LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
AuxDetGeo.h
Go to the documentation of this file.
1 
8 #ifndef LARCOREALG_GEOMETRY_AUXDETGEO_H
9 #define LARCOREALG_GEOMETRY_AUXDETGEO_H
10 
11 // LArSoft libraries
19 
20 // ROOT libraries
21 #include "Math/GenVector/DisplacementVector3D.h"
22 #include "Math/GenVector/PositionVector3D.h"
23 #include "TGeoVolume.h"
24 
25 // C/C++ libraries
26 #include <stddef.h>
27 #include <string>
28 #include <type_traits>
29 #include <vector>
30 
31 class TGeoNode;
32 
33 namespace geo {
34 
36  class AuxDetGeo {
37  public:
39  using AuxDetSensitiveList_t = std::vector<AuxDetSensitiveGeo>;
40 
42 
55  struct AuxDetGeoCoordinatesTag {};
57 
60 
63 
65 
66  AuxDetGeo(TGeoNode const* node,
67  TransformationMatrix&& trans,
68  AuxDetSensitiveList_t&& sensitive);
69 
76  Point_t GetCenter(double localz = 0.0) const;
77 
79  Vector_t GetNormalVector() const;
80 
83  double Length() const { return fLength; }
84  double HalfWidth1() const { return fHalfWidth1; }
85  double HalfWidth2() const { return fHalfWidth2; }
86  double HalfHeight() const { return fHalfHeight; }
87  const TGeoVolume* TotalVolume() const { return fTotalVolume; }
89 
91  Length_t DistanceToPoint(Point_t const& point) const { return (point - GetCenter()).R(); }
94 
97 
99  Point_t toWorldCoords(LocalPoint_t const& local) const { return fTrans.toWorldCoords(local); }
100 
102  Vector_t toWorldCoords(LocalVector_t const& local) const { return fTrans.toWorldCoords(local); }
103 
105  LocalPoint_t toLocalCoords(Point_t const& world) const { return fTrans.toLocalCoords(world); }
106 
108  LocalVector_t toLocalCoords(Vector_t const& world) const { return fTrans.toLocalCoords(world); }
109 
111 
112  std::string Name() const { return fTotalVolume->GetName(); }
113 
116 
118  std::size_t FindSensitiveVolume(Point_t const& point) const;
120 
121  AuxDetSensitiveGeo const& PositionToSensitiveVolume(Point_t const& point, size_t& sv) const;
123  AuxDetSensitiveGeo const& SensitiveVolume(size_t sv) const { return fSensitive[sv]; }
124  size_t NSensitiveVolume() const { return fSensitive.size(); }
125 
127 
129 
150  template <typename Stream>
151  void PrintAuxDetInfo(Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
152 
159  std::string AuxDetInfo(std::string indent = "", unsigned int verbosity = 1) const;
160 
162  static constexpr unsigned int MaxVerbosity = 4;
163 
164  private:
165  using LocalTransformation_t =
167 
168  TGeoVolume const* fTotalVolume;
170  double fLength;
171  double fHalfWidth1;
172  double fHalfWidth2;
173  double fHalfHeight;
174  std::vector<AuxDetSensitiveGeo> fSensitive;
175 
177  void InitShapeSize();
178  }; // class AuxDetGeo
179 
180  static_assert(std::is_move_assignable_v<AuxDetGeo>);
181  static_assert(std::is_move_constructible_v<AuxDetGeo>);
182 
183 }
184 
185 //------------------------------------------------------------------------------
186 //--- template implementation
187 //---
188 template <typename Stream>
190  std::string indent /* = "" */,
191  unsigned int verbosity /* = 1 */
192 ) const
193 {
194  //----------------------------------------------------------------------------
195  out << "\"" << Name() << "\"";
196 
197  if (verbosity-- <= 0) return; // 0
198 
199  //----------------------------------------------------------------------------
200  out << " centered at " << GetCenter() << " cm";
201 
202  if (verbosity-- <= 0) return; // 1
203 
204  //----------------------------------------------------------------------------
206  out << ", size ( " << (2.0 * HalfWidth1());
207  if (coordIs.nonEqual(HalfWidth1(), HalfWidth2())) out << "/" << (2.0 * HalfWidth2());
208  out << " x " << (2.0 * HalfHeight()) << " x " << Length() << " ) cm";
209 
210  if (verbosity-- <= 0) return; // 2
211 
212  //----------------------------------------------------------------------------
213  out << "\n" << indent << "with ";
214  switch (NSensitiveVolume()) {
215  case 0: out << "no sensitive volume"; break;
216  case 1: out << "1 sensitive volume"; break;
217  default: out << NSensitiveVolume() << " sensitive volumes"; break;
218  } // switch
219 
220  if (verbosity-- <= 0) return; // 3
221 
222  //----------------------------------------------------------------------------
223  out << ", normal facing " << GetNormalVector();
224 
225 } // geo::AuxDetGeo::PrintAuxDetInfo()
226 
227 //------------------------------------------------------------------------------
228 
229 #endif // LARCOREALG_GEOMETRY_AUXDETGEO_H
Point3DBase_t< AuxDetGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:59
std::string AuxDetInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with auxiliary detector information.
Definition: AuxDetGeo.cxx:108
AuxDetGeo(TGeoNode const *node, TransformationMatrix &&trans, AuxDetSensitiveList_t &&sensitive)
Definition: AuxDetGeo.cxx:32
Vector3DBase_t< AuxDetGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:62
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:133
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
Encapsulate the geometry of the sensitive portion of an auxiliary detector .
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:123
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:172
Provides simple real number checks.
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:169
std::vector< AuxDetSensitiveGeo > AuxDetSensitiveList_t
Type of list of sensitive volumes.
Definition: AuxDetGeo.h:39
Length_t DistanceToPoint(Point_t const &point) const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:92
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
AuxDetSensitiveGeo const & PositionToSensitiveVolume(Point_t const &point, size_t &sv) const
Definition: AuxDetGeo.cxx:90
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:171
Tag for vectors in the "local" GDML coordinate frame of the auxiliary detector.
Definition: AuxDetGeo.h:56
Point_t GetCenter(double localz=0.0) const
Returns the geometric center of the sensitive volume.
Definition: AuxDetGeo.cxx:51
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:170
TGeoVolume const * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:168
Class for approximate comparisons.
double HalfWidth2() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:85
Local-to-world transformations with LArSoft geometry vectors.
double HalfHeight() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:86
LocalPoint_t toLocalCoords(Point_t const &world) const
Transform point from world frame to local auxiliary detector frame.
Definition: AuxDetGeo.h:105
Definitions of geometry vector data types.
std::string indent(std::size_t const i)
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:124
Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
Definition: AuxDetGeo.cxx:59
Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:99
LocalVector_t toLocalCoords(Vector_t const &world) const
Transform direction vector from world to local.
Definition: AuxDetGeo.h:108
std::size_t FindSensitiveVolume(Point_t const &point) const
Definition: AuxDetGeo.cxx:65
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:180
Selection of the type of transformation matrix used in geometry.
double Length() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:83
std::string Name() const
Definition: AuxDetGeo.h:112
const TGeoVolume * TotalVolume() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:87
void SortSubVolumes(AuxDetGeoObjectSorter &sorter)
Definition: AuxDetGeo.cxx:102
Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: AuxDetGeo.h:102
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
Definition: AuxDetGeo.h:162
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:88
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:83
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:84
Float_t e
Definition: plot.C:35
ROOT libraries.
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:173
void InitShapeSize()
Extracts the size of the detector from the geometry information.
Definition: AuxDetGeo.cxx:117
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this auxiliary detector.
Definition: AuxDetGeo.h:189
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
Specialization of local-to-world transformations for ROOT GenVector.This is a header-only library...
std::vector< AuxDetSensitiveGeo > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:174