LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
OpDetGeo.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::makeFromCoords()
14 
15 // ROOT libraries
16 #include "TGeoManager.h"
17 #include "TGeoTube.h"
18 #include "TGeoNode.h"
19 
20 // C/C++ standard libraries
21 #include <cmath>
22 
23 
24 namespace {
25  template <typename T>
26  inline T sqr(T v) { return v*v; }
27 } // local namespace
28 
29 namespace geo{
30 
31  //-----------------------------------------
32  OpDetGeo::OpDetGeo(std::vector<const TGeoNode*>& path, int depth)
33  : fTrans(path, depth)
34  {
35  fOpDetNode = path[depth];
36 
37  fCenter = toWorldCoords(geo::origin<LocalPoint_t>());
38 
39  }
40 
41  //......................................................................
42 
47  void OpDetGeo::GetCenter(double* xyz, double localz) const
48  {
49  double xyzLocal[3] = {0.,0.,localz};
50  this->LocalToWorld(xyzLocal, xyz);
51  }
52 
53  //......................................................................
54 
55  double OpDetGeo::RMax() const
56  {
57  return ((TGeoTube*)fOpDetNode->GetVolume()->GetShape())->GetRmax();
58  }
59 
60  //......................................................................
61 
62  double OpDetGeo::HalfL() const
63  {
64  return ((TGeoTube*)fOpDetNode->GetVolume()->GetShape())->GetDZ();
65  }
66 
67  //......................................................................
68 
69  double OpDetGeo::RMin() const
70  {
71  return ((TGeoTube*)fOpDetNode->GetVolume()->GetShape())->GetRmin();
72  }
73 
74  //......................................................................
75  double OpDetGeo::ThetaZ() const
76  {
77  auto const& center = GetCenter();
78  auto const& end = toWorldCoords(LocalPoint_t{ 0.0, 0.0, HalfL() });
79 
80  // TODO change this into something generic
81  //either y or x will be 0, so ading both will always catch the right
82  //one
83  double angle = (end.Y()-center.Y()+end.X()-center.X()) /
84  std::abs(end.Y()-center.Y()+center.X()-end.X()) *
85  std::acos((end.Z() - center.Z())/HalfL());
86  if (angle < 0) angle += util::pi();
87  return angle;
88  }
89 
90  //......................................................................
91  double OpDetGeo::ThetaZ(bool degree) const
92  { return degree? util::RadiansToDegrees(ThetaZ()): ThetaZ(); }
93 
94 
95 
96  //......................................................................
97  double OpDetGeo::DistanceToPoint(geo::Point_t const& point) const
98  { return (point - GetCenter()).R(); }
99  double OpDetGeo::DistanceToPoint(double const* xyz) const
100  { return DistanceToPoint(geo::vect::makeFromCoords<geo::Point_t>(xyz)); }
101 
102 
103  //......................................................................
104  double OpDetGeo::CosThetaFromNormal(geo::Point_t const& point) const {
105  auto const& local = toLocalCoords(point);
106  return local.Z() / local.R();
107  }
108  double OpDetGeo::CosThetaFromNormal(double const* xyz) const
109  { return CosThetaFromNormal(geo::vect::makeFromCoords<geo::Point_t>(xyz)); }
110 
111 
112 }
double CosThetaFromNormal(geo::Point_t const &point) const
Get cos(angle) to normal of this detector - used for solid angle calcs.
Definition: OpDetGeo.cxx:104
OpDetGeo(std::vector< const TGeoNode * > &path, int depth)
Definition: OpDetGeo.cxx:32
const TGeoNode * fOpDetNode
Pointer to theopdet node.
Definition: OpDetGeo.h:163
double RMin() const
Definition: OpDetGeo.cxx:69
double RMax() const
Definition: OpDetGeo.cxx:55
T sqr(T v)
double HalfL() const
Definition: OpDetGeo.cxx:62
geo::Point_t fCenter
Stored geometric center of the optical detector.
Definition: OpDetGeo.h:164
Utilities to extend the interface of geometry vectors.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local optical detector frame to world frame.
Definition: OpDetGeo.h:100
Encapsulate the geometry of an optical detector.
geo::Point_t const & GetCenter() const
Definition: OpDetGeo.h:63
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
Definition: OpDetGeo.cxx:97
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
double ThetaZ() const
Definition: OpDetGeo.cxx:75
constexpr T RadiansToDegrees(T angle)
Converts the argument angle from radians into degrees ( )
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
geo::Point3DBase_t< OpDetGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML TPC frame.
Definition: OpDetGeo.h:52
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
Namespace collecting geometry-related classes utilities.
void LocalToWorld(const double *opdet, double *world) const
Transform point from local optical detector frame to world frame.
Definition: OpDetGeo.h:96
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local optical detector frame.
Definition: OpDetGeo.h:116