All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/GeometryTools/CRTGeoAlg.h
Go to the documentation of this file.
1 #ifndef CRTGEOALG_H_SEEN
2 #define CRTGEOALG_H_SEEN
3 
4 
5 ///////////////////////////////////////////////
6 // CRTGeoAlg.h
7 //
8 // Wrapper for some awkward CRT geometry things
9 // T Brooks (tbrooks@fnal.gov), November 2018
10 ///////////////////////////////////////////////
11 
12 // framework
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "canvas/Persistency/Common/Ptr.h"
18 #include "canvas/Persistency/Common/PtrVector.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 
22 // LArSoft
28 #include "nusimdata/SimulationBase/MCParticle.h"
30 
31 // c++
32 #include <vector>
33 
34 // ROOT
35 #include "TVector3.h"
36 #include "TGeoManager.h"
37 
38 namespace sbn{
39 
40  struct CRTSipmGeo{
41  uint32_t channel;
42  double x;
43  double y;
44  double z;
45  std::string strip;
46  bool null;
47  };
48 
49  // CRT strip geometry struct contains dimensions and mother module
50  struct CRTStripGeo{
51  std::string name;
53  double minX;
54  double maxX;
55  double minY;
56  double maxY;
57  double minZ;
58  double maxZ;
60  double width;
61  std::string module;
62  std::pair<int, int> sipms;
63  bool null;
64  };
65 
66  // CRT module geometry struct contains dimensions, daughter strips and mother tagger
67  struct CRTModuleGeo{
68  std::string name;
69  int auxDetID;
70  double minX;
71  double maxX;
72  double minY;
73  double maxY;
74  double minZ;
75  double maxZ;
77  size_t planeID;
78  bool top;
79  std::string tagger;
80  std::map<std::string, CRTStripGeo> strips;
81  bool null;
82  };
83 
84  // CRT tagger geometry struct contains dimensions and daughter modules
85  struct CRTTaggerGeo{
86  std::string name;
87  double minX;
88  double maxX;
89  double minY;
90  double maxY;
91  double minZ;
92  double maxZ;
93  // change to ref?
94  std::map<std::string, CRTModuleGeo> modules;
95  bool null;
96  };
97 
98 
99  class CRTGeoAlg {
100  public:
101 
102  CRTGeoAlg(geo::GeometryCore const *geometry, geo::AuxDetGeometryCore const *auxdet_geometry);
103  CRTGeoAlg();
104 
105  ~CRTGeoAlg();
106 
107  // Return the volume enclosed by the whole CRT system
108  std::vector<double> CRTLimits() const;
109 
110  // Get the number of taggers in the geometry
111  size_t NumTaggers() const;
112 
113  // Get the total number of modules in the geometry
114  size_t NumModules() const;
115  // Get the number of modules in a tagger by name
116  size_t NumModules(std::string taggerName) const;
117  // Get the number of modules in a tagger by index
118  size_t NumModules(size_t tagger_i) const;
119 
120  // Get the total number of strips in the geometry
121  size_t NumStrips() const;
122  // Get the number of strips in module by name
123  size_t NumStrips(std::string moduleName) const;
124  // Get the number of strips in module by global index
125  size_t NumStrips(size_t module_i) const;
126  // Get the number of strips in module by tagger index and local module index
127  size_t NumStrips(size_t tagger_i, size_t module_i) const;
128 
129  // Get the tagger geometry object by name
130  CRTTaggerGeo GetTagger(std::string taggerName) const;
131  // Get the tagger geometry object by index
132  CRTTaggerGeo GetTagger(size_t tagger_i) const;
133 
134  // Get the module geometry object by name
135  CRTModuleGeo GetModule(std::string moduleName) const;
136  // Get the module geometry object by global index
137  CRTModuleGeo GetModule(size_t module_i) const;
138  // Get the module geometry object by tagger index and local module index
139  CRTModuleGeo GetModule(size_t tagger_i, size_t module_i) const;
140 
141  // Get the strip geometry object by name
142  CRTStripGeo GetStrip(std::string stripName) const;
143  // Get the strip geometry object by global index
144  CRTStripGeo GetStrip(size_t strip_i) const;
145  // Get the strip geometry object by global module index and local strip index
146  CRTStripGeo GetStrip(size_t module_i, size_t strip_i) const;
147  // Get the strip geometry object by tagger index, local module index and local strip index
148  CRTStripGeo GetStrip(size_t tagger_i, size_t module_i, size_t strip_i) const;
149 
150  // Get tagger name from strip or module name
151  std::string GetTaggerName(std::string name) const;
152 
153  // Get the name of the strip from the SiPM channel ID
154  std::string ChannelToStripName(size_t channel) const;
155 
156  // Get the world position of Sipm from the channel ID
157  geo::Point_t ChannelToSipmPosition(size_t channel) const;
158 
159  // Get the sipm channels on a strip
160  std::pair<int, int> GetStripSipmChannels(std::string stripName) const;
161 
162  // Recalculate strip limits including charge sharing
163  std::vector<double> StripLimitsWithChargeSharing(std::string stripName, double x, double ex);
164 
165  // Return the distance to a sipm in the plane of the sipms
166  double DistanceBetweenSipms(geo::Point_t position, size_t channel) const;
167  // Returns max distance from sipms in strip
168  double DistanceBetweenSipms(geo::Point_t position, std::string stripName) const;
169  // Return the distance along the strip (from sipm end)
170  double DistanceDownStrip(geo::Point_t position, std::string stripName) const;
171 
172  // Determine if a point is inside CRT volume
173  bool IsInsideCRT(TVector3 point);
174  bool IsInsideCRT(geo::Point_t point);
175  // Determine if a point is inside a tagger by name
176  bool IsInsideTagger(std::string taggerName, geo::Point_t point);
177  bool IsInsideTagger(const CRTTaggerGeo& tagger, geo::Point_t point);
178  // Determine if a point is inside a module by name
179  bool IsInsideModule(std::string moduleName, geo::Point_t point);
180  bool IsInsideModule(const CRTModuleGeo& module, geo::Point_t point);
181  // Determine if a point is inside a strip by name
182  bool IsInsideStrip(std::string stripName, geo::Point_t point);
183  bool IsInsideStrip(const CRTStripGeo& strip, geo::Point_t point);
184 
185  // Check if two modules overlap in 2D
186  bool CheckOverlap(const CRTModuleGeo& module1, const CRTModuleGeo& module2);
187  // Check is a module overlaps with a perpendicual module in the same tagger
188  bool HasOverlap(const CRTModuleGeo& module);
189  bool StripHasOverlap(std::string stripName);
190  std::vector<double> StripOverlap(std::string strip1Name, std::string strip2Name);
191 
192  // Find the average of the tagger entry and exit points of a true particle trajectory
193  geo::Point_t TaggerCrossingPoint(std::string taggerName, const simb::MCParticle& particle);
194  geo::Point_t TaggerCrossingPoint(const CRTTaggerGeo& tagger, const simb::MCParticle& particle);
195  bool CrossesTagger(const CRTTaggerGeo& tagger, const simb::MCParticle& particle);
196  // Find the average of the module entry and exit points of a true particle trajectory
197  geo::Point_t ModuleCrossingPoint(std::string moduleName, const simb::MCParticle& particle);
198  geo::Point_t ModuleCrossingPoint(const CRTModuleGeo& module, const simb::MCParticle& particle);
199  bool CrossesModule(const CRTModuleGeo& module, const simb::MCParticle& particle);
200  // Find the average of the strip entry and exit points of a true particle trajectory
201  geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle& particle);
202  geo::Point_t StripCrossingPoint(const CRTStripGeo& strip, const simb::MCParticle& particle);
203  bool CrossesStrip(const CRTStripGeo& strip, const simb::MCParticle& particle);
204 
205  // Work out which strips the true particle crosses
206  std::vector<std::string> CrossesStrips(const simb::MCParticle& particle);
207 
208  // Find the angle of true particle trajectory to tagger
209  double AngleToTagger(std::string taggerName, const simb::MCParticle& particle);
210 
211  // Check if a particle enters the CRT volume
212  bool EntersVolume(const simb::MCParticle& particle);
213  // Check if a particle crosses the CRT volume
214  bool CrossesVolume(const simb::MCParticle& particle);
215 
216  // Determine if a particle would be able to produce a hit in a tagger
217  bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle& particle);
218 
219 
220  private:
221 
222  std::map<std::string, CRTTaggerGeo> fTaggers;
223  std::map<std::string, CRTModuleGeo> fModules;
224  std::map<std::string, CRTStripGeo> fStrips;
225  std::map<int, CRTSipmGeo> fSipms;
226 
229 
230  };
231 
232 }
233 
234 #endif
235 
geo::Point_t ModuleCrossingPoint(std::string moduleName, const simb::MCParticle &particle)
bool CrossesStrip(const CRTStripGeo &strip, const simb::MCParticle &particle)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
std::map< std::string, CRTModuleGeo > fModules
geo::Point_t ChannelToSipmPosition(size_t channel) const
Utilities related to art service access.
bool StripHasOverlap(std::string stripName)
const geo::GeometryCore * geometry
process_name opflash particleana ie x
bool CrossesVolume(const simb::MCParticle &particle)
bool IsInsideModule(std::string moduleName, geo::Point_t point)
double AngleToTagger(std::string taggerName, const simb::MCParticle &particle)
bool HasOverlap(const CRTModuleGeo &module)
std::map< std::string, CRTTaggerGeo > fTaggers
std::string GetTaggerName(std::string name) const
bool IsInsideStrip(std::string stripName, geo::Point_t point)
Description of geometry of one set of auxiliary detectors.
std::map< std::string, CRTModuleGeo > modules
std::map< std::string, CRTStripGeo > fStrips
std::map< int, CRTSipmGeo > fSipms
geo::Point_t TaggerCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
Access the description of detector geometry.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
bool IsInsideTagger(std::string taggerName, geo::Point_t point)
art framework interface to geometry description for auxiliary detectors
CRTModuleGeo GetModule(std::string moduleName) const
std::string ChannelToStripName(size_t channel) const
std::vector< double > StripLimitsWithChargeSharing(std::string stripName, double x, double ex)
Description of geometry of one entire detector.
Definition of data types for geometry description.
bool EntersVolume(const simb::MCParticle &particle)
std::map< std::string, CRTStripGeo > strips
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const
bool CrossesTagger(const CRTTaggerGeo &tagger, const simb::MCParticle &particle)
geo::GeometryCore const * fGeometryService
CRTTaggerGeo GetTagger(std::string taggerName) const
std::pair< int, int > GetStripSipmChannels(std::string stripName) const
geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle &particle)
const geo::AuxDetGeometryCore * fAuxDetGeoCore
bool CheckOverlap(const CRTModuleGeo &module1, const CRTModuleGeo &module2)
then echo fcl name
CRTStripGeo GetStrip(std::string stripName) const
std::vector< double > StripOverlap(std::string strip1Name, std::string strip2Name)
bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
std::vector< double > CRTLimits() const
std::vector< std::string > CrossesStrips(const simb::MCParticle &particle)
bool CrossesModule(const CRTModuleGeo &module, const simb::MCParticle &particle)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
art framework interface to geometry description