LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeometryUtilities.h
Go to the documentation of this file.
1 // \file GeometryUtilities.h
3 //
4 // \brief Functions to calculate distances and angles in 3D and 2D
5 //
6 // \author andrzej.szelc@yale.edu
7 //
9 #ifndef UTIL_GEOMETRYUTILITIES_H
10 #define UTIL_GEOMETRYUTILITIES_H
11 
14 
15 #include "TVector3.h"
16 
17 #include "PxUtils.h"
18 
19 #include <limits>
20 #include <vector>
21 
22 class TLorentzVector;
23 
24 namespace detinfo {
25  class DetectorClocksData;
26  class DetectorPropertiesData;
27 }
28 namespace geo {
29  class GeometryCore;
30 }
31 
33 namespace util {
34 
35  constexpr double kINVALID_DOUBLE = std::numeric_limits<double>::max();
36 
38  public:
40  detinfo::DetectorClocksData const& clockData,
41  detinfo::DetectorPropertiesData const& propData);
42 
43  int Get3DaxisN(int iplane0,
44  int iplane1,
45  double omega0,
46  double omega1,
47  double& phi,
48  double& theta) const;
49 
50  double CalculatePitch(unsigned int iplane0, double phi, double theta) const;
51 
52  double CalculatePitchPolar(unsigned int iplane0, double phi, double theta) const;
53 
54  double Get3DSpecialCaseTheta(int iplane0, int iplane1, double dw0, double dw1) const;
55 
56  double Get2Dangle(double deltawire, double deltatime) const;
57 
58  double Get2Dangle(double wireend, double wirestart, double timeend, double timestart) const;
59 
60  double Get2Dangle(const PxPoint* endpoint, const PxPoint* startpoint) const;
61 
62  double Get2DangleFrom3D(unsigned int plane, double phi, double theta) const;
63 
64  double Get2DangleFrom3D(unsigned int plane, TVector3 dir_vector) const;
65 
66  double Get2Dslope(double deltawire, double deltatime) const;
67 
68  double Get2Dslope(double wireend, double wirestart, double timeend, double timestart) const;
69 
70  double Get2Dslope(const PxPoint* endpoint, const PxPoint* startpoint) const;
71 
72  double Get2DDistance(double wire1, double time1, double wire2, double time2) const;
73 
74  double Get2DDistance(const PxPoint* point1, const PxPoint* point2) const;
75 
76  double Get2DPitchDistance(double angle, double inwire, double wire) const;
77 
78  double Get2DPitchDistanceWSlope(double slope, double inwire, double wire) const;
79 
80  int GetPointOnLine(double slope,
81  double intercept,
82  double wire1,
83  double time1,
84  double& wireout,
85  double& timeout) const;
86 
87  int GetPointOnLine(double slope,
88  double wirestart,
89  double timestart,
90  double wire1,
91  double time1,
92  double& wireout,
93  double& timeout) const;
94 
95  int GetPointOnLine(double slope,
96  const PxPoint* startpoint,
97  const PxPoint* point1,
98  PxPoint& pointout) const;
99 
100  int GetPointOnLine(double slope,
101  double intercept,
102  const PxPoint* point1,
103  PxPoint& pointout) const;
104 
105  int GetPointOnLineWSlopes(double slope,
106  double intercept,
107  double ort_intercept,
108  double& wireout,
109  double& timeout) const;
110 
111  int GetPointOnLineWSlopes(double slope,
112  double intercept,
113  double ort_intercept,
114  PxPoint& pointonline) const;
115 
116  inline PxPoint Get2DPointProjection(double const* xyz, unsigned int plane) const
117  {
118  return Get2DPointProjection(geo::vect::toPoint(xyz), plane);
119  }
120  PxPoint Get2DPointProjection(geo::Point_t const& xyz, unsigned int plane) const;
121 
122  PxPoint Get2DPointProjectionCM(std::vector<double> const& xyz, unsigned int plane) const;
123 
124  PxPoint Get2DPointProjectionCM(double const* xyz, unsigned int plane) const;
125 
126  PxPoint Get2DPointProjectionCM(TLorentzVector const* xyz, unsigned int plane) const;
127 
128  double GetTimeTicks(double x, unsigned int plane) const;
129 
130  int GetProjectedPoint(const PxPoint* p0, const PxPoint* p1, PxPoint& pN) const;
131 
132  PxHit FindClosestHit(std::vector<PxHit> const& hitlist,
133  unsigned int wirein,
134  double timein) const;
135 
136  unsigned int FindClosestHitIndex(std::vector<PxHit> const& hitlist,
137  unsigned int wirein,
138  double timein) const;
139 
140  int GetYZ(const PxPoint* p0, const PxPoint* p1, double* yz) const;
141 
142  int GetXYZ(const PxPoint* p0, const PxPoint* p1, double* xyz) const;
143 
144  double PitchInView(unsigned int plane, double phi, double theta) const;
145 
146  void GetDirectionCosines(double phi, double theta, double* dirs) const;
147 
148  // interface without average Hit
149  void SelectLocalHitlist(const std::vector<PxHit>& hitlist,
150  std::vector<const PxHit*>& hitlistlocal,
151  PxPoint& startHit,
152  double& linearlimit,
153  double& ortlimit,
154  double& lineslopetest) const;
155 
156  void SelectLocalHitlist(const std::vector<PxHit>& hitlist,
157  std::vector<const PxHit*>& hitlistlocal,
158  PxPoint& startHit,
159  double& linearlimit,
160  double& ortlimit,
161  double& lineslopetest,
162  PxHit& averageHit) const;
163 
164  void SelectLocalHitlistIndex(const std::vector<PxHit>& hitlist,
165  std::vector<unsigned int>& hitlistlocal_index,
166  PxPoint& startHit,
167  double& linearlimit,
168  double& ortlimit,
169  double& lineslopetest) const;
170 
171  void SelectPolygonHitList(const std::vector<PxHit>& hitlist,
172  std::vector<const PxHit*>& hitlistlocal) const;
173 
174  std::vector<size_t> PolyOverlap(std::vector<const PxHit*> ordered_hits,
175  std::vector<size_t> candidate_polygon) const;
176 
177  bool Clockwise(double Ax, double Ay, double Bx, double By, double Cx, double Cy) const;
178 
179  double TimeToCm() const { return fTimetoCm; }
180  double WireToCm() const { return fWiretoCm; }
181  double WireTimeToCmCm() const { return fWireTimetoCmCm; }
182  unsigned int Nplanes() const { return fNPlanes; }
183 
184  private:
188 
189  std::vector<double> vertangle; // angle wrt to vertical
190  double fWirePitch;
191  double fTimeTick;
193  unsigned int fNPlanes;
194  double fWiretoCm;
195  double fTimetoCm;
197  }; // class GeometryUtilities
198 
199 } // namespace util
200 #endif // UTIL_GEOMETRYUTILITIES_H
Float_t x
Definition: compare.C:6
detinfo::DetectorClocksData const & fClocks
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
std::vector< double > vertangle
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
double WireTimeToCmCm() const
PxPoint Get2DPointProjection(double const *xyz, unsigned int plane) const
bool Clockwise(double Ax, double Ay, double Bx, double By, double Cx, double Cy)
Definition: Polygon2D.cxx:14
unsigned int Nplanes() const
detinfo::DetectorPropertiesData const & fDetProp
Definitions of geometry vector data types.
Utilities to extend the interface of geometry vectors.
geo::GeometryCore const & fGeom
General LArSoft Utilities.
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
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:180
Contains all timing reference information for the detector.
constexpr double kINVALID_DOUBLE
Namespace collecting geometry-related classes utilities.