All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbndcode/sbndcode/Geometry/GeometryWrappers/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 sbnd{
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 
116  // Get the total number of strips in the geometry
117  size_t NumStrips() const;
118 
119  // Get the tagger geometry object by name
120  CRTTaggerGeo GetTagger(std::string taggerName) const;
121  // Get the tagger geometry object by index
122  CRTTaggerGeo GetTagger(size_t tagger_i) const;
123 
124  // Get the module geometry object by name
125  CRTModuleGeo GetModule(std::string moduleName) const;
126  // Get the module geometry object by global index
127  CRTModuleGeo GetModule(size_t module_i) const;
128 
129  // Get the strip geometry object by name
130  CRTStripGeo GetStrip(std::string stripName) const;
131  // Get the strip geometry object by global index
132  CRTStripGeo GetStrip(size_t strip_i) const;
133 
134  // Get tagger name from strip or module name
135  std::string GetTaggerName(std::string name) const;
136 
137  // Get the name of the strip from the SiPM channel ID
138  std::string ChannelToStripName(size_t channel) const;
139 
140  // Get the world position of Sipm from the channel ID
141  geo::Point_t ChannelToSipmPosition(size_t channel) const;
142 
143  // Get the sipm channels on a strip
144  std::pair<int, int> GetStripSipmChannels(std::string stripName) const;
145 
146  // Recalculate strip limits including charge sharing
147  std::vector<double> StripLimitsWithChargeSharing(std::string stripName, double x, double ex);
148 
149  // Return the distance to a sipm in the plane of the sipms
150  double DistanceBetweenSipms(geo::Point_t position, size_t channel) const;
151  // Returns max distance from sipms in strip
152  double DistanceBetweenSipms(geo::Point_t position, std::string stripName) const;
153  // Return the distance along the strip (from sipm end)
154  double DistanceDownStrip(geo::Point_t position, std::string stripName) const;
155 
156  // Determine if a point is inside CRT volume
157  bool IsInsideCRT(TVector3 point);
158  bool IsInsideCRT(geo::Point_t point);
159  // Determine if a point is inside a tagger by name
160  bool IsInsideTagger(const CRTTaggerGeo& tagger, geo::Point_t point);
161  // Determine if a point is inside a module by name
162  bool IsInsideModule(const CRTModuleGeo& module, geo::Point_t point);
163  // Determine if a point is inside a strip by name
164  bool IsInsideStrip(const CRTStripGeo& strip, geo::Point_t point);
165 
166  // Check if two modules overlap in 2D
167  bool CheckOverlap(const CRTModuleGeo& module1, const CRTModuleGeo& module2);
168  // Check is a module overlaps with a perpendicual module in the same tagger
169  bool HasOverlap(const CRTModuleGeo& module);
170  bool StripHasOverlap(std::string stripName);
171 
172  // Find the average of the tagger entry and exit points of a true particle trajectory
173  geo::Point_t TaggerCrossingPoint(std::string taggerName, const simb::MCParticle& particle);
174  geo::Point_t TaggerCrossingPoint(const CRTTaggerGeo& tagger, const simb::MCParticle& particle);
175  bool CrossesTagger(const CRTTaggerGeo& tagger, const simb::MCParticle& particle);
176  // Find the average of the module entry and exit points of a true particle trajectory
177  geo::Point_t ModuleCrossingPoint(std::string moduleName, const simb::MCParticle& particle);
178  geo::Point_t ModuleCrossingPoint(const CRTModuleGeo& module, const simb::MCParticle& particle);
179  bool CrossesModule(const CRTModuleGeo& module, const simb::MCParticle& particle);
180  // Find the average of the strip entry and exit points of a true particle trajectory
181  geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle& particle);
182  geo::Point_t StripCrossingPoint(const CRTStripGeo& strip, const simb::MCParticle& particle);
183  bool CrossesStrip(const CRTStripGeo& strip, const simb::MCParticle& particle);
184 
185  // Work out which strips the true particle crosses
186  std::vector<std::string> CrossesStrips(const simb::MCParticle& particle);
187 
188  // Find the angle of true particle trajectory to tagger
189  double AngleToTagger(std::string taggerName, const simb::MCParticle& particle);
190 
191  // Check if a particle enters the CRT volume
192  bool EntersVolume(const simb::MCParticle& particle);
193  // Check if a particle crosses the CRT volume
194  bool CrossesVolume(const simb::MCParticle& particle);
195 
196  // Determine if a particle would be able to produce a hit in a tagger
197  bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle& particle);
198 
199 
200  private:
201 
202  std::map<std::string, CRTTaggerGeo> fTaggers;
203  std::map<std::string, CRTModuleGeo> fModules;
204  std::map<std::string, CRTStripGeo> fStrips;
205  std::map<int, CRTSipmGeo> fSipms;
206 
209 
210  };
211 
212 }
213 
214 #endif
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
bool IsInsideModule(const CRTModuleGeo &module, geo::Point_t point)
Utilities related to art service access.
const geo::GeometryCore * geometry
process_name opflash particleana ie x
std::map< std::string, CRTModuleGeo > modules
CRTTaggerGeo GetTagger(std::string taggerName) const
bool IsInsideStrip(const CRTStripGeo &strip, geo::Point_t point)
std::map< std::string, CRTModuleGeo > fModules
geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle &particle)
bool IsInsideTagger(const CRTTaggerGeo &tagger, geo::Point_t point)
Description of geometry of one set of auxiliary detectors.
CRTModuleGeo GetModule(std::string moduleName) const
Access the description of detector geometry.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::map< std::string, CRTTaggerGeo > fTaggers
std::string ChannelToStripName(size_t channel) const
art framework interface to geometry description for auxiliary detectors
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
CRTStripGeo GetStrip(std::string stripName) const
std::pair< int, int > GetStripSipmChannels(std::string stripName) const
Description of geometry of one entire detector.
bool CrossesTagger(const CRTTaggerGeo &tagger, const simb::MCParticle &particle)
Definition of data types for geometry description.
std::string GetTaggerName(std::string name) const
std::vector< double > StripLimitsWithChargeSharing(std::string stripName, double x, double ex)
bool CheckOverlap(const CRTModuleGeo &module1, const CRTModuleGeo &module2)
std::vector< std::string > CrossesStrips(const simb::MCParticle &particle)
double AngleToTagger(std::string taggerName, const simb::MCParticle &particle)
geo::Point_t TaggerCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
geo::Point_t ModuleCrossingPoint(std::string moduleName, const simb::MCParticle &particle)
bool EntersVolume(const simb::MCParticle &particle)
stream1 can override from command line with o or output services user sbnd
then echo fcl name
std::map< std::string, CRTStripGeo > fStrips
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
geo::Point_t ChannelToSipmPosition(size_t channel) const
bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
bool CrossesStrip(const CRTStripGeo &strip, const simb::MCParticle &particle)
art framework interface to geometry description
bool CrossesVolume(const simb::MCParticle &particle)
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const