LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AuxDetSensitiveGeo.h
Go to the documentation of this file.
1 
9 #ifndef LARCOREALG_GEOMETRY_AUXDETSENSITIVEGEO_H
10 #define LARCOREALG_GEOMETRY_AUXDETSENSITIVEGEO_H
11 
12 // LArSoft libraries
18 
19 // ROOT libraries
20 #include "Math/GenVector/DisplacementVector3D.h"
21 #include "Math/GenVector/PositionVector3D.h"
22 #include "Math/GenVector/Transform3D.h"
23 
24 // C/C++ standard libraries
25 #include <string>
26 #include <type_traits>
27 
28 class TGeoNode;
29 class TGeoVolume;
30 
31 namespace geo {
32 
35  public:
37 
55 
58 
61 
63 
64  AuxDetSensitiveGeo(TGeoNode const& node, geo::TransformationMatrix&& trans);
65 
72  geo::Point_t GetCenter(double localz = 0.0) const;
73 
76 
77  //box geometry
78  double Length() const { return fLength; }
79  double HalfLength() const { return Length() / 2.0; }
80  double HalfWidth1() const { return fHalfWidth1; }
81  double HalfWidth2() const { return fHalfWidth2; }
82  double HalfCenterWidth() const { return (HalfWidth1() + HalfWidth2()) / 2.0; }
83  double HalfHeight() const { return fHalfHeight; }
84  const TGeoVolume* TotalVolume() const { return fTotalVolume; }
85 
87  geo::Length_t DistanceToPoint(geo::Point_t const& point) const
89  {
90  return (point - GetCenter()).R();
91  }
92  geo::Length_t DistanceToPoint(double const* point) const;
94 
97 
100  {
101  return fTrans.toWorldCoords(local);
102  }
103 
106  {
107  return fTrans.toWorldCoords(local);
108  }
109 
112  {
113  return fTrans.toLocalCoords(world);
114  }
115 
118  {
119  return fTrans.toLocalCoords(world);
120  }
121 
123 
143  template <typename Stream>
144  void PrintAuxDetInfo(Stream&& out, std::string indent = "", unsigned int verbosity = 0) const;
145 
153  std::string AuxDetInfo(std::string indent = "", unsigned int verbosity = 1) const;
154 
156  static constexpr unsigned int MaxVerbosity = 2;
157 
158  private:
159  using LocalTransformation_t =
161 
163  const TGeoVolume* fTotalVolume;
164  double fLength;
165  double fHalfWidth1;
166  double fHalfWidth2;
167  double fHalfHeight;
168 
170  void InitShapeSize();
171 
172  }; // class AuxDetSensitiveGeo
173 
174  static_assert(std::is_move_assignable_v<geo::AuxDetSensitiveGeo>);
175  static_assert(std::is_move_constructible_v<geo::AuxDetSensitiveGeo>);
176 
177 } // namespace geo
178 
179 //------------------------------------------------------------------------------
180 //--- template implementation
181 //---
182 template <typename Stream>
184  std::string indent /* = "" */,
185  unsigned int verbosity /* = 0 */
186 ) const
187 {
188 
189  //----------------------------------------------------------------------------
190  out << "centered at " << GetCenter() << " cm";
191 
192  if (verbosity-- <= 0) return; // 0
193 
194  //----------------------------------------------------------------------------
196  out << ", size ( " << (2.0 * HalfWidth1());
197  if (coordIs.nonEqual(HalfWidth1(), HalfWidth2())) out << "/" << (2.0 * HalfWidth2());
198  out << " x " << (2.0 * HalfHeight()) << " x " << Length() << " ) cm";
199 
200  if (verbosity-- <= 0) return; // 1
201 
202  //----------------------------------------------------------------------------
203  out << ", normal facing " << GetNormalVector();
204 
205  // if (verbosity-- <= 0) return; // 2
206 
207  //----------------------------------------------------------------------------
208 
209 } // geo::AuxDetSensitiveGeo::PrintAuxDetInfo()
210 
211 //------------------------------------------------------------------------------
212 
213 #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
geo::Point_t GetCenter(double localz=0.0) const
Returns the geometric center of the sensitive volume.
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
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
double HalfCenterWidth() const
Provides simple real number checks.
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
double fHalfHeight
half height of volume
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Class for approximate comparisons.
AuxDetSensitiveGeo(TGeoNode const &node, geo::TransformationMatrix &&trans)
void InitShapeSize()
Extracts the size of the detector from the geometry information.
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
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
geo::Length_t DistanceToPoint(geo::Point_t const &point) const
Returns the distance of point from the center of the detector.
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this auxiliary sensitive 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().
geo::Point3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
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
Namespace collecting geometry-related classes utilities.
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local auxiliary detector frame.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
Specialization of local-to-world transformations for ROOT GenVector.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
geo::Vector3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML auxiliary detector frame.