LArSoft  v07_13_02
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 asTube()->GetRmax();
58  }
59 
60  //......................................................................
61 
62  double OpDetGeo::HalfL() const
63  {
64  TGeoBBox const* pBox = asBox();
65  return pBox? pBox->GetDZ(): 0.0;
66  }
67 
68  //......................................................................
69 
70  double OpDetGeo::HalfW() const
71  {
72  TGeoBBox const* pBox = asBox();
73  return pBox? pBox->GetDX(): 0.0;
74  }
75 
76  //......................................................................
77 
78  double OpDetGeo::HalfH() const
79  {
80  TGeoBBox const* pBox = asBox();
81  return pBox? pBox->GetDY(): 0.0;
82  }
83 
84  //......................................................................
85 
86  double OpDetGeo::RMin() const
87  {
88  return asTube()->GetRmin();
89  }
90 
91  //......................................................................
92  double OpDetGeo::ThetaZ() const
93  {
94  auto const& center = GetCenter();
95  auto const& end = toWorldCoords(LocalPoint_t{ 0.0, 0.0, HalfL() });
96 
97  // TODO change this into something generic
98  //either y or x will be 0, so ading both will always catch the right
99  //one
100  double angle = (end.Y()-center.Y()+end.X()-center.X()) /
101  std::abs(end.Y()-center.Y()+center.X()-end.X()) *
102  std::acos((end.Z() - center.Z())/HalfL());
103  if (angle < 0) angle += util::pi();
104  return angle;
105  }
106 
107  //......................................................................
108  double OpDetGeo::ThetaZ(bool degree) const
109  { return degree? util::RadiansToDegrees(ThetaZ()): ThetaZ(); }
110 
111 
112 
113  //......................................................................
114  double OpDetGeo::DistanceToPoint(geo::Point_t const& point) const
115  { return (point - GetCenter()).R(); }
116  double OpDetGeo::DistanceToPoint(double const* xyz) const
117  { return DistanceToPoint(geo::vect::makeFromCoords<geo::Point_t>(xyz)); }
118 
119 
120  //......................................................................
121  double OpDetGeo::CosThetaFromNormal(geo::Point_t const& point) const {
122  auto const& local = toLocalCoords(point);
123  return local.Z() / local.R();
124  }
125  double OpDetGeo::CosThetaFromNormal(double const* xyz) const
126  { return CosThetaFromNormal(geo::vect::makeFromCoords<geo::Point_t>(xyz)); }
127 
128 
129 }
double CosThetaFromNormal(geo::Point_t const &point) const
Get cos(angle) to normal of this detector - used for solid angle calcs.
Definition: OpDetGeo.cxx:121
OpDetGeo(std::vector< const TGeoNode * > &path, int depth)
Definition: OpDetGeo.cxx:32
const TGeoNode * fOpDetNode
Pointer to theopdet node.
Definition: OpDetGeo.h:179
double RMin() const
Definition: OpDetGeo.cxx:86
double RMax() const
Definition: OpDetGeo.cxx:55
double HalfW() const
Definition: OpDetGeo.cxx:70
T sqr(T v)
double HalfL() const
Definition: OpDetGeo.cxx:62
TGeoBBox const * asBox() const
Returns the geometry object as TGeoBBox, nullptr if not a tube.
Definition: OpDetGeo.h:187
geo::Point_t fCenter
Stored geometric center of the optical detector.
Definition: OpDetGeo.h:180
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:107
Encapsulate the geometry of an optical detector.
geo::Point_t const & GetCenter() const
Definition: OpDetGeo.h:66
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
Definition: OpDetGeo.cxx:114
TGeoTube const * asTube() const
Returns the geometry object as TGeoTube, nullptr if not a tube.
Definition: OpDetGeo.h:183
double HalfH() const
Definition: OpDetGeo.cxx:78
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
double ThetaZ() const
Definition: OpDetGeo.cxx:92
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:55
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:103
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local optical detector frame.
Definition: OpDetGeo.h:123