LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::AuxDetGeo Class Reference

#include "AuxDetGeo.h"

Classes

struct  AuxDetGeoCoordinatesTag
 

Public Types

using AuxDetSensitiveList_t = std::vector< geo::AuxDetSensitiveGeo >
 Type of list of sensitive volumes. More...
 
Types for geometry-local reference vectors.

These types represents points and displacement vectors in the reference frame defined in the auxiliary detector geometry box from the GDML geometry description.

No alias is explicitly defined for the LArSoft global vector types, geo::Point_t and geo::Vector_t.

Remember the LocalPoint_t and LocalVector_t vectors from different instances of geo::AuxDetGeo have the same type but are not compatible.

using LocalPoint_t = geo::Point3DBase_t< AuxDetGeoCoordinatesTag >
 Type of points in the local GDML auxiliary detector frame. More...
 
using LocalVector_t = geo::Vector3DBase_t< AuxDetGeoCoordinatesTag >
 Type of displacement vectors in the local GDML auxiliary detector frame. More...
 

Public Member Functions

 AuxDetGeo (TGeoNode const &node, geo::TransformationMatrix &&trans, AuxDetSensitiveList_t &&sensitive)
 
geo::Point_t GetCenter (double localz=0.0) const
 Returns the geometric center of the sensitive volume. More...
 
geo::Vector_t GetNormalVector () const
 Returns the unit normal vector to the detector. More...
 
std::string Name () const
 
AuxDetSensitiveGeo const & SensitiveVolume (size_t sv) const
 
size_t NSensitiveVolume () const
 
void SortSubVolumes (geo::GeoObjectSorter const &sorter)
 
template<typename Stream >
void PrintAuxDetInfo (Stream &&out, std::string indent="", unsigned int verbosity=1) const
 Prints information about this auxiliary detector. More...
 
std::string AuxDetInfo (std::string indent="", unsigned int verbosity=1) const
 Returns a string with auxiliary detector information. More...
 
Box geometry
double Length () const
 Returns the distance of point from the center of the detector. More...
 
double HalfWidth1 () const
 Returns the distance of point from the center of the detector. More...
 
double HalfWidth2 () const
 Returns the distance of point from the center of the detector. More...
 
double HalfHeight () const
 Returns the distance of point from the center of the detector. More...
 
const TGeoVolume * TotalVolume () const
 Returns the distance of point from the center of the detector. More...
 
geo::Length_t DistanceToPoint (geo::Point_t const &point) const
 Returns the distance of point from the center of the detector. More...
 
Coordinate transformation
geo::Point_t toWorldCoords (LocalPoint_t const &local) const
 Transform point from local auxiliary detector frame to world frame. More...
 
geo::Vector_t toWorldCoords (LocalVector_t const &local) const
 Transform direction vector from local to world. More...
 
LocalPoint_t toLocalCoords (geo::Point_t const &world) const
 Transform point from world frame to local auxiliary detector frame. More...
 
LocalVector_t toLocalCoords (geo::Vector_t const &world) const
 Transform direction vector from world to local. More...
 
Access to the sensitive volumes in the detector
std::size_t FindSensitiveVolume (geo::Point_t const &point) const
 
AuxDetSensitiveGeo const & PositionToSensitiveVolume (geo::Point_t const &point, size_t &sv) const
 

Static Public Attributes

static constexpr unsigned int MaxVerbosity = 4
 Maximum verbosity supported by PrintAuxDetInfo(). More...
 

Private Types

using LocalTransformation_t = geo::LocalTransformationGeo< geo::TransformationMatrix, LocalPoint_t, LocalVector_t >
 

Private Member Functions

void InitShapeSize ()
 Extracts the size of the detector from the geometry information. More...
 

Private Attributes

const TGeoVolume * fTotalVolume
 Total volume of AuxDet, called vol*. More...
 
LocalTransformation_t fTrans
 Auxiliary detector-to-world transformation. More...
 
double fLength
 length of volume, along z direction in local More...
 
double fHalfWidth1
 1st half width of volume, at -z/2 in local coordinates More...
 
double fHalfWidth2
 2nd half width (width1==width2 for boxes), at +z/2 More...
 
double fHalfHeight
 half height of volume More...
 
std::vector< AuxDetSensitiveGeofSensitive
 sensitive volumes in the detector More...
 

Detailed Description

Definition at line 38 of file AuxDetGeo.h.

Member Typedef Documentation

Type of list of sensitive volumes.

Definition at line 41 of file AuxDetGeo.h.

Type of points in the local GDML auxiliary detector frame.

Definition at line 63 of file AuxDetGeo.h.

Type of displacement vectors in the local GDML auxiliary detector frame.

Definition at line 66 of file AuxDetGeo.h.

Constructor & Destructor Documentation

