LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
OpDetGeo.h
Go to the documentation of this file.
1 
9 #ifndef LARCOREALG_GEOMETRY_OPDETGEO_H
10 #define LARCOREALG_GEOMETRY_OPDETGEO_H
11 
12 // LArSoft libraries
15 
16 // ROOT libraries
17 #include "TGeoMatrix.h" // TGeoHMatrix
18 
19 // C/C++ standard libraries
20 #include <vector>
21 #include <array>
22 
23 
24 // forward declarations
25 class TGeoNode;
26 
27 namespace geo {
28 
30  class OpDetGeo {
31  public:
32 
34 
48  struct OpDetGeoCoordinatesTag {};
50 
53 
56 
58 
59  OpDetGeo(std::vector<const TGeoNode*>& path,
60  int depth);
61 
62  void GetCenter(double* xyz, double localz=0.0) const;
63  geo::Point_t const& GetCenter() const { return fCenter; }
64  double RMin() const;
65  double RMax() const;
66  double HalfL() const;
67  double Length() const { return 2.0 * HalfL(); }
68  double ThetaZ() const;
69  double ThetaZ(bool degrees) const;
72 
75  double CosThetaFromNormal(geo::Point_t const& point) const;
77  double CosThetaFromNormal(double const* xyz) const;
79 
80  double DistanceToPoint(geo::Point_t const& point) const;
82  double DistanceToPoint(double const* xyz) const;
84 
85 
87 
95  void LocalToWorld(const double* opdet, double* world) const
97  { fTrans.LocalToWorld(opdet, world); }
98 
101  { return fTrans.toWorldCoords(local); }
102 
104  void LocalToWorldVect(const double* opdet, double* world) const
105  { fTrans.LocalToWorldVect(opdet, world); }
106 
109  { return fTrans.toWorldCoords(local); }
110 
112  void WorldToLocal(const double* world, double* opdet) const
113  { fTrans.WorldToLocal(world, opdet); }
114 
117  { return fTrans.toLocalCoords(world); }
118 
120  void WorldToLocalVect(const double* world, double* opdet) const
121  { fTrans.WorldToLocalVect(world, opdet); }
122 
125  { return fTrans.toLocalCoords(world); }
126 
128 
129 
130  const TGeoNode* Node() const { return fOpDetNode; }
131 
151  template <typename Stream>
152  void PrintOpDetInfo
153  (Stream&& out, std::string indent = "", unsigned int verbosity = 0) const;
154 
156  static constexpr unsigned int MaxVerbosity = 2;
157 
158  private:
161 
163  const TGeoNode* fOpDetNode;
165 
166  }; // class OpDetGeo
167 
168 } // namespace geo
169 
170 
171 //------------------------------------------------------------------------------
172 //--- template implementation
173 //---
174 template <typename Stream>
176  Stream&& out,
177  std::string indent /* = "" */,
178  unsigned int verbosity /* = 0 */
179 ) const {
180 
181  //----------------------------------------------------------------------------
182  out << "centered at " << GetCenter() << " cm";
183 
184  if (verbosity-- <= 0) return; // 0
185 
186  //----------------------------------------------------------------------------
187  out << ", radius: " << RMax() << " cm";
188  if (RMin() != 0.0) out << " (inner: " << RMin() << " cm)";
189  out << ", length: " << Length() << " cm";
190 
191  if (verbosity-- <= 0) return; // 1
192 
193  //----------------------------------------------------------------------------
194  out << ", theta(z): " << ThetaZ() << " rad";
195 
196 // if (verbosity-- <= 0) return; // 2
197 
198  //----------------------------------------------------------------------------
199 
200 } // geo::OpDetGeo::PrintOpDetInfo()
201 
202 
203 #endif // LARCOREALG_GEOMETRY_OPDETGEO_H
const TGeoNode * Node() const
Definition: OpDetGeo.h:130
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
Tag for vectors in the "local" GDML coordinate frame of the TPC.
Definition: OpDetGeo.h:49
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
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
OpDetGeo(std::vector< const TGeoNode * > &path, int depth)
Definition: OpDetGeo.cxx:32
void LocalToWorld(double const *local, double *world) const
Transforms a point from local frame to world frame.
void LocalToWorldVect(double const *local, double *world) const
Transforms a vector from local frame to world frame.
const TGeoNode * fOpDetNode
Pointer to theopdet node.
Definition: OpDetGeo.h:163
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Definition: OpDetGeo.h:124
double RMin() const
Definition: OpDetGeo.cxx:69
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: OpDetGeo.h:108
double RMax() const
Definition: OpDetGeo.cxx:55
Local-to-world transformations with LArSoft geometry vectors.
double HalfL() const
Definition: OpDetGeo.cxx:62
Definitions of geometry vector data types.
std::string indent(std::size_t const i)
void WorldToLocal(const double *world, double *opdet) const
Transform point from world frame to local optical detector frame.
Definition: OpDetGeo.h:112
double Length() const
Definition: OpDetGeo.h:67
void PrintOpDetInfo(Stream &&out, std::string indent="", unsigned int verbosity=0) const
Prints information about this optical detector.
Definition: OpDetGeo.h:175
geo::Point_t fCenter
Stored geometric center of the optical detector.
Definition: OpDetGeo.h:164
void LocalToWorldVect(const double *opdet, double *world) const
Transform direction vector from local to world.
Definition: OpDetGeo.h:104
geo::Vector3DBase_t< OpDetGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML TPC frame.
Definition: OpDetGeo.h:55
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local optical detector frame to world frame.
Definition: OpDetGeo.h:100
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
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintOpDetInfo().
Definition: OpDetGeo.h:156
double ThetaZ() const
Definition: OpDetGeo.cxx:75
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:95
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:90
LocalTransformation_t fTrans
Optical-detector-to-world transformation.
Definition: OpDetGeo.h:162
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.
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 WorldToLocalVect(const double *world, double *opdet) const
Transform direction vector from world to local.
Definition: OpDetGeo.h:120
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
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