REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestCombinedMask.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see https://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see https://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
86
87#include "TRestCombinedMask.h"
88
89#include "TRandom3.h"
90
91ClassImp(TRestCombinedMask);
92
97
112TRestCombinedMask::TRestCombinedMask(const char* cfgFileName, std::string name)
113 : TRestPatternMask(cfgFileName) {
114 Initialize();
115
117
119}
120
125
131 SetSectionName(this->ClassName());
132 SetType("Combined");
133
134 for (const auto mask : fMasks) {
135 mask->Initialize();
136 if (mask->GetMaskRadius() > fMaskRadius) fMaskRadius = mask->GetMaskRadius();
137 }
138}
139
148Int_t TRestCombinedMask::GetRegion(Double_t& x, Double_t& y) {
149 Int_t region = 0;
150 Double_t xIn = x;
151 Double_t yIn = y;
152 for (const auto mask : fMasks) {
153 Int_t id = mask->GetRegion(x, y);
154
155 // The (x,y) coordinates are transformed for each mask.
156 // We need to recover the original point to be evaluated for each mask.
157 x = xIn;
158 y = yIn;
159
160 RESTDebug << "TRestCombinedMask::GetRegion. Mask type: " << mask->GetType() << " region : " << id
161 << RESTendl;
162 if (id == 0) return 0;
163
164 region = id + region * mask->GetMaxRegions();
165 }
166
167 return region;
168}
169
175
176 int cont = 0;
178 while (msk != nullptr) {
179 AddMask(msk);
180 cont++;
181 msk = (TRestPatternMask*)this->InstantiateChildMetadata(cont, "Mask");
182 }
183 Initialize();
184}
185
191
192 PrintMask();
193
194 Int_t cont = 1;
195 for (const auto mask : fMasks) {
196 RESTMetadata << " == MASK " << cont << " == " << RESTendl;
197 cont++;
198 mask->PrintMask();
199 RESTMetadata << "++++" << RESTendl;
200 }
201}
202
209 RESTMetadata << "++++" << RESTendl;
210}
211
217 RESTMetadata << " - Number of masks : " << fMasks.size() << RESTendl;
218}
A class used to define and generate a combined structure mask.
void PrintMaskMembers() override
Prints on screen the information about the metadata members from this class excluding common metadata...
TRestCombinedMask()
Default constructor.
void PrintMask() override
Prints on screen the information about the metadata members from this class, including common pattern...
void InitFromConfigFile() override
Implements class initialization through RML.
Int_t GetRegion(Double_t &x, Double_t &y) override
It returns a number identifying the region where the particle with coordinates (x,...
void PrintMetadata() override
Prints on screen the complete information about the metadata members from this class.
~TRestCombinedMask()
Default destructor.
void Initialize() override
Function to initialize input/output event members and define the section name.
endl_t RESTendl
Termination flag object for TRestStringOutput.
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
TRestMetadata * InstantiateChildMetadata(int index, std::string pattern="")
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadat...
virtual void InitFromConfigFile()
To make settings from rml file. This method must be implemented in the derived class.
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string fConfigFileName
Full name of the rml file.
An abstract class used to encapsulate different mask pattern class definitions.
void SetType(const std::string &type)
It defines the mask type. To be called by the inherited class constructor.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestPatternMask.
Double_t fMaskRadius
The maximum mask radius in mm (if 0 it will be infinite)
@ REST_Info
+show most of the information for each steps