geo::AuxDetGeo::AuxDetGeo ( TGeoNode const &  node,
geo::TransformationMatrix &&  trans,
AuxDetSensitiveList_t &&  sensitive 
)

Definition at line 32 of file AuxDetGeo.cxx.

References fSensitive, fTotalVolume, fTrans, InitShapeSize(), geo::LocalTransformation< StoredMatrix >::Matrix(), and MF_LOG_DEBUG.

35  : fTotalVolume(node.GetVolume()), fTrans(std::move(trans)), fSensitive(std::move(sensitive))
36  {
37  if (!fTotalVolume) throw cet::exception("AuxDetGeo") << "cannot find AuxDet volume\n";
38 
39  MF_LOG_DEBUG("Geometry") << "detector total volume is " << fTotalVolume->GetName();
40 
41  // if there are no sensitive volumes then this aux det
42  // could be from an older gdml file than the introduction of AuxDetSensitiveGeo
43  // in that case assume the full AuxDetGeo is sensitive and copy its information
44  // into a single AuxDetSensitive
45  if (fSensitive.empty())
46  fSensitive.emplace_back(node, geo::TransformationMatrix(fTrans.Matrix()));
47 
48  InitShapeSize();
49  }
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:191
TransformationMatrix_t const & Matrix() const
Direct access to the transformation matrix.
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:190
#define MF_LOG_DEBUG(id)
void InitShapeSize()
Extracts the size of the detector from the geometry information.
Definition: AuxDetGeo.cxx:118
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< AuxDetSensitiveGeo > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:196

Member Function Documentation

std::string geo::AuxDetGeo::AuxDetInfo ( std::string  indent = "",
unsigned int  verbosity = 1 
) const

Returns a string with auxiliary detector information.

See also
PrintAuxDetInfo()

The arguments and provided information are the same as in PrintAuxDetInfo().

Definition at line 109 of file AuxDetGeo.cxx.

References PrintAuxDetInfo().

Referenced by NSensitiveVolume().

111  {
112  std::ostringstream sstr;
113  PrintAuxDetInfo(sstr, indent, verbosity);
114  return sstr.str();
115  }
std::string indent(std::size_t const i)
void PrintAuxDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this auxiliary detector.
Definition: AuxDetGeo.h:211
geo::Length_t geo::AuxDetGeo::DistanceToPoint ( geo::Point_t const &  point) const
inline

Returns the distance of point from the center of the detector.

Definition at line 96 of file AuxDetGeo.h.

Referenced by TotalVolume().

97  {
98  return (point - GetCenter()).R();
99  }
geo::Point_t GetCenter(double localz=0.0) const
Returns the geometric center of the sensitive volume.
Definition: AuxDetGeo.cxx:52
std::size_t geo::AuxDetGeo::FindSensitiveVolume ( geo::Point_t const &  point) const

Definition at line 66 of file AuxDetGeo.cxx.

References fSensitive, and SensitiveVolume().

Referenced by Name(), and PositionToSensitiveVolume().

67  {
68  for (std::size_t a = 0; a < fSensitive.size(); ++a) {
69  auto const& sensVol = SensitiveVolume(a);
70 
71  auto const local = sensVol.toLocalCoords(point);
72 
73  double const HalfCenterWidth = sensVol.HalfCenterWidth();
74 
75  double const deltaWidth =
76  local.Z() * (HalfCenterWidth - sensVol.HalfWidth2()) / sensVol.HalfLength();
77 
78  if (local.Z() >= -sensVol.HalfLength() && local.Z() <= sensVol.HalfLength() &&
79  local.Y() >= -sensVol.HalfHeight() && local.Y() <= sensVol.HalfHeight() &&
80  // if SensitiveVolume a is a box, then HalfSmallWidth = HalfWidth
81  local.X() >= -HalfCenterWidth + deltaWidth && local.X() <= HalfCenterWidth - deltaWidth)
82  return a;
83 
84  } // for loop over AuxDetSensitive a
85 
86  throw cet::exception("AuxDetGeo")
87  << "Can't find AuxDetSensitive for position " << point << "\n";
88  } // AuxDetGeo::FindSensitiveVolume(geo::Point_t)
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:143
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< AuxDetSensitiveGeo > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:196
geo::Point_t geo::AuxDetGeo::GetCenter ( double  localz = 0.0) const

Returns the geometric center of the sensitive volume.

Parameters
localz(default: 0) distance from the center along the length of the volume (z) [cm]
Returns
the geometric center of the sensitive volume [cm]

Definition at line 52 of file AuxDetGeo.cxx.

References toWorldCoords().

Referenced by PrintAuxDetInfo(), and TotalVolume().

53  {
54  return toWorldCoords(LocalPoint_t{0.0, 0.0, localz});
55  }
geo::Point3DBase_t< AuxDetGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML auxiliary detector frame.
Definition: AuxDetGeo.h:63
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:106
geo::Vector_t geo::AuxDetGeo::GetNormalVector ( ) const

