LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
AuxDetSensitiveGeo.h
Go to the documentation of this file.
1 
7 #ifndef LARCOREALG_GEOMETRY_AUXDETSENSITIVEGEO_H
8 #define LARCOREALG_GEOMETRY_AUXDETSENSITIVEGEO_H
9 
10 // LArSoft libraries
16 
17 // ROOT libraries
18 #include "Math/GenVector/DisplacementVector3D.h"
19 #include "Math/GenVector/PositionVector3D.h"
20 #include "Math/GenVector/Transform3D.h"
21 
22 // C/C++ standard libraries
23 #include <string>
24 #include <type_traits>
25 
26 class TGeoNode;
27 class TGeoVolume;
28 
29 namespace geo {
30 
33  public:
35 
53 
56 
59 
61 
62  AuxDetSensitiveGeo(TGeoNode const* node, TransformationMatrix&& trans);
63 
70  Point_t GetCenter(double localz = 0.0) const;
71 
73  Vector_t GetNormalVector() const;
74 
75  //box geometry
76  double Length() const { return fLength; }
77  double HalfLength() const { return Length() / 2.0; }
78  double HalfWidth1() const { return fHalfWidth1; }
79  double HalfWidth2() const { return fHalfWidth2; }
80  double HalfCenterWidth() const { return (HalfWidth1() + HalfWidth2()) / 2.0; }
81  double HalfHeight() const { return fHalfHeight; }
82  const TGeoVolume* TotalVolume() const { return fTotalVolume; }
83 
85  Length_t DistanceToPoint(Point_t const& point) const { return (point - GetCenter()).R(); }
87  Length_t DistanceToPoint(double const* point) const;
89 
92 
94  Point_t toWorldCoords(LocalPoint_t const& local) const { return fTrans.toWorldCoords(local); }
95 
97  Vector_t toWorldCoords(LocalVector_t const& local) const { return fTrans.toWorldCoords(local); }
98 
100  LocalPoint_t toLocalCoords(Point_t const& world) const { return fTrans.toLocalCoords(world); }
101 
103  LocalVector_t toLocalCoords(Vector_t const& world) const { return fTrans.toLocalCoords(world); }
104 
106 
126  template <typename Stream>
127  void PrintAuxDetInfo(Stream&& out, std::string indent = "", unsigned int verbosity = 0) const;
128 
136  std::string AuxDetInfo(std::string indent = "", unsigned int verbosity = 1) const;
137 
139  static constexpr unsigned int MaxVerbosity = 2;
140 
141  private:
142  using LocalTransformation_t =
144 
146  const TGeoVolume* fTotalVolume;
147  double fLength;
148  double fHalfWidth1;
149  double fHalfWidth2;
150  double fHalfHeight;
151 
153  void InitShapeSize();
154 
155  }; // class AuxDetSensitiveGeo
156 
157  static_assert(std::is_move_assignable_v<AuxDetSensitiveGeo>);
158  static_assert(std::is_move_constructible_v<AuxDetSensitiveGeo>);
159 
160 } // namespace geo
161 
162 //------------------------------------------------------------------------------
163 //--- template implementation
164 //---
165 template <typename Stream>
167  std::string indent /* = "" */,
168  unsigned int verbosity /* = 0 */
169 ) const
170 {
171 
172  //----------------------------------------------------------------------------
173  out << "centered at " << GetCenter() << " cm";
174 
175  if (verbosity-- <= 0) return; // 0
176 
177  //----------------------------------------------------------------------------
179  out << ", size ( " << (2.0 * HalfWidth1());
180  if (coordIs.nonEqual(HalfWidth1(), HalfWidth2())) out << "/" << (2.0 * HalfWidth2());
181  out << " x " << (2.0 * HalfHeight()) << " x " << Length() << " ) cm";
182 
183  if (verbosity-- <= 0) return; // 1
184 
185  //----------------------------------------------------------------------------
186  out << ", normal facing " << GetNormalVector();
187 
188  // if (verbosity-- <= 0) return; // 2
189 
190  //----------------------------------------------------------------------------
191 
192 } // geo::AuxDetSensitiveGeo::PrintAuxDetInfo()
193 
194 //------------------------------------------------------------------------------
195 
196 #endif // LARCOREALG_GEOMETRY_AUXDETSENSITIVEGEO_H
double fLength
length of volume, along z direction in local
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
double HalfCenterWidth() const
Provides simple real number checks.
Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
Point3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
double fHalfHeight
half height of volume
Point_t GetCenter(double localz=0.0) const
Returns the geometric center of the sensitive volume.
Class for approximate comparisons.
AuxDetSensitiveGeo(TGeoNode const *node, TransformationMatrix &&trans)
LocalVector_t toLocalCoords(Vector_t const &world) const
Transform direction vector from world to local.
void InitShapeSize()
Extracts the size of the detector from the geometry information.
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
LocalPoint_t toLocalCoords(Point_t const &world) const
Transform point from world frame to local auxiliary detector frame.
Local-to-world transformations with LArSoft geometry vectors.
Definitions of geometry vector data types.
std::string indent(std::size_t const i)
const TGeoVolume * TotalVolume() const
Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this auxiliary sensitive detector.
Length_t DistanceToPoint(Point_t const &point) const
Returns the distance of point from the center of the detector.
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
std::string AuxDetInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with auxiliary sensitive detector information.
Selection of the type of transformation matrix used in geometry.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintAuxDetInfo().
Vector3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML auxiliary detector frame.
Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:88
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
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.
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Float_t e
Definition: plot.C:35
ROOT libraries.
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...