LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
AuxDetSensitiveGeo.cxx
Go to the documentation of this file.
1 
8 // class header
10 
11 // LArSoft libraries
12 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect namespace
13 
15 #include "TGeoTrd2.h"
16 #include "TGeoBBox.h"
17 
18 // Framework includes
20 #include "cetlib_except/exception.h"
21 
22 
23 namespace geo{
24 
25  //-----------------------------------------
26  AuxDetSensitiveGeo::AuxDetSensitiveGeo(std::vector<const TGeoNode*> const& path, int depth)
27  : fTrans(path, depth)
28  {
29 
30  fTotalVolume = path[depth]->GetVolume();
31  if(!fTotalVolume){
32  throw cet::exception("AuxDetSensitiveGeo") << "cannot find AuxDetSensitive volume\n";
33  }
34 
35  LOG_DEBUG("Geometry") << "detector sensitive total volume is " << fTotalVolume->GetName();
36 
37  InitShapeSize();
38 
39  }
40 
41  //-----------------------------------------
42  AuxDetSensitiveGeo::AuxDetSensitiveGeo(const TGeoVolume* volume,
43  TGeoHMatrix const& rotation)
44  : fTrans(rotation)
45  , fTotalVolume(volume)
46  {
47  assert(fTotalVolume);
48  LOG_DEBUG("Geometry") << "detector sensitive total volume is " << fTotalVolume->GetName();
49 
50  InitShapeSize();
51 
52  }
53 
54  //-----------------------------------------
55  AuxDetSensitiveGeo::AuxDetSensitiveGeo(const TGeoVolume* volume,
56  TGeoHMatrix&& rotation)
57  : fTrans(std::move(rotation))
58  , fTotalVolume(volume)
59  {
60  assert(fTotalVolume);
61  LOG_DEBUG("Geometry") << "detector sensitive total volume is " << fTotalVolume->GetName();
62 
63  InitShapeSize();
64 
65  }
66 
67  //......................................................................
68  geo::Point_t AuxDetSensitiveGeo::GetCenter(double localz /* = 0.0 */) const
69  { return toWorldCoords(LocalPoint_t{ 0.0, 0.0, localz }); }
70 
71  //......................................................................
72  void AuxDetSensitiveGeo::GetCenter(double* xyz, double localz) const {
73  auto const& center = GetCenter(localz);
74  xyz[0] = center.X();
75  xyz[1] = center.Y();
76  xyz[2] = center.Z();
77  } // AuxDetSensitiveGeo::GetCenter(double*)
78 
79  //......................................................................
80 
81  // Return the unit normal vector (0,0,1) in local coordinates to global coordinates
83  { return toWorldCoords(geo::Zaxis<LocalVector_t>()); }
84 
85  //......................................................................
86 
87  // Return the unit normal vector (0,0,1) in local coordinates to global coordinates
88  void AuxDetSensitiveGeo::GetNormalVector(double* xyzDir) const {
89  auto const& norm = GetNormalVector();
90  xyzDir[0] = norm.X();
91  xyzDir[1] = norm.Y();
92  xyzDir[2] = norm.Z();
93  } // AuxDetSensitiveGeo::GetNormalVector(double*)
94 
95 
96  //......................................................................
99 
100 
101  //......................................................................
103  // set the ends depending on whether the shape is a box or trapezoid
104  std::string volName(fTotalVolume->GetName());
105  if( volName.find("Trap") != std::string::npos ) {
106 
107  // Small Width
108  // ____ Height is the thickness
109  // / \ T of the trapezoid
110  // / \ |
111  // / \ | Length
112  // /__________\ _
113  // Width
114  fHalfHeight = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDy1(); // same as Dy2()
115  fLength = 2.0*((TGeoTrd2*)fTotalVolume->GetShape())->GetDz();
116  fHalfWidth1 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx1(); // at -Dz
117  fHalfWidth2 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx2(); // at +Dz
118  }
119  else {
120  fHalfWidth1 = ((TGeoBBox*)fTotalVolume->GetShape())->GetDX();
121  fHalfHeight = ((TGeoBBox*)fTotalVolume->GetShape())->GetDY();
122  fLength = 2.0*((TGeoBBox*)fTotalVolume->GetShape())->GetDZ();
124  }
125  } // AuxDetSensitiveGeo::InitShapeSize()
126 }
double fLength
length of volume, along z direction in local
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:167
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Definition: geo_vectors.h:140
Encapsulate the geometry of the sensitive portion of an auxiliary detector.
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
STL namespace.
double fHalfHeight
half height of volume
AuxDetSensitiveGeo(std::vector< const TGeoNode * > const &path, int depth)
void InitShapeSize()
Extracts the size of the detector from the geometry information.
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Utilities to extend the interface of geometry vectors.
geo::Length_t DistanceToPoint(geo::Point_t const &point) const
Returns the distance of point from the center of the detector.
Float_t norm
geo::Point3DBase_t< AuxDetSensitiveGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
#define LOG_DEBUG(id)
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
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:187
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Namespace collecting geometry-related classes utilities.
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.