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