Returns the unit normal vector to the detector.

Definition at line 60 of file AuxDetGeo.cxx.

References toWorldCoords().

Referenced by PrintAuxDetInfo().

61  {
62  return toWorldCoords(geo::Zaxis<LocalVector_t>());
63  }
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:106
double geo::AuxDetGeo::HalfHeight ( ) const
inline

Returns the distance of point from the center of the detector.

Definition at line 90 of file AuxDetGeo.h.

References fHalfHeight.

Referenced by PrintAuxDetInfo().

90 { return fHalfHeight; }
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:195
double geo::AuxDetGeo::HalfWidth1 ( ) const
inline

Returns the distance of point from the center of the detector.

Definition at line 88 of file AuxDetGeo.h.

References fHalfWidth1.

Referenced by PrintAuxDetInfo().

88 { return fHalfWidth1; }
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:193
double geo::AuxDetGeo::HalfWidth2 ( ) const
inline

Returns the distance of point from the center of the detector.

Definition at line 89 of file AuxDetGeo.h.

References fHalfWidth2.

Referenced by PrintAuxDetInfo().

89 { return fHalfWidth2; }
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:194
void geo::AuxDetGeo::InitShapeSize ( )
private

Extracts the size of the detector from the geometry information.

Definition at line 118 of file AuxDetGeo.cxx.

References fHalfHeight, fHalfWidth1, fHalfWidth2, fLength, and fTotalVolume.

Referenced by AuxDetGeo().

119  {
120  // set the ends depending on whether the shape is a box or trapezoid
121  std::string volName(fTotalVolume->GetName());
122  if (volName.find("Trap") != std::string::npos) {
123 
124  // Small Width
125  // ____ Height is the thickness
126  // / \ T of the trapezoid
127  // / \ |
128  // / \ | Length
129  // /__________\ _
130  // Width
131  fHalfHeight = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDy1(); // same as Dy2()
132  fLength = 2.0 * ((TGeoTrd2*)fTotalVolume->GetShape())->GetDz();
133  fHalfWidth1 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx1(); // at -Dz
134  fHalfWidth2 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx2(); // at +Dz
135  }
136  else {
137  fHalfWidth1 = ((TGeoBBox*)fTotalVolume->GetShape())->GetDX();
138  fHalfHeight = ((TGeoBBox*)fTotalVolume->GetShape())->GetDY();
139  fLength = 2.0 * ((TGeoBBox*)fTotalVolume->GetShape())->GetDZ();
141  }
142  }
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:194
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:193
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:192
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:190
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:195
double geo::AuxDetGeo::Length ( ) const
inline

Returns the distance of point from the center of the detector.

Definition at line 87 of file AuxDetGeo.h.

References fLength.

Referenced by PrintAuxDetInfo().

87 { return fLength; }
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:192
std::string geo::AuxDetGeo::Name ( ) const
inline

Definition at line 131 of file AuxDetGeo.h.

References FindSensitiveVolume(), fTotalVolume, and PositionToSensitiveVolume().

Referenced by PrintAuxDetInfo().

131 { return fTotalVolume->GetName(); }
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:190
size_t geo::AuxDetGeo::NSensitiveVolume ( ) const
inline
AuxDetSensitiveGeo const & geo::AuxDetGeo::PositionToSensitiveVolume ( geo::Point_t const &  point,
size_t &  sv 
) const

Definition at line 91 of file AuxDetGeo.cxx.

References FindSensitiveVolume(), and SensitiveVolume().

Referenced by Name().

93  {
94  sv = FindSensitiveVolume(point);
95  if (sv == std::numeric_limits<std::size_t>::max()) {
96  throw cet::exception("AuxDetGeo")
97  << "Can't find AuxDetSensitiveGeo for position " << point << "\n";
98  }
99  return SensitiveVolume(sv);
100  }
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:143
std::size_t FindSensitiveVolume(geo::Point_t const &point) const
Definition: AuxDetGeo.cxx:66
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename Stream >
void geo::AuxDetGeo::PrintAuxDetInfo ( Stream &&  out,
std::string  indent = "",
unsigned int  verbosity = 1 
) const

Prints information about this auxiliary detector.

Template Parameters
Streamtype of output stream to use
Parameters
outstream to send the information to
indentprepend each line with this string
verbosityamount of information printed

Note that the first line out the output is not indented.

Verbosity levels

  • 0: only detector name
  • 1 _(default)_: also center
  • 2: also size
  • 3: also number of sensitive detectors
  • 4: also normal direction

The constant MaxVerbosity is set to the highest supported verbosity level.

Definition at line 211 of file AuxDetGeo.h.

References e, GetCenter(), GetNormalVector(), HalfHeight(), HalfWidth1(), HalfWidth2(), Length(), Name(), lar::util::RealComparisons< RealType >::nonEqual(), and NSensitiveVolume().

Referenced by AuxDetInfo(), NSensitiveVolume(), and geo::GeometryCore::Print().

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()
Provides simple real number checks.
double HalfWidth2() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:89
double HalfHeight() const
Returns the distance of point from the center of the detector.
Definition: AuxDetGeo.h:90
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
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
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
void geo::AuxDetGeo::SortSubVolumes ( geo::GeoObjectSorter const &  sorter)

Definition at line 103 of file AuxDetGeo.cxx.

References fSensitive, and geo::GeoObjectSorter::SortAuxDetSensitive().

Referenced by NSensitiveVolume().

104  {
105  sorter.SortAuxDetSensitive(fSensitive);
106  }
std::vector< AuxDetSensitiveGeo > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:196
LocalPoint_t geo::AuxDetGeo::toLocalCoords ( geo::Point_t const &  world) const
inline

Transform point from world frame to local auxiliary detector frame.

Definition at line 118 of file AuxDetGeo.h.

References fTrans, and geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >::toLocalCoords().

119  {
120  return fTrans.toLocalCoords(world);
121  }
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 geo::AuxDetGeo::toLocalCoords ( geo::Vector_t const &  world) const
inline

Transform direction vector from world to local.

Definition at line 124 of file AuxDetGeo.h.

References fTrans, and geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >::toLocalCoords().

125  {
126  return fTrans.toLocalCoords(world);
127  }
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.
const TGeoVolume* geo::AuxDetGeo::TotalVolume ( ) const
inline

Returns the distance of point from the center of the detector.

Definition at line 91 of file AuxDetGeo.h.

References DistanceToPoint(), fTotalVolume, and GetCenter().

Referenced by geo::sortAuxDetStandard().

91 { return fTotalVolume; }
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:190
geo::Point_t geo::AuxDetGeo::toWorldCoords ( LocalPoint_t const &  local) const
inline

Transform point from local auxiliary detector frame to world frame.

Definition at line 106 of file AuxDetGeo.h.

References fTrans, and geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >::toWorldCoords().

Referenced by GetCenter(), and GetNormalVector().

107  {
108  return fTrans.toWorldCoords(local);
109  }
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:191
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.
geo::Vector_t geo::AuxDetGeo::toWorldCoords ( LocalVector_t const &  local) const
inline

Transform direction vector from local to world.

Definition at line 112 of file AuxDetGeo.h.

References fTrans, and geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >::toWorldCoords().

113  {
114  return fTrans.toWorldCoords(local);
115  }
LocalTransformation_t fTrans
Auxiliary detector-to-world transformation.
Definition: AuxDetGeo.h:191
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.

Member Data Documentation

double geo::AuxDetGeo::fHalfHeight
private

half height of volume

Definition at line 195 of file AuxDetGeo.h.

Referenced by HalfHeight(), and InitShapeSize().

double geo::AuxDetGeo::fHalfWidth1
private

1st half width of volume, at -z/2 in local coordinates

Definition at line 193 of file AuxDetGeo.h.

Referenced by HalfWidth1(), and InitShapeSize().

double geo::AuxDetGeo::fHalfWidth2
private

2nd half width (width1==width2 for boxes), at +z/2

Definition at line 194 of file AuxDetGeo.h.

Referenced by HalfWidth2(), and InitShapeSize().

double geo::AuxDetGeo::fLength
private

length of volume, along z direction in local

Definition at line 192 of file AuxDetGeo.h.

Referenced by InitShapeSize(), and Length().

std::vector<AuxDetSensitiveGeo> geo::AuxDetGeo::fSensitive
private

sensitive volumes in the detector

Definition at line 196 of file AuxDetGeo.h.

Referenced by AuxDetGeo(), FindSensitiveVolume(), NSensitiveVolume(), SensitiveVolume(), and SortSubVolumes().

const TGeoVolume* geo::AuxDetGeo::fTotalVolume
private

Total volume of AuxDet, called vol*.

Definition at line 190 of file AuxDetGeo.h.

Referenced by AuxDetGeo(), InitShapeSize(), Name(), and TotalVolume().

LocalTransformation_t geo::AuxDetGeo::fTrans
private

Auxiliary detector-to-world transformation.

Definition at line 191 of file AuxDetGeo.h.

Referenced by AuxDetGeo(), toLocalCoords(), and toWorldCoords().

constexpr unsigned int geo::AuxDetGeo::MaxVerbosity = 4
static

Maximum verbosity supported by PrintAuxDetInfo().

Definition at line 184 of file AuxDetGeo.h.

Referenced by geo::GeometryCore::Print().


The documentation for this class was generated from the following files: