|
| 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 | + |
| 23 | +///////////////////////////////////////////////////////////////////////// |
| 24 | +/// This class defines a stripped pattern. It defines a periodicity |
| 25 | +/// and a thickness for the strips. The method TRestRadialStrippedMask::GetRegion |
| 26 | +/// will return a unique id for each region in between strips. |
| 27 | +/// |
| 28 | +/// The stripped structure is centered in (0,0) and it can be shifted using |
| 29 | +/// the offset defined inside TRestPatternMask. The pattern will be only |
| 30 | +/// delimited by the limits imposed inside TRestPatternMask. |
| 31 | +/// |
| 32 | +/// ### Specific stripped metadata parameters |
| 33 | +/// |
| 34 | +/// * **stripsAngle**: This parameter defines the strips angular periodicity. |
| 35 | +/// * **stripsThickness**: The thickness of the strips. |
| 36 | +/// * **modulus**: A number that defines the range of ids used to identify |
| 37 | +/// the different regions inside the stripped pattern. If modulus is 10, |
| 38 | +/// then we will only be able to identify up to 10 unique regions. If a |
| 39 | +/// larger amount of regions is found, it will happen that two regions will |
| 40 | +/// be assigned the same id. |
| 41 | +/// |
| 42 | +/// ### Common pattern metadata parameters |
| 43 | +/// |
| 44 | +/// On top of the metadata class parameters, we may define common pattern |
| 45 | +/// parameters to induce an offset and rotation to the pattern. |
| 46 | +/// |
| 47 | +/// * **offset**: A parameter to shift the pattern window mask. |
| 48 | +/// * **rotationAngle**: An angle given in radians to rotate the pattern. |
| 49 | +/// * **maskRadius**: A radius defining the limits of the circular mask. |
| 50 | +/// |
| 51 | +/// ### Examples |
| 52 | +/// |
| 53 | +/// Mask pattern RML definitions can be found inside the file |
| 54 | +/// `REST_PATH/examples/masks.rml`. |
| 55 | +/// |
| 56 | +/// The following definition ilustrates a complete RML implementation of a |
| 57 | +/// TRestRadialStrippedMask. |
| 58 | +/// |
| 59 | +/// \code |
| 60 | +/// <TRestRadialStrippedMask name="strongback" verboseLevel="warning"> |
| 61 | +/// <parameter name="maskRadius" value="30cm" /> |
| 62 | +/// <parameter name="offset" value="(5,5)cm" /> |
| 63 | +/// <parameter name="rotationAngle" value="30degrees" /> |
| 64 | +/// |
| 65 | +/// <parameter name="stripsAngle" value="60degrees" /> |
| 66 | +/// <parameter name="stripsThickness" value="2.5cm" /> |
| 67 | +/// </TRestRadialStrippedMask> |
| 68 | +/// \endcode |
| 69 | +/// |
| 70 | +/// The basic use of this class is provided by the TRestRadialStrippedMask::GetRegion |
| 71 | +/// method. For example: |
| 72 | +/// |
| 73 | +/// \code |
| 74 | +/// TRestRadialStrippedMask mask("masks.rml", "radialStrips"); |
| 75 | +/// Int_t id = mask.GetRegion( 12.5, 4.3 ); |
| 76 | +/// std::cout << "Region id is : " << id << endl; |
| 77 | +/// \endcode |
| 78 | +/// |
| 79 | +/// The following figure may be generated using the TRestPatternMask::DrawMonteCarlo |
| 80 | +/// method. |
| 81 | +/// |
| 82 | +/// \code |
| 83 | +/// TRestRadialStrippedMask mask("masks.rml", "radialStrips"); |
| 84 | +/// TCanvas *c = mask.DrawMonteCarlo(30000); |
| 85 | +/// c->Draw(); |
| 86 | +/// c->Print("radialstrippedmask.png"); |
| 87 | +/// \endcode |
| 88 | +/// |
| 89 | +/// \htmlonly <style>div.image img[src="radialstrippedmask.png"]{width:500px;}</style> \endhtmlonly |
| 90 | +///  |
| 91 | +/// |
| 92 | +///---------------------------------------------------------------------- |
| 93 | +/// |
| 94 | +/// REST-for-Physics - Software for Rare Event Searches Toolkit |
| 95 | +/// |
| 96 | +/// History of developments: |
| 97 | +/// |
| 98 | +/// 2022-05: First implementation of TRestRadialStrippedMask |
| 99 | +/// Javier Galan |
| 100 | +/// |
| 101 | +/// \class TRestRadialStrippedMask |
| 102 | +/// \author: Javier Galan - [email protected] |
| 103 | +/// |
| 104 | +/// <hr> |
| 105 | +/// |
| 106 | + |
| 107 | +#include "TRestRadialStrippedMask.h" |
| 108 | + |
| 109 | +#include "TRandom3.h" |
| 110 | + |
| 111 | +ClassImp(TRestRadialStrippedMask); |
| 112 | + |
| 113 | +/////////////////////////////////////////////// |
| 114 | +/// \brief Default constructor |
| 115 | +/// |
| 116 | +TRestRadialStrippedMask::TRestRadialStrippedMask() : TRestPatternMask() { Initialize(); } |
| 117 | + |
| 118 | +///////////////////////////////////////////// |
| 119 | +/// \brief Constructor loading data from a config file |
| 120 | +/// |
| 121 | +/// If no configuration path is defined using TRestMetadata::SetConfigFilePath |
| 122 | +/// the path to the config file must be specified using full path, absolute or |
| 123 | +/// relative. |
| 124 | +/// |
| 125 | +/// The default behaviour is that the config file must be specified with |
| 126 | +/// full path, absolute or relative. |
| 127 | +/// |
| 128 | +/// \param cfgFileName A const char* giving the path to an RML file. |
| 129 | +/// \param name The name of the specific metadata. It will be used to find the |
| 130 | +/// corresponding TRestRadialStrippedMask section inside the RML. |
| 131 | +/// |
| 132 | +TRestRadialStrippedMask::TRestRadialStrippedMask(const char* cfgFileName, std::string name) |
| 133 | + : TRestPatternMask(cfgFileName) { |
| 134 | + Initialize(); |
| 135 | + |
| 136 | + LoadConfigFromFile(fConfigFileName, name); |
| 137 | + |
| 138 | + if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) PrintMetadata(); |
| 139 | +} |
| 140 | + |
| 141 | +/////////////////////////////////////////////// |
| 142 | +/// \brief Default destructor |
| 143 | +/// |
| 144 | +TRestRadialStrippedMask::~TRestRadialStrippedMask() {} |
| 145 | + |
| 146 | +/////////////////////////////////////////////// |
| 147 | +/// \brief Function to initialize input/output event members and define |
| 148 | +/// the section name |
| 149 | +/// |
| 150 | +void TRestRadialStrippedMask::Initialize() { |
| 151 | + SetSectionName(this->ClassName()); |
| 152 | + SetType("RadialStripped"); |
| 153 | +} |
| 154 | + |
| 155 | +/////////////////////////////////////////////// |
| 156 | +/// \brief It returns a number identifying the region where the particle |
| 157 | +/// with coordinates (x,y) felt in. The method returns 0 if the particle |
| 158 | +/// hits the pattern. |
| 159 | +/// |
| 160 | +/// The particle will be counter-rotated to emulate the mask rotation |
| 161 | +/// using the method TRestPatternMask::ApplyCommonMaskTransformation |
| 162 | +/// |
| 163 | +Int_t TRestRadialStrippedMask::GetRegion(Double_t& x, Double_t& y) { |
| 164 | + if (TRestPatternMask::GetRegion(x, y)) return 0; |
| 165 | + |
| 166 | + Double_t d = TMath::Sqrt(x * x + y * y); |
| 167 | + |
| 168 | + if (d < fInitialRadius) { |
| 169 | + if (fInternalRegionRadius > 0 && d < fInternalRegionRadius) return 1; |
| 170 | + |
| 171 | + return 0; |
| 172 | + } |
| 173 | + |
| 174 | + TVector2 point(x, y); |
| 175 | + Double_t phi = point.Phi(); |
| 176 | + |
| 177 | + /// phi determines the region where the point is found |
| 178 | + Int_t region = (Int_t)(phi / fStripsAngle); |
| 179 | + region = 2 + region % fMaxRegions; |
| 180 | + |
| 181 | + Double_t angle = 0; |
| 182 | + /// Checking if we hit an arm |
| 183 | + while (angle < 2 * TMath::Pi()) { |
| 184 | + if (point.Y() < fStripsThickness / 2. && point.Y() > -fStripsThickness / 2. && point.X() >= 0) |
| 185 | + return 0; |
| 186 | + |
| 187 | + point = point.Rotate(fStripsAngle); |
| 188 | + angle += fStripsAngle; |
| 189 | + } |
| 190 | + |
| 191 | + return 1 + region % fModulus; |
| 192 | +} |
| 193 | + |
| 194 | +///////////////////////////////////////////// |
| 195 | +/// \brief Prints on screen the complete information about the metadata members from this class |
| 196 | +/// |
| 197 | +void TRestRadialStrippedMask::PrintMetadata() { |
| 198 | + TRestPatternMask::PrintMetadata(); |
| 199 | + |
| 200 | + PrintMaskMembers(); |
| 201 | + RESTMetadata << "++++" << RESTendl; |
| 202 | +} |
| 203 | + |
| 204 | +///////////////////////////////////////////// |
| 205 | +/// \brief Prints on screen the information about the metadata members of TRestRingsMask, |
| 206 | +/// including common pattern headers, but without common metadata headers. |
| 207 | +/// |
| 208 | +void TRestRadialStrippedMask::PrintMask() { |
| 209 | + PrintCommonPatternMembers(); |
| 210 | + RESTMetadata << "----" << RESTendl; |
| 211 | + PrintMaskMembers(); |
| 212 | +} |
| 213 | + |
| 214 | +///////////////////////////////////////////// |
| 215 | +/// \brief Prints on screen the information about the metadata members of TRestRingsMask, |
| 216 | +/// excluding common metadata headers. |
| 217 | +/// |
| 218 | +void TRestRadialStrippedMask::PrintMaskMembers() { |
| 219 | + RESTMetadata << " - Strips angle : " << fStripsAngle * units("degrees") << " degrees" << RESTendl; |
| 220 | + RESTMetadata << " - Strips thickness : " << fStripsThickness << " mm" << RESTendl; |
| 221 | +} |
0 commit comments