LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
12 #include <TMath.h>
13 #include <TLorentzVector.h>
14 
15 #include "PxUtils.h"
20 #include "time.h"
21 
26 
27 #include <climits>
28 #include <iostream>
29 #include <vector>
30 
31 
33 namespace util{
34 
36 
37  //class GeometryUtilities : public larlight::larlight_base {
39 
40  public:
41 
42  static const GeometryUtilities* GetME() {
43  if(!_me) _me = new GeometryUtilities;
44  return _me;
45  }
46 
49 
52 
53  private:
54 
56 
57  /*
59  GeometryUtilities();
60 
62  ~GeometryUtilities();
63  */
64 
65  public:
66 
67  void Reconfigure();
68 
69  Int_t Get3DaxisN(Int_t iplane0,
70  Int_t iplane1,
71  Double_t omega0,
72  Double_t omega1,
73  Double_t &phi,
74  Double_t &theta) const;
75 
76  Double_t CalculatePitch(UInt_t iplane0,
77  Double_t phi,
78  Double_t theta) const;
79 
80  Double_t CalculatePitchPolar(UInt_t iplane0,
81  Double_t phi,
82  Double_t theta) const;
83 
84  Double_t Get3DSpecialCaseTheta(Int_t iplane0,
85  Int_t iplane1,
86  Double_t dw0,
87  Double_t dw1) const;
88 
89 
90  Double_t Get2Dangle(Double_t deltawire,
91  Double_t deltatime) const;
92 
93 
94 
95  Double_t Get2Dangle(Double_t wireend,
96  Double_t wirestart,
97  Double_t timeend,
98  Double_t timestart) const;
99 
100 
101  double Get2Dangle(const util::PxPoint *endpoint,
102  const util::PxPoint *startpoint) const;
103 
104  double Get2DangleFrom3D(unsigned int plane,double phi, double theta) const;
105 
106  double Get2DangleFrom3D(unsigned int plane,TVector3 dir_vector) const;
107 
108 
109  Double_t Get2Dslope(Double_t deltawire,
110  Double_t deltatime) const;
111 
112  Double_t Get2Dslope(Double_t wireend,
113  Double_t wirestart,
114  Double_t timeend,
115  Double_t timestart) const;
116 
117  double Get2Dslope(const util::PxPoint *endpoint,
118  const util::PxPoint *startpoint) const;
119 
120  Double_t Get2DDistance(Double_t wire1,
121  Double_t time1,
122  Double_t wire2,
123  Double_t time2) const;
124 
125  double Get2DDistance(const util::PxPoint *point1,
126  const util::PxPoint *point2) const;
127 
128 
129  Double_t Get2DPitchDistance(Double_t angle,
130  Double_t inwire,
131  Double_t wire) const;
132 
133  Double_t Get2DPitchDistanceWSlope(Double_t slope,
134  Double_t inwire,
135  Double_t wire) const;
136 
137  Int_t GetPointOnLine(Double_t slope,
138  Double_t intercept,
139  Double_t wire1,
140  Double_t time1,
141  Double_t &wireout,
142  Double_t &timeout) const;
143 
144  Int_t GetPointOnLine(Double_t slope,
145  Double_t wirestart,
146  Double_t timestart,
147  Double_t wire1,
148  Double_t time1,
149  Double_t &wireout,
150  Double_t &timeout) const;
151 
152  int GetPointOnLine(Double_t slope,
153  const util::PxPoint *startpoint,
154  const util::PxPoint *point1,
155  util::PxPoint &pointout) const;
156 
157  int GetPointOnLine(double slope,
158  double intercept,
159  const util::PxPoint *point1,
160  util::PxPoint &pointout) const;
161 
162  Int_t GetPointOnLineWSlopes(Double_t slope,
163  Double_t intercept,
164  Double_t ort_intercept,
165  Double_t &wireout,
166  Double_t &timeout) const;
167 
168  Int_t GetPointOnLineWSlopes(double slope,
169  double intercept,
170  double ort_intercept,
171  util::PxPoint &pointonline) const;
172 
173  PxPoint Get2DPointProjection(Double_t *xyz,Int_t plane) const;
174 
175  PxPoint Get2DPointProjectionCM(std::vector< double > xyz, int plane) const;
176 
177  PxPoint Get2DPointProjectionCM(double *xyz, int plane) const;
178 
179  PxPoint Get2DPointProjectionCM(TLorentzVector *xyz, int plane) const;
180 
181  Double_t GetTimeTicks(Double_t x, Int_t plane) const;
182 
183  Int_t GetProjectedPoint(const PxPoint *p0,
184  const PxPoint *p1,
185  PxPoint &pN) const;
186 
187  /* art::Ptr< recob::Hit > FindClosestHitPtr(std::vector<art::Ptr< recob::Hit > > hitlist,
188  unsigned int wirein,
189  double timein) const;
190 
191 
192  recob::Hit * FindClosestHit(std::vector<art::Ptr< recob::Hit > > hitlist,
193  unsigned int wirein,
194  double timein) const; */
195 
196  util::PxHit FindClosestHit(std::vector<util::PxHit > hitlist,
197  unsigned int wirein,
198  double timein) const;
199 
200  unsigned int FindClosestHitIndex(std::vector<util::PxHit > hitlist,
201  unsigned int wirein,
202  double timein) const;
203 
204 
205 // void SelectLocalHitlist(std::vector< art::Ptr < recob::Hit> > hitlist,
206 // std::vector < art::Ptr<recob::Hit> > &hitlistlocal,
207 // double wire_start,
208 // double time_start,
209 // double linearlimit,
210 // double ortlimit,
211 // double lineslopetest);
212 
213 /* void SelectLocalHitlist(std::vector< util::PxHit > hitlist,
214  std::vector < util::PxHit > &hitlistlocal,
215  double wire_start,
216  double time_start,
217  double linearlimit,
218  double ortlimit,
219  double lineslopetest); */
220 
221 
222  Int_t GetYZ(const PxPoint *p0,
223  const PxPoint *p1,
224  Double_t* yz) const;
225 
226 
227  Int_t GetXYZ(const PxPoint *p0,
228  const PxPoint *p1,
229  Double_t* xyz) const;
230 
231  Double_t PitchInView(UInt_t plane,
232  Double_t phi,
233  Double_t theta) const;
234 
235  void GetDirectionCosines(Double_t phi,
236  Double_t theta,
237  Double_t *dirs) const;
238 
239  //interface without average Hit
240  void SelectLocalHitlist(const std::vector<util::PxHit> &hitlist,
241  std::vector <const util::PxHit*> &hitlistlocal,
242  util::PxPoint &startHit,
243  Double_t& linearlimit,
244  Double_t& ortlimit,
245  Double_t& lineslopetest);
246 
247  void SelectLocalHitlist(const std::vector<util::PxHit> &hitlist,
248  std::vector <const util::PxHit*> &hitlistlocal,
249  util::PxPoint &startHit,
250  Double_t& linearlimit,
251  Double_t& ortlimit,
252  Double_t& lineslopetest,
253  util::PxHit &averageHit);
254 
255  void SelectLocalHitlistIndex(const std::vector<util::PxHit> &hitlist,
256  std::vector <unsigned int> &hitlistlocal_index,
257  util::PxPoint &startHit,
258  Double_t& linearlimit,
259  Double_t& ortlimit,
260  Double_t& lineslopetest);
261 
262 
263  void SelectPolygonHitList(const std::vector<util::PxHit> &hitlist,
264  std::vector <const util::PxHit*> &hitlistlocal);
265 
266  std::vector<size_t> PolyOverlap( std::vector<const util::PxHit*> ordered_hits,
267  std::vector<size_t> candidate_polygon);
268 
269  bool Clockwise(double Ax, double Ay, double Bx, double By,
270  double Cx, double Cy);
271 
272  Double_t TimeToCm() const {return fTimetoCm;}
273  Double_t WireToCm() const {return fWiretoCm;}
274  Double_t WireTimeToCmCm() const {return fWireTimetoCmCm;}
275  UInt_t Nplanes() const { return fNPlanes; }
276 
277  private:
278 
279  /*
280  larutil::Geometry* geom;
281  larutil::DetectorProperties* detp;
282  */
283 
286  /*
287  art::ServiceHandle<detinfo::DetectorPropertiesService> detp;
288  art::ServiceHandle<detinfo::LArPropertiesService> larp;
289  */
290 
291  std::vector< Double_t > vertangle; //angle wrt to vertical
292  Double_t fWirePitch;
293  Double_t fTimeTick;
294  Double_t fDriftVelocity;
295  UInt_t fNPlanes;
296  Double_t fWiretoCm;
297  Double_t fTimetoCm;
298  Double_t fWireTimetoCmCm;
299 
300  }; // class GeometryUtilities
301 
302 } //namespace util
303 #endif // UTIL_GEOMETRYUTILITIES_H
Float_t x
Definition: compare.C:6
static const GeometryUtilities * GetME()
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:17
Double_t Get2DDistance(Double_t wire1, Double_t time1, Double_t wire2, Double_t time2) const
Class def header for exception classes used in GeometryUtilities.
bool Clockwise(double Ax, double Ay, double Bx, double By, double Cx, double Cy)
Double_t Get2Dangle(Double_t deltawire, Double_t deltatime) const
Declaration of signal hit object.
static GeometryUtilities * _me
Double_t TimeToCm() const
Double_t WireToCm() const
Double_t PitchInView(UInt_t plane, Double_t phi, Double_t theta) const
Double_t Get2DPitchDistance(Double_t angle, Double_t inwire, Double_t wire) const
const detinfo::DetectorProperties * detp
Access the description of detector geometry.
Int_t max
Definition: plot.C:27
Double_t Get3DSpecialCaseTheta(Int_t iplane0, Int_t iplane1, Double_t dw0, Double_t dw1) const
Double_t GetTimeTicks(Double_t x, Int_t plane) const
Description of geometry of one entire detector.
void SelectLocalHitlist(const std::vector< util::PxHit > &hitlist, std::vector< const util::PxHit * > &hitlistlocal, util::PxPoint &startHit, Double_t &linearlimit, Double_t &ortlimit, Double_t &lineslopetest)
~GeometryUtilities()
Default destructor.
std::vector< Double_t > vertangle
Definition of data types for geometry description.
Int_t GetPointOnLine(Double_t slope, Double_t intercept, Double_t wire1, Double_t time1, Double_t &wireout, Double_t &timeout) const
void SelectLocalHitlistIndex(const std::vector< util::PxHit > &hitlist, std::vector< unsigned int > &hitlistlocal_index, util::PxPoint &startHit, Double_t &linearlimit, Double_t &ortlimit, Double_t &lineslopetest)
Double_t Get2DPitchDistanceWSlope(Double_t slope, Double_t inwire, Double_t wire) const
Int_t GetYZ(const PxPoint *p0, const PxPoint *p1, Double_t *yz) const
GeometryUtilities()
Default constructor = private for singleton.
const geo::GeometryCore * geom
util::PxHit FindClosestHit(std::vector< util::PxHit > hitlist, unsigned int wirein, double timein) const
double Get2DangleFrom3D(unsigned int plane, double phi, double theta) const
Int_t GetProjectedPoint(const PxPoint *p0, const PxPoint *p1, PxPoint &pN) const
void GetDirectionCosines(Double_t phi, Double_t theta, Double_t *dirs) const
const double kINVALID_DOUBLE
PxPoint Get2DPointProjection(Double_t *xyz, Int_t plane) const
Double_t WireTimeToCmCm() const
PxPoint Get2DPointProjectionCM(std::vector< double > xyz, int plane) const
Double_t CalculatePitch(UInt_t iplane0, Double_t phi, Double_t theta) const
Int_t GetPointOnLineWSlopes(Double_t slope, Double_t intercept, Double_t ort_intercept, Double_t &wireout, Double_t &timeout) const
std::vector< size_t > PolyOverlap(std::vector< const util::PxHit * > ordered_hits, std::vector< size_t > candidate_polygon)
Double_t Get2Dslope(Double_t deltawire, Double_t deltatime) const
Int_t GetXYZ(const PxPoint *p0, const PxPoint *p1, Double_t *xyz) const
Int_t Get3DaxisN(Int_t iplane0, Int_t iplane1, Double_t omega0, Double_t omega1, Double_t &phi, Double_t &theta) const
void SelectPolygonHitList(const std::vector< util::PxHit > &hitlist, std::vector< const util::PxHit * > &hitlistlocal)
art framework interface to geometry description
Double_t CalculatePitchPolar(UInt_t iplane0, Double_t phi, Double_t theta) const
unsigned int FindClosestHitIndex(std::vector< util::PxHit > hitlist, unsigned int wirein, double timein) const