AuxDetSensitiveGeo.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file larcorealg/Geometry/AuxDetSensitiveGeo.cxx
3 /// \brief Encapsulate the geometry of the sensitive portion of an auxilary detector
4 ///
5 /// \author brebel@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 
8 // class header
10 
11 // LArSoft libraries
12 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect namespace
13 
14 /// ROOT libraries
15 #include "TGeoTrd2.h"
16 #include "TGeoBBox.h"
17 #include "TGeoNode.h"
18 #include "TGeoVolume.h"
19 
20 // Framework includes
22 
23 // C++ standard libraries
24 #include <sstream> // std::ostringstream
25 
26 
27 namespace geo{
28 
29  //-----------------------------------------
31  (TGeoNode const& node, geo::TransformationMatrix&& trans)
32  : fTrans(std::move(trans))
33  , fTotalVolume(node.GetVolume())
34  {
35 
36  MF_LOG_DEBUG("Geometry") << "detector sensitive total volume is " << fTotalVolume->GetName();
37 
38  InitShapeSize();
39 
40  }
41 
42  //......................................................................
43  geo::Point_t AuxDetSensitiveGeo::GetCenter(double localz /* = 0.0 */) const
44  { return toWorldCoords(LocalPoint_t{ 0.0, 0.0, localz }); }
45 
46  //......................................................................
47  void AuxDetSensitiveGeo::GetCenter(double* xyz, double localz) const {
48  auto const& center = GetCenter(localz);
49  xyz[0] = center.X();
50  xyz[1] = center.Y();
51  xyz[2] = center.Z();
52  } // AuxDetSensitiveGeo::GetCenter(double*)
53 
54  //......................................................................
55 
56  // Return the unit normal vector (0,0,1) in local coordinates to global coordinates
58  { return toWorldCoords(geo::Zaxis<LocalVector_t>()); }
59 
60  //......................................................................
61 
62  // Return the unit normal vector (0,0,1) in local coordinates to global coordinates
63  void AuxDetSensitiveGeo::GetNormalVector(double* xyzDir) const {
64  auto const& norm = GetNormalVector();
65  xyzDir[0] = norm.X();
66  xyzDir[1] = norm.Y();
67  xyzDir[2] = norm.Z();
68  } // AuxDetSensitiveGeo::GetNormalVector(double*)
69 
70 
71  //......................................................................
74 
75 
76  //......................................................................
78  (std::string indent /* = "" */, unsigned int verbosity /* = 1 */) const
79  {
80  std::ostringstream sstr;
81  PrintAuxDetInfo(sstr, indent, verbosity);
82  return sstr.str();
83  } // AuxDetSensitiveGeo::AuxDetInfo()
84 
85 
86  //......................................................................
88  // set the ends depending on whether the shape is a box or trapezoid
89  std::string volName(fTotalVolume->GetName());
90  if( volName.find("Trap") != std::string::npos ) {
91 
92  // Small Width
93  // ____ Height is the thickness
94  // / \ T of the trapezoid
95  // / \ |
96  // / \ | Length
97  // /__________\ _
98  // Width
99  fHalfHeight = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDy1(); // same as Dy2()
100  fLength = 2.0*((TGeoTrd2*)fTotalVolume->GetShape())->GetDz();
101  fHalfWidth1 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx1(); // at -Dz
102  fHalfWidth2 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx2(); // at +Dz
103  }
104  else {
105  fHalfWidth1 = ((TGeoBBox*)fTotalVolume->GetShape())->GetDX();
106  fHalfHeight = ((TGeoBBox*)fTotalVolume->GetShape())->GetDY();
107  fLength = 2.0*((TGeoBBox*)fTotalVolume->GetShape())->GetDZ();
109  }
110  } // AuxDetSensitiveGeo::InitShapeSize()
111 }
112 ////////////////////////////////////////////////////////////////////////
double fLength
length of volume, along z direction in local
Utilities to extend the interface of geometry vectors.
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
std::string string
Definition: nybbler.cc:12
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
double fHalfHeight
half height of 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:164
AuxDetSensitiveGeo(TGeoNode const &node, geo::TransformationMatrix &&trans)
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
void InitShapeSize()
Extracts the size of the detector from the geometry information.
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
def move(depos, offset)
Definition: depos.py:107
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.
auto norm(Vector const &v)
Return norm of the specified vector.
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:184
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Definition: geo_vectors.h:137
std::string AuxDetInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with auxiliary sensitive detector information.
def center(depos, point)
Definition: depos.py:117
#define MF_LOG_DEBUG(id)
geo::Point3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.
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.