LArSoft  v10_04_05
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 
16 
17 #include "TVector3.h"
18 
19 #include "PxUtils.h"
20 
21 #include <limits>
22 #include <vector>
23 
24 class TLorentzVector;
25 
26 namespace detinfo {
27  class DetectorClocksData;
28  class DetectorPropertiesData;
29 }
30 
32 namespace util {
33 
34  constexpr double kINVALID_DOUBLE = std::numeric_limits<double>::max();
35 
37  public:
39  geo::WireReadoutGeom const& wireReadoutGeom,
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  PxPoint Get2DPointProjection(geo::Point_t const& xyz, geo::PlaneID const& planeID) const;
117  PxPoint Get2DPointProjectionCM(geo::Point_t xyz, geo::PlaneID const& planeID) const;
118 
119  double GetTimeTicks(double x, unsigned int plane) const;
120 
121  int GetProjectedPoint(const PxPoint* p0, const PxPoint* p1, PxPoint& pN) const;
122 
123  PxHit FindClosestHit(std::vector<PxHit> const& hitlist,
124  unsigned int wirein,
125  double timein) const;
126 
127  unsigned int FindClosestHitIndex(std::vector<PxHit> const& hitlist,
128  unsigned int wirein,
129  double timein) const;
130 
131  int GetYZ(const PxPoint* p0, const PxPoint* p1, double* yz) const;
132 
133  int GetXYZ(const PxPoint* p0, const PxPoint* p1, double* xyz) const;
134 
135  double PitchInView(unsigned int plane, double phi, double theta) const;
136 
137  void GetDirectionCosines(double phi, double theta, double* dirs) const;
138 
139  // interface without average Hit
140  void SelectLocalHitlist(const std::vector<PxHit>& hitlist,
141  std::vector<const PxHit*>& hitlistlocal,
142  PxPoint& startHit,
143  double& linearlimit,
144  double& ortlimit,
145  double& lineslopetest) const;
146 
147  void SelectLocalHitlist(const std::vector<PxHit>& hitlist,
148  std::vector<const PxHit*>& hitlistlocal,
149  PxPoint& startHit,
150  double& linearlimit,
151  double& ortlimit,
152  double& lineslopetest,
153  PxHit& averageHit) const;
154 
155  void SelectLocalHitlistIndex(const std::vector<PxHit>& hitlist,
156  std::vector<unsigned int>& hitlistlocal_index,
157  PxPoint& startHit,
158  double& linearlimit,
159  double& ortlimit,
160  double& lineslopetest) const;
161 
162  void SelectPolygonHitList(const std::vector<PxHit>& hitlist,
163  std::vector<const PxHit*>& hitlistlocal) const;
164 
165  std::vector<size_t> PolyOverlap(std::vector<const PxHit*> ordered_hits,
166  std::vector<size_t> candidate_polygon) const;
167 
168  bool Clockwise(double Ax, double Ay, double Bx, double By, double Cx, double Cy) const;
169 
170  double TimeToCm() const { return fTimetoCm; }
171  double WireToCm() const { return fWiretoCm; }
172  double WireTimeToCmCm() const { return fWireTimetoCmCm; }
173  unsigned int Nplanes() const { return fNPlanes; }
174 
175  private:
180 
181  std::vector<double> vertangle; // angle wrt to vertical
182  double fWirePitch;
183  double fTimeTick;
185  unsigned int fNPlanes;
186  double fWiretoCm;
187  double fTimetoCm;
189  }; // class GeometryUtilities
190 
191 } // namespace util
192 #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
The data type to uniquely identify a Plane.
Definition: geo_types.h:364
double WireTimeToCmCm() 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
geo::WireReadoutGeom const & fWireReadoutGeom
Definitions of geometry vector data types.
Interface for a class providing readout channel mapping to geometry.
Utilities to extend the interface of geometry vectors.This library provides facilities that can be us...
geo::GeometryCore const & fGeom
General LArSoft Utilities.
Description of the physical geometry of one entire detector.
Definition: GeometryCore.h:91
Definition of data types for geometry description.
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