REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestGridMask.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
105
106#include "TRestGridMask.h"
107
108#include "TRandom3.h"
109
110ClassImp(TRestGridMask);
111
116
131TRestGridMask::TRestGridMask(const char* cfgFileName, std::string name) : TRestPatternMask(cfgFileName) {
132 Initialize();
133
135
137}
138
143
149 SetSectionName(this->ClassName());
150 SetType("Grid");
151}
152
161Int_t TRestGridMask::GetRegion(Double_t& x, Double_t& y) {
162 if (TRestPatternMask::GetRegion(x, y)) return 0;
163
164 Double_t xEval = fGridThickness / 2. + x;
165
166 Int_t xcont = 0;
167 if (xEval > 0) {
168 while (xEval > fGridGap) {
169 xEval -= fGridGap;
170 xcont++;
171 }
172 } else {
173 while (xEval < 0) {
174 xEval += fGridGap;
175 xcont--;
176 }
177 }
178
179 if (xEval < fGridThickness) return 0;
180
181 Double_t yEval = fGridThickness / 2. + y;
182
183 Int_t ycont = 0;
184 if (yEval > 0) {
185 while (yEval > fGridGap) {
186 yEval -= fGridGap;
187 ycont++;
188 }
189 } else {
190 while (yEval < 0) {
191 yEval += fGridGap;
192 ycont--;
193 }
194 }
195
196 if (yEval < fGridThickness) return 0;
197
198 xcont = xcont % fModulus;
199 if (xcont < 0) xcont += fModulus;
200
201 ycont = ycont % fModulus;
202 if (ycont < 0) ycont += fModulus;
203
204 return 1 + (fModulus * ycont + xcont) % fMaxRegions;
205}
206
212
214 RESTMetadata << "----" << RESTendl;
215}
216
223 RESTMetadata << "----" << RESTendl;
225}
226
232 RESTMetadata << " - Grid gap : " << fGridGap << " mm" << RESTendl;
233 RESTMetadata << " - Grid thickness : " << fGridThickness << " mm" << RESTendl;
234}
A class used to define a grid mask pattern.
Definition: TRestGridMask.h:29
Double_t fGridThickness
The width of the grid structure in mm.
Definition: TRestGridMask.h:37
void PrintMask() override
Prints on screen the information about the metadata members of TRestRingsMask, including common patte...
Double_t fGridGap
The periodity of the grid structure in mm.
Definition: TRestGridMask.h:34
void PrintMetadata() override
Prints on screen the complete information about the metadata members from this class.
void Initialize() override
Function to initialize input/output event members and define the section name.
Int_t fModulus
It defines the maximum number of cells/regions in each axis.
Definition: TRestGridMask.h:40
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 PrintMaskMembers() override
Prints on screen the information about the metadata members of TRestRingsMask, excluding common metad...
TRestGridMask()
Default constructor.
~TRestGridMask()
Default destructor.
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.
@ REST_Info
+show most of the information for each steps