LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
AuxDetGeo.h
Go to the documentation of this file.
1 
9 #ifndef LARCOREALG_GEOMETRY_AUXDETGEO_H
10 #define LARCOREALG_GEOMETRY_AUXDETGEO_H
11 
12 // LArSoft libraries
17 
18 // ROOT libraries
19 #include "TGeoVolume.h"
20 #include "TGeoMatrix.h" // TGeoHMatrix
21 
22 // C/C++ libraries
23 #include <vector>
24 
25 class TGeoNode;
26 
27 
28 namespace geo {
29 
31  class AuxDetGeo {
32  public:
34 
48  struct AuxDetGeoCoordinatesTag {};
51 
54 
57 
59 
60  AuxDetGeo(std::vector<const TGeoNode*>& path,
61  int depth);
62 
63  ~AuxDetGeo();
64 
71  void GetCenter(double* xyz, double localz=0.0) const;
72 
79  geo::Point_t GetCenter(double localz = 0.0) const;
80 
83 
85  void GetNormalVector(double* xyzDir) const;
86 
87 
90  double Length() const { return fLength; }
91  double HalfWidth1() const { return fHalfWidth1; }
92  double HalfWidth2() const { return fHalfWidth2; }
93  double HalfHeight() const { return fHalfHeight; }
94  const TGeoVolume* TotalVolume() const { return fTotalVolume; }
96 
98  geo::Length_t DistanceToPoint(geo::Point_t const& point) const
100  { return (point - GetCenter()).R(); }
101  geo::Length_t DistanceToPoint(double const* point) const;
103 
106 
108  void LocalToWorld(const double* auxdet, double* world) const
109  { fTrans.LocalToWorld(auxdet, world); }
110 
113  { return fTrans.toWorldCoords(local); }
114 
116  void LocalToWorldVect(const double* auxdet, double* world) const
117  { fTrans.LocalToWorldVect(auxdet, world); }
118 
121  { return fTrans.toWorldCoords(local); }
122 
124  void WorldToLocal(const double* world, double* auxdet) const
125  { fTrans.WorldToLocal(world, auxdet); }
126 
129  { return fTrans.toLocalCoords(world); }
130 
132  void WorldToLocalVect(const double* world, double* auxdet) const
133  { fTrans.WorldToLocalVect(world, auxdet); }
134 
137  { return fTrans.toLocalCoords(world); }
138 
140 
141 
142  std::string Name() const { return fTotalVolume->GetName(); }
143 
146 
148  std::size_t FindSensitiveVolume(geo::Point_t const& point) const;
150  std::size_t FindSensitiveVolume(double const worldLoc[3]) const;
152 
154  (geo::Point_t const& point, size_t& sv) const;
157  (double const worldLoc[3], size_t& sv) const;
159  AuxDetSensitiveGeo const& SensitiveVolume(size_t sv) const { return *fSensitive[sv]; }
160  size_t NSensitiveVolume() const { return fSensitive.size(); }
161 
163 
164  void SortSubVolumes(geo::GeoObjectSorter const& sorter);
165 
166 
188  template <typename Stream>
189  void PrintAuxDetInfo
190  (Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
191 
193  static constexpr unsigned int MaxVerbosity = 4;
194 
195 
196  private:
197 
200 
201 
202  void FindAuxDetSensitive(std::vector<const TGeoNode*>& path,
203  unsigned int depth);
204  void MakeAuxDetSensitive(std::vector<const TGeoNode*>& path,
205  int depth);
206 
207  const TGeoVolume* fTotalVolume;
209  double fLength;
210  double fHalfWidth1;
211  double fHalfWidth2;
212  double fHalfHeight;
213  std::vector<AuxDetSensitiveGeo*> fSensitive;
214 
216  void InitShapeSize();
217  };
218 }
219 
220 
221 //------------------------------------------------------------------------------
222 //--- template implementation
223 //---
224 template <typename Stream>
226  Stream&& out,
227  std::string indent /* = "" */,
228  unsigned int verbosity /* = 1 */
229 ) const {
230 
231  //----------------------------------------------------------------------------
232  out << "\"" << Name() << "\"";
233 
234  if (verbosity-- <= 0) return; // 0
235 
236  //----------------------------------------------------------------------------
237  out << " centered at " << GetCenter() << " cm";
238 
239  if (verbosity-- <= 0) return; // 1
240 
241  //----------------------------------------------------------------------------
243  out << ", size ( " << (2.0 * HalfWidth1());
244  if (coordIs.nonEqual(HalfWidth1(), HalfWidth2()))
245  out << "/" << (2.0 * HalfWidth2());
246  out << " x " << (2.0 * HalfHeight()) << " x " << Length() << " ) cm";
247 
248  if (verbosity-- <= 0) return; // 2
249 
250  //----------------------------------------------------------------------------
251  out << "\n" << indent
252  << "with ";
253  switch (NSensitiveVolume()) {
254  case 0: out << "no sensitive volume"; break;
255  case 1: out << "1 sensitive volume"; break;
256  default: out << NSensitiveVolume() << " sensitive volumes"; break;
257  } // switch
258 
259  if (verbosity-- <= 0) return; // 3
260 
261  //----------------------------------------------------------------------------
262  out << ", normal facing " << GetNormalVector();
263 
264 // if (verbosity-- <= 0) return; // 4
265 
266  //----------------------------------------------------------------------------
267 
268 } // geo::AuxDetGeo::PrintAuxDetInfo()
269 
270 
271 //------------------------------------------------------------------------------
272 
273 #endif // LARCOREALG_GEOMETRY_AUXDETGEO_H
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:167
void FindAuxDetSensitive(std::vector< const TGeoNode * > &path, unsigned int depth)
Definition: AuxDetGeo.cxx:62
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local auxiliary detector frame.
Definition: AuxDetGeo.h:128
void LocalToWorld(const double *auxdet, double *world) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:108
constexpr bool nonEqual(Value_t a, Value_t b) const
Returns whether a and b are farther than the threshold.
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Definition: geo_vectors.h:140
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:159
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:211
geo::Length_t DistanceToPoint(geo::Point_t const &point) const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:99
Provides simple real number checks.
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:208
void WorldToLocal(const double *world, double *auxdet) const
Transform point from world frame to local auxiliary detector frame.
Definition: AuxDetGeo.h:124
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Definition: AuxDetGeo.h:136
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:210
void WorldToLocalVect(const double *world, double *auxdet) const
Transform direction vector from world to local.
Definition: AuxDetGeo.h:132
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Definition: AuxDetGeo.cxx:178
void LocalToWorld(double const *local, double *world) const
Transforms a point from local frame to world frame.
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: AuxDetGeo.h:120
void LocalToWorldVect(double const *local, double *world) const
Transforms a vector from local frame to world frame.
geo::Point3DBase_t< AuxDetGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:53
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:209
Class for approximate comparisons.
AuxDetSensitiveGeo const & PositionToSensitiveVolume(geo::Point_t const &point, size_t &sv) const
Definition: AuxDetGeo.cxx:162
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:213
Interface to algorithm class for sorting geo::XXXGeo objects.
double HalfWidth2() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:92
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:207
void LocalToWorldVect(const double *auxdet, double *world) const
Transform direction vector from local to world.
Definition: AuxDetGeo.h:116
void MakeAuxDetSensitive(std::vector< const TGeoNode * > &path, int depth)
Definition: AuxDetGeo.cxx:87
geo::Vector3DBase_t< AuxDetGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:56
std::size_t FindSensitiveVolume(geo::Point_t const &point) const
Definition: AuxDetGeo.cxx:126
double HalfHeight() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:93
std::string indent(std::size_t const i)
AuxDetGeo(std::vector< const TGeoNode * > &path, int depth)
Definition: AuxDetGeo.cxx:28
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:160
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
Definition: AuxDetGeo.cxx:107
Definition of data types for geometry description.
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
double Length() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:90
std::string Name() const
Definition: AuxDetGeo.h:142
const TGeoVolume * TotalVolume() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:94
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
Definition: AuxDetGeo.h:193
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:95
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:90
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.
double HalfWidth1() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:91
Float_t e
Definition: plot.C:34
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:187
Namespace collecting geometry-related classes utilities.
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:212
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
void InitShapeSize()
Extracts the size of the detector from the geometry information.
Definition: AuxDetGeo.cxx:186
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this auxiliary detector.
Definition: AuxDetGeo.h:225
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:112
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.
Definition: AuxDetGeo.cxx:97