REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRingsMask.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 
110 
111 #include "TRestRingsMask.h"
112 
113 #include "TRandom3.h"
114 
115 ClassImp(TRestRingsMask);
116 
121 
136 TRestRingsMask::TRestRingsMask(const char* cfgFileName, std::string name) : TRestPatternMask(cfgFileName) {
137  Initialize();
138 
140 
142 }
143 
148 
154  SetSectionName(this->ClassName());
155  SetType("Rings");
156 
157  if (fNRings > 0) GenerateRings();
158 }
159 
168 Int_t TRestRingsMask::GetRegion(Double_t& x, Double_t& y) {
169  if (TRestPatternMask::GetRegion(x, y)) return 0;
170 
171  Double_t r = TMath::Sqrt(x * x + y * y);
172  int cont = 0;
173  for (const auto& ringRadius : fRingsRadii) {
174  if (r < ringRadius.second && r >= ringRadius.first) return cont % fMaxRegions + 1;
175  cont++;
176  }
177  return 0;
178 }
179 
185  fRingsRadii.clear();
186  for (int n = 0; n < fNRings; n++) {
187  Double_t inR = fInitialRadius + n * fRingsGap;
188  Double_t outR = fRingsThickness + fInitialRadius + n * fRingsGap;
189 
190  std::pair<Double_t, Double_t> p(inR, outR);
191  fRingsRadii.push_back(p);
192  }
193 }
194 
200 
202  RESTMetadata << "----" << RESTendl;
203 }
204 
211  RESTMetadata << "----" << RESTendl;
213 }
214 
220  if (fRingsGap > 0) RESTMetadata << " - Rings gap : " << fRingsGap << " mm" << RESTendl;
221  if (fRingsThickness > 0) RESTMetadata << " - Rings thickness : " << fRingsThickness << " mm" << RESTendl;
222  if (fNRings > 0) RESTMetadata << " - Number of rings : " << fNRings << RESTendl;
223  if (fInitialRadius > 0) RESTMetadata << " - Initial radius : " << fInitialRadius << " mm" << RESTendl;
224  if (fRingsRadii.size() > 0) {
225  if (fNRings > 0) RESTMetadata << "-----" << RESTendl;
226  RESTMetadata << "Inner radii : (";
227  for (unsigned int n = 0; n < fRingsRadii.size(); n++) {
228  if (n > 0) RESTMetadata << ", ";
229  RESTMetadata << fRingsRadii[n].first;
230  }
231  RESTMetadata << ")" << RESTendl;
232  }
233  if (fRingsRadii.size() > 0) {
234  RESTMetadata << "Outter radii : (";
235  for (unsigned int n = 0; n < fRingsRadii.size(); n++) {
236  if (n > 0) RESTMetadata << ", ";
237  RESTMetadata << fRingsRadii[n].second;
238  }
239  RESTMetadata << ")" << RESTendl;
240  }
241 }
242 
248  for (unsigned int n = 0; n < fRingsRadii.size(); n++)
249  std::cout << n << " - " << fRingsRadii[n].first << " - " << fRingsRadii[n].second << std::endl;
250 }
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.
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.
Int_t fMaxRegions
The maximum number of regions allowed in each mask.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestPatternMask.
virtual Int_t GetRegion(Double_t &x, Double_t &y)
To be implemented at the inherited class with the pattern and region identification logic.
void PrintCommonPatternMembers()
Prints on screen the information about the metadata members without header.
A class used to define a rings mask pattern.
void GenerateRings()
It will initialize the variable fRingsRadii using the number of radius, initial radius,...
virtual Int_t GetRegion(Double_t &x, Double_t &y) override
It returns a number identifying the region where the particle with coordinates (x,...
void Initialize() override
Function to initialize input/output event members and define the section name.
Double_t fRingsGap
The periodity of the rings structure in mm. Optionally used to initialize the rings.
void PrintMask() override
Prints on screen the information about the metadata members of TRestRingsMask, including common patte...
TRestRingsMask()
Default constructor.
Double_t fRingsThickness
The width of the rings structure in mm. Optionally used to initialize the rings.
void PrintMetadata() override
Prints on screen the information about the metadata members from this class.
~TRestRingsMask()
Default destructor.
Int_t fNRings
The number of rings inside the structure.
void PrintMaskMembers() override
Prints on screen the information about the metadata members of TRestRingsMask, excluding common metad...
Double_t fInitialRadius
The initial radius for the inner ring.
std::vector< std::pair< Double_t, Double_t > > fRingsRadii
A pair containing inner/outter radius for each ring.
void PrintRings()
Prints on screen the information about the metadata members of TRestRingsMask, excluding common metad...
@ REST_Info
+show most of the information for each steps