LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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
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 
35  class GeoObjectSorter;
36 
38  class AuxDetGeo {
39  public:
41  using AuxDetSensitiveList_t = std::vector<geo::AuxDetSensitiveGeo>;
42 
44 
58  struct AuxDetGeoCoordinatesTag {};
61 
64 
67 
69 
70  AuxDetGeo(TGeoNode const& node,
72  AuxDetSensitiveList_t&& sensitive);
73 
80  geo::Point_t GetCenter(double localz = 0.0) const;
81 
84 
87  double Length() const { return fLength; }
88  double HalfWidth1() const { return fHalfWidth1; }
89  double HalfWidth2() const { return fHalfWidth2; }
90  double HalfHeight() const { return fHalfHeight; }
91  const TGeoVolume* TotalVolume() const { return fTotalVolume; }
93 
95  geo::Length_t DistanceToPoint(geo::Point_t const& point) const
97  {
98  return (point - GetCenter()).R();
99  }
101 
104 
107  {
108  return fTrans.toWorldCoords(local);
109  }
110 
113  {
114  return fTrans.toWorldCoords(local);
115  }
116 
119  {
120  return fTrans.toLocalCoords(world);
121  }
122 
125  {
126  return fTrans.toLocalCoords(world);
127  }
128 
130 
131  std::string Name() const { return fTotalVolume->GetName(); }
132 
135 
137  std::size_t FindSensitiveVolume(geo::Point_t const& point) const;
139 
141  size_t& sv) const;
143  AuxDetSensitiveGeo const& SensitiveVolume(size_t sv) const { return fSensitive[sv]; }
144  size_t NSensitiveVolume() const { return fSensitive.size(); }
145 
147 
148  void SortSubVolumes(geo::GeoObjectSorter const& sorter);
149 
171  template <typename Stream>
172  void PrintAuxDetInfo(Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
173 
181  std::string AuxDetInfo(std::string indent = "", unsigned int verbosity = 1) const;
182 
184  static constexpr unsigned int MaxVerbosity = 4;
185 
186  private:
187  using LocalTransformation_t =
189 
190  const TGeoVolume* fTotalVolume;
192  double fLength;
193  double fHalfWidth1;
194  double fHalfWidth2;
195  double fHalfHeight;
196  std::vector<AuxDetSensitiveGeo> fSensitive;
197 
199  void InitShapeSize();
200  }; // class AuxDetGeo
201 
202  static_assert(std::is_move_assignable_v<geo::AuxDetGeo>);
203  static_assert(std::is_move_constructible_v<geo::AuxDetGeo>);
204 
205 }
206 
207 //------------------------------------------------------------------------------
208 //--- template implementation
209 //---
210 template <typename Stream>
212  std::string indent /* = "" */,
213  unsigned int verbosity /* = 1 */
214 ) const
215 {
216  //----------------------------------------------------------------------------
217  out << "\"" << Name() << "\"";
218 
219  if (verbosity-- <= 0) return; // 0
220 
221  //----------------------------------------------------------------------------
222  out << " centered at " << GetCenter() << " cm";
223 
224  if (verbosity-- <= 0) return; // 1
225 
226  //----------------------------------------------------------------------------
228  out << ", size ( " << (2.0 * HalfWidth1());
229  if (coordIs.nonEqual(HalfWidth1(), HalfWidth2())) out << "/" << (2.0 * HalfWidth2());
230  out << " x " << (2.0 * HalfHeight()) << " x " << Length() << " ) cm";
231 
232  if (verbosity-- <= 0) return; // 2
233 
234  //----------------------------------------------------------------------------
235  out << "\n" << indent << "with ";
236  switch (NSensitiveVolume()) {
237  case 0: out << "no sensitive volume"; break;
238  case 1: out << "1 sensitive volume"; break;
239  default: out << NSensitiveVolume() << " sensitive volumes"; break;
240  } // switch
241 
242  if (verbosity-- <= 0) return; // 3
243 
244  //----------------------------------------------------------------------------
245  out << ", normal facing " << GetNormalVector();
246 
247 } // geo::AuxDetGeo::PrintAuxDetInfo()
248 
249 //------------------------------------------------------------------------------
250 
251 #endif // LARCOREALG_GEOMETRY_AUXDETGEO_H
std::string AuxDetInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with auxiliary detector information.
Definition: AuxDetGeo.cxx:109
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local auxiliary detector frame.
Definition: AuxDetGeo.h:118
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:143
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:194
geo::Length_t DistanceToPoint(geo::Point_t const &point) const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:96
Provides simple real number checks.
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:191
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:124
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:193
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Definition: AuxDetGeo.cxx:103
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: AuxDetGeo.h:112
geo::Point3DBase_t< AuxDetGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:63
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:192
Class for approximate comparisons.
AuxDetSensitiveGeo const & PositionToSensitiveVolume(geo::Point_t const &point, size_t &sv) const
Definition: AuxDetGeo.cxx:91
double HalfWidth2() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:89
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:190
geo::Vector3DBase_t< AuxDetGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:66
std::size_t FindSensitiveVolume(geo::Point_t const &point) const
Definition: AuxDetGeo.cxx:66
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:90
Definitions of geometry vector data types.
std::string indent(std::size_t const i)
size_t NSensitiveVolume() const
Definition: AuxDetGeo.h:144
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
Definition: AuxDetGeo.cxx:60
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:87
std::string Name() const
Definition: AuxDetGeo.h:131
const TGeoVolume * TotalVolume() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:91
AuxDetGeo(TGeoNode const &node, geo::TransformationMatrix &&trans, AuxDetSensitiveList_t &&sensitive)
Definition: AuxDetGeo.cxx:32
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
Definition: AuxDetGeo.h:184
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:88
Float_t e
Definition: plot.C:35
geo::Point_t GetCenter(double localz=0.0) const
Returns the geometric center of the sensitive volume.
Definition: AuxDetGeo.cxx:52
std::vector< geo::AuxDetSensitiveGeo > AuxDetSensitiveList_t
Type of list of sensitive volumes.
Definition: AuxDetGeo.h:41
Namespace collecting geometry-related classes utilities.
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:195
void InitShapeSize()
Extracts the size of the detector from the geometry information.
Definition: AuxDetGeo.cxx:118
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this auxiliary detector.
Definition: AuxDetGeo.h:211
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:106
Specialization of local-to-world transformations for ROOT GenVector.
std::vector< AuxDetSensitiveGeo > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:196