Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons required by XMM Wolter optics integration inside axionlib #235

Merged
merged 43 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2f63dfa
Merge branch 'jgalan_metadata_child' into xmm_optics
jgalan May 30, 2022
c5f56a8
TRestTools::GetColumnFromTable method added
jgalan May 30, 2022
b63b352
TRestPatternMask::GetRegion method documented
jgalan May 31, 2022
2a2546f
TRestMySQLToAnalysisProcess::Initialize adding SQL not supported warning
jgalan Jun 4, 2022
a3dda0c
TRestMetadata::GetChildMetadata new method added
jgalan Jun 4, 2022
6c3c529
TRestPatternMask::fMaxRegions metadata member added
jgalan Jun 4, 2022
a375422
TRestXYZMask implemented the use of fMaxRegions
jgalan Jun 4, 2022
fb7077c
Updating masks Print methods scheme
jgalan Jun 4, 2022
2d9efcf
masks.rml Adding a first TRestCombinedMask example
jgalan Jun 4, 2022
b2bb336
TRestCombinedMask new mask class added
jgalan Jun 4, 2022
59b9f5c
TRestSpiderMask::PrintMaskMembers adding ranges output
jgalan Jun 4, 2022
285c000
TRestCombinedMask. Implementing Initialize
jgalan Jun 4, 2022
0cb3fa4
TRestCombinedMask::Initialize is now public
jgalan Jun 4, 2022
39f2f43
TRestPatternMask::SetMaxRegions added
jgalan Jun 4, 2022
7da140a
TRestCombinedMask. Fixing fMaskRadius initialization
jgalan Jun 4, 2022
dee6727
Updating masks.rml
jgalan Jun 4, 2022
296512c
Adding an image generated using TRestCombinedMask
jgalan Jun 4, 2022
ab8300c
TRestCombinedMask. Updating documentation
jgalan Jun 4, 2022
abb1e44
TRestCombinedMask. Reducing figure size
jgalan Jun 4, 2022
78b04bd
TRestCombineMask. Minor documentation fix
jgalan Jun 4, 2022
e97d19e
Moving TRestMask related classes to a dedicated directory
jgalan Jun 5, 2022
7dc1144
TRestMetadata::GetChildMetadata. Fixing retrieval without specifying …
jgalan Jun 7, 2022
9017f31
TRestPhysics::GetConeNormal method added
jgalan Jun 7, 2022
65bc02d
TRestPhysics::GetVectorReflection method added
jgalan Jun 7, 2022
b5a5f00
Merge branch 'jgalan_metadata_child' into xmm_optics
jgalan Jun 7, 2022
8eddc59
TRestCombinedMask renaming GetChildMetadata to InstantiateChilMetadata
jgalan Jun 7, 2022
f8da8e3
Merge branch 'master' into xmm_optics
jgalan Jun 9, 2022
f4389e1
Merge branch 'master' into xmm_optics
jgalan Jun 15, 2022
182975e
Fixing github validation pipeline
jgalan Jun 15, 2022
4a40d68
Merge branch 'master' into xmm_optics
jgalan Jun 15, 2022
4069368
Fixing github validation
jgalan Jun 15, 2022
f3bc9ef
Merge branch 'master' into xmm_optics
jgalan Jun 15, 2022
5d8cb71
TRestMetadata::InstantiateChildMetadata. Now it calls Initialize
jgalan Jun 16, 2022
d43967f
TRestPhysics::GetConeNormal
jgalan Jun 16, 2022
83c7c5d
TRestCombinedMask::GetMask method added
jgalan Jun 16, 2022
3b670c5
TRestRingsMask::PrintRings method added
jgalan Jun 16, 2022
e4cd22a
TRestRingsMask. Aesthetics
jgalan Jun 16, 2022
42dd69e
TRestCombinedMask. Adding error message
jgalan Jun 16, 2022
bafa027
TRestCombinedMask. Adding debug message
jgalan Jun 16, 2022
08dfac9
restRoot now includes units system by default
jgalan Jun 20, 2022
4a64e76
TRestStringHelper::Double/IntegerToString now accepts to redefine the…
jgalan Jun 20, 2022
b077c4f
Merge branch 'jgalan_minor_updates' into xmm_optics
jgalan Jun 20, 2022
77b8a20
TRestPhysics::GetVectorsAngle added
jgalan Jun 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/doxygen/images/combinedmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 66 additions & 47 deletions examples/masks.rml
Original file line number Diff line number Diff line change
@@ -1,50 +1,69 @@
<?xml version="1.0"?>
<masks>
<TRestGridMask name="strongback" verboseLevel="warning">
<parameter name="maskRadius" value="20"/>
<parameter name="offset" value="(5,5)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="gridGap" value="1cm"/>
<parameter name="gridThickness" value="2mm"/>
</TRestGridMask>
<TRestStrippedMask name="stripped" verboseLevel="warning">
<parameter name="maskRadius" value="2cm"/>
<parameter name="offset" value="(3,3)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="stripsGap" value="12mm"/>
<parameter name="stripsThickness" value="1.2mm"/>
</TRestStrippedMask>
<TRestRingsMask name="rings" verboseLevel="warning">
<parameter name="maskRadius" value="9cm"/>
<parameter name="offset" value="(3,3)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="ringsGap" value="12mm"/>
<parameter name="ringsThickness" value="9mm"/>
<parameter name="initialRadius" value="3cm"/>
<parameter name="nRings" value="5"/>
</TRestRingsMask>
<TRestSpiderMask name="spider1" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="10"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="80degrees"/>
<parameter name="initialRadius" value="12cm"/>
</TRestSpiderMask>
<TRestSpiderMask name="spider2" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="0"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="30degrees"/>
<parameter name="initialRadius" value="3cm"/>
</TRestSpiderMask>
<TRestSpiderMask name="spider3" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="30deg"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="60degrees"/>
<parameter name="initialRadius" value="6cm"/>
</TRestSpiderMask>
<TRestGridMask name="strongback" verboseLevel="warning">
<parameter name="maskRadius" value="20"/>
<parameter name="offset" value="(5,5)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="gridGap" value="1cm"/>
<parameter name="gridThickness" value="2mm"/>
</TRestGridMask>
<TRestStrippedMask name="stripped" verboseLevel="warning">
<parameter name="maskRadius" value="2cm"/>
<parameter name="offset" value="(3,3)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="stripsGap" value="12mm"/>
<parameter name="stripsThickness" value="1.2mm"/>
</TRestStrippedMask>
<TRestRingsMask name="rings" verboseLevel="warning">
<parameter name="maskRadius" value="9cm"/>
<parameter name="offset" value="(3,3)mm"/>
<parameter name="rotationAngle" value="0.5"/>
<parameter name="ringsGap" value="12mm"/>
<parameter name="ringsThickness" value="9mm"/>
<parameter name="initialRadius" value="3cm"/>
<parameter name="nRings" value="5"/>
</TRestRingsMask>
<TRestSpiderMask name="spider1" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="10"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="80degrees"/>
<parameter name="initialRadius" value="12cm"/>
</TRestSpiderMask>
<TRestSpiderMask name="spider2" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="0"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="30degrees"/>
<parameter name="initialRadius" value="3cm"/>
</TRestSpiderMask>
<TRestSpiderMask name="spider3" verboseLevel="info">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="30deg"/>
<parameter name="armsWidth" value="5deg"/>
<parameter name="armsSeparationAngle" value="60degrees"/>
<parameter name="initialRadius" value="6cm"/>
</TRestSpiderMask>
<TRestCombinedMask name="combined" verboseLevel="warning">
<TRestSpiderMask name="spider1" verboseLevel="warning">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)cm"/>
<parameter name="rotationAngle" value="10deg"/>
<parameter name="armsWidth" value="7deg"/>
<parameter name="armsSeparationAngle" value="30deg"/>
<parameter name="initialRadius" value="5cm"/>
</TRestSpiderMask>
<TRestRingsMask name="rings" verboseLevel="warning">
<parameter name="maskRadius" value="20cm"/>
<parameter name="offset" value="(0,0)mm"/>
<parameter name="rotationAngle" value="0"/>
<parameter name="ringsGap" value="25mm"/>
<parameter name="ringsThickness" value="15mm"/>
<parameter name="initialRadius" value="5cm"/>
<parameter name="nRings" value="6"/>
</TRestRingsMask>
</TRestCombinedMask>
</masks>
3 changes: 2 additions & 1 deletion source/bin/restRoot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace std;
#ifdef WIN32
// in windows the pointer address from string conversion is without "0x", we must add
// the prefix so that ROOT can correctly initialize run/metadata objects
#define PTR_ADDR_PREFIX "0x"
#define PTR_ADDR_PREFIX "0x"
#else
#define PTR_ADDR_PREFIX ""
#endif // WIN32
Expand Down Expand Up @@ -75,6 +75,7 @@ int main(int argc, char* argv[]) {

gROOT->ProcessLine("#include <TRestStringHelper.h>");
gROOT->ProcessLine("#include <TRestPhysics.h>");
gROOT->ProcessLine("#include <TRestSystemOfUnits.h>");
if (loadMacros) {
if (!silent) printf("= Loading macros ...\n");
auto a = TRestTools::Execute(
Expand Down
2 changes: 1 addition & 1 deletion source/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(external)

set(contents external/tinyxml tools core analysis)
set(contents external/tinyxml tools core analysis masks)

file(GLOB_RECURSE addon_src
"tiny*cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,14 @@ void TRestMySQLToAnalysisProcess::InitProcess() {
/// \brief Function to initialize input/output event members and define the
/// section name and library version
///
void TRestMySQLToAnalysisProcess::Initialize() { SetSectionName(this->ClassName()); }
void TRestMySQLToAnalysisProcess::Initialize() {
SetSectionName(this->ClassName());

#ifndef USE_SQL
RESTWarning << "TRestMySQLToAnalysisProcess. REST was compiled without mySQL support" << RESTendl;
RESTWarning << "This process will not be funcional" << RESTendl;
#endif
}

///////////////////////////////////////////////
/// \brief The main processing event function
Expand Down
1 change: 1 addition & 0 deletions source/framework/core/inc/TRestMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class TRestMetadata : public TNamed {
Int_t LoadConfigFromFile(const std::string& configFilename, const std::string& sectionName = "");
Int_t LoadConfigFromBuffer();

TRestMetadata* InstantiateChildMetadata(int index, std::string pattern = "");
TRestMetadata* InstantiateChildMetadata(std::string pattern = "", std::string name = "");

/// Making default settings.
Expand Down
64 changes: 60 additions & 4 deletions source/framework/core/src/TRestMetadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,63 @@ Int_t TRestMetadata::LoadConfigFromBuffer() {

///////////////////////////////////////////////
/// \brief This method will retrieve a new TRestMetadata instance of a child element
/// of the present TRestMetadata instance. I.e. `TRestChildClass` in the following
/// example:
/// of the present TRestMetadata instance based on the `index` given by argument,
/// which defines the element order to be retrieved, 0 for first element found, 1 for
/// the second element found, etc.
///
/// In brief, it will create an instance of `TRestChildClass` in the following example:
///
/// \code
/// <TRestThisMetadataClass ...
/// <TRestChildClass ...> <!-- if index = 0 -->
/// <TRestChildClass ...> <!-- if index = 1 -->
/// <TRestChildClass ...> <!-- if index = 2 -->
/// \endcode
///
/// An optional argument may help to restrict the search to a particular metadata
/// element.
///
/// - *pattern*: If a pattern value is given, then the pattern must be contained inside
/// the metadata class name. I.e. pattern="TRestGeant4" will require that the class
/// belongs to the geant4 library.
///
/// Otherwise, the first child section that satisfies that it starts by `TRest` will be
/// considered.
///
/// If no child element is found with the required criteria, `nullptr` will be returned.
///
TRestMetadata* TRestMetadata::InstantiateChildMetadata(int index, std::string pattern) {
int count = 0;
auto paraele = fElement->FirstChildElement();
while (paraele != nullptr) {
std::string xmlChild = paraele->Value();
if (xmlChild.find("TRest") == 0) {
if (pattern == "" || xmlChild.find(pattern) != string::npos) {
if (count == index) {
TClass* c = TClass::GetClass(xmlChild.c_str());
if (c) // this means we have the metadata class was found
{
TRestMetadata* md = (TRestMetadata*)c->New();
TiXmlElement* rootEle = GetElementFromFile(fConfigFileName);
TiXmlElement* Global = GetElement("globals", rootEle);
md->LoadConfigFromElement(paraele, Global, {});
md->Initialize();
return md;
}
}
count++;
}
}
paraele = paraele->NextSiblingElement();
}
return nullptr;
}

///////////////////////////////////////////////
/// \brief This method will retrieve a new TRestMetadata instance of a child element
/// of the present TRestMetadata instance based on the `name` given by argument.
///
/// In brief, it will create an instance of `TRestChildClass` in the following example:
///
/// \code
/// <TRestThisMetadataClass ...
Expand All @@ -688,22 +743,23 @@ Int_t TRestMetadata::LoadConfigFromBuffer() {
/// Otherwise, the first child section that satisfies that it starts by `TRest` will be
/// returned.
///
/// If no child element is found `nullptr` will be returned.
/// If no child element is found with the required criteria, `nullptr` will be returned.
///
TRestMetadata* TRestMetadata::InstantiateChildMetadata(std::string pattern, std::string name) {
auto paraele = fElement->FirstChildElement();
while (paraele != nullptr) {
std::string xmlChild = paraele->Value();
if (xmlChild.find("TRest") == 0) {
if (pattern.empty() || xmlChild.find(pattern) != string::npos) {
if (!name.empty() && name == (string)paraele->Attribute("name")) {
if (name.empty() || !name.empty() && name == (string)paraele->Attribute("name")) {
TClass* c = TClass::GetClass(xmlChild.c_str());
if (c) // this means we have the metadata class was found
{
TRestMetadata* md = (TRestMetadata*)c->New();
TiXmlElement* rootEle = GetElementFromFile(fConfigFileName);
TiXmlElement* Global = GetElement("globals", rootEle);
md->LoadConfigFromElement(paraele, Global, {});
md->Initialize();
return md;
}
}
Expand Down
1 change: 1 addition & 0 deletions source/framework/masks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pattern masks implemented to be used un ray-tracking at axionlib, but given their generic nature have been placed directly in the framework.
60 changes: 60 additions & 0 deletions source/framework/masks/inc/TRestCombinedMask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*************************************************************************
* This file is part of the REST software framework. *
* *
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
* For more information see https://gifna.unizar.es/trex *
* *
* REST is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* REST is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have a copy of the GNU General Public License along with *
* REST in $REST_PATH/LICENSE. *
* If not, see https://www.gnu.org/licenses/. *
* For the list of contributors see $REST_PATH/CREDITS. *
*************************************************************************/

#ifndef REST_TRestCombinedMask
#define REST_TRestCombinedMask

#include <TRestPatternMask.h>

/// A class used to define and generate a combined structure mask
class TRestCombinedMask : public TRestPatternMask {
private:
std::vector<TRestPatternMask*> fMasks;

public:
void Initialize() override;

void AddMask(TRestPatternMask* mask) { fMasks.push_back(mask); }

TRestPatternMask* const& GetMask(int index) const {
if (index < fMasks.size()) {
return fMasks[index];
}
if (index == 0) RESTError << "TRestCombinedMask does not contain any masks" << RESTendl;
return fMasks[0];
}

Int_t GetRegion(Double_t x, Double_t y) override;

void InitFromConfigFile() override;

void PrintMetadata() override;
void PrintMaskMembers() override;
void PrintMask() override;

TRestCombinedMask();
TRestCombinedMask(const char* cfgFileName, std::string name = "");
~TRestCombinedMask();

ClassDefOverride(TRestCombinedMask, 1);
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class TRestGridMask : public TRestPatternMask {
Int_t GetModulus() { return fModulus; }

void PrintMetadata() override;

void Print() override;
void PrintMaskMembers() override;
void PrintMask() override;

TRestGridMask();
TRestGridMask(const char* cfgFileName, std::string name = "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class TRestPatternMask : public TRestMetadata {

protected:
/// The maximum mask radius in mm (if 0 it will be infinite)
Double_t fMaskRadius = 0;
Double_t fMaskRadius = 0; //<

/// The maximum number of regions allowed in each mask
Int_t fMaxRegions = 100; //<

/// It defines the mask type. To be called by the inherited class constructor.
void SetType(const std::string& type) { fPatternType = type; }
Expand All @@ -55,8 +58,13 @@ class TRestPatternMask : public TRestMetadata {
TRestPatternMask(const char* cfgFileName, std::string name = "");

public:
Int_t GetMaxRegions() { return fMaxRegions; }

void SetMaxRegions(Int_t regions) { fMaxRegions = regions; }

Bool_t HitsPattern(Double_t x, Double_t y);

/// To be implemented at the inherited class with the pattern and region identification logic
virtual Int_t GetRegion(Double_t x, Double_t y) = 0;

/// It returns the mask pattern type
Expand All @@ -80,9 +88,12 @@ class TRestPatternMask : public TRestMetadata {
/// It defines the mask radius
void SetMaskRadius(const Double_t& radius) { fMaskRadius = radius; }

void PrintMetadata() override;
void PrintCommonPatternMembers();

virtual void PrintMaskMembers() = 0;
virtual void PrintMask() = 0;

virtual void Print();
void PrintMetadata() override;

TCanvas* DrawMonteCarlo(Int_t nSamples = 10000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class TRestRingsMask : public TRestPatternMask {
}

void PrintMetadata() override;
void PrintMaskMembers() override;
void PrintMask() override;
void PrintRings();

TRestRingsMask();
TRestRingsMask(const char* cfgFileName, std::string name = "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
class TRestSpiderMask : public TRestPatternMask {
private:
void Initialize() override;

/// The angle between two consecutive spider arms measured in radians.
Double_t fArmsSeparationAngle = 0; //<

Expand Down Expand Up @@ -60,6 +59,8 @@ class TRestSpiderMask : public TRestPatternMask {
Double_t GetInitialRadius() { return fInitialRadius; }

void PrintMetadata() override;
void PrintMaskMembers() override;
void PrintMask() override;

TRestSpiderMask();
TRestSpiderMask(const char* cfgFileName, std::string name = "");
Expand Down
Loading