00001
00002
00003
00004
00005
00006
00007
00009 #ifndef UTIL_GEOMETRYUTILITIES_H
00010 #define UTIL_GEOMETRYUTILITIES_H
00011
00012 #include <TMath.h>
00013
00014 #include "DataFormat-TypeDef.hh"
00015 #include "Geometry.hh"
00016 #include "LArProperties.hh"
00017 #include "DetectorProperties.hh"
00018 #include "PxUtils.h"
00019 #include "time.h"
00020
00022 namespace larutil{
00023
00024 class PxPoint;
00025 class PxLine;
00026
00027 class GeometryUtilities : public larlight::larlight_base {
00028
00029 private:
00031 GeometryUtilities();
00032
00034 ~GeometryUtilities();
00035
00036 static GeometryUtilities* _me;
00037
00038 public:
00039
00041 static const GeometryUtilities* GetME(){
00042 if(!_me) _me = new GeometryUtilities;
00043 return _me;
00044 }
00045
00046 void Reconfigure();
00047
00048 Int_t Get3DaxisN(Int_t iplane0,
00049 Int_t iplane1,
00050 Double_t omega0,
00051 Double_t omega1,
00052 Double_t &phi,
00053 Double_t &theta) const;
00054
00055 Double_t CalculatePitch(UInt_t iplane0,
00056 Double_t phi,
00057 Double_t theta) const;
00058
00059 Double_t CalculatePitchPolar(UInt_t iplane0,
00060 Double_t phi,
00061 Double_t theta) const;
00062
00063 Double_t Get3DSpecialCaseTheta(Int_t iplane0,
00064 Int_t iplane1,
00065 Double_t dw0,
00066 Double_t dw1) const;
00067
00068
00069 Double_t Get2Dangle(Double_t deltawire,
00070 Double_t deltatime) const;
00071
00072
00073
00074 Double_t Get2Dangle(Double_t wireend,
00075 Double_t wirestart,
00076 Double_t timeend,
00077 Double_t timestart) const;
00078
00079
00080 double Get2Dangle(const larutil::PxPoint *endpoint,
00081 const larutil::PxPoint *startpoint) const;
00082
00083 double Get2DangleFrom3D(unsigned int plane,double phi, double theta) const;
00084
00085 double Get2DangleFrom3D(unsigned int plane,TVector3 dir_vector) const;
00086
00087
00088 Double_t Get2Dslope(Double_t deltawire,
00089 Double_t deltatime) const;
00090
00091 Double_t Get2Dslope(Double_t wireend,
00092 Double_t wirestart,
00093 Double_t timeend,
00094 Double_t timestart) const;
00095
00096 double Get2Dslope(const larutil::PxPoint *endpoint,
00097 const larutil::PxPoint *startpoint) const;
00098
00099 Double_t Get2DDistance(Double_t wire1,
00100 Double_t time1,
00101 Double_t wire2,
00102 Double_t time2) const;
00103
00104 double Get2DDistance(const larutil::PxPoint *point1,
00105 const larutil::PxPoint *point2) const;
00106
00107
00108 Double_t Get2DPitchDistance(Double_t angle,
00109 Double_t inwire,
00110 Double_t wire) const;
00111
00112 Double_t Get2DPitchDistanceWSlope(Double_t slope,
00113 Double_t inwire,
00114 Double_t wire) const;
00115
00116 Int_t GetPointOnLine(Double_t slope,
00117 Double_t intercept,
00118 Double_t wire1,
00119 Double_t time1,
00120 Double_t &wireout,
00121 Double_t &timeout) const;
00122
00123 Int_t GetPointOnLine(Double_t slope,
00124 Double_t wirestart,
00125 Double_t timestart,
00126 Double_t wire1,
00127 Double_t time1,
00128 Double_t &wireout,
00129 Double_t &timeout) const;
00130
00131 int GetPointOnLine(Double_t slope,
00132 const larutil::PxPoint *startpoint,
00133 const larutil::PxPoint *point1,
00134 larutil::PxPoint &pointout) const;
00135
00136 int GetPointOnLine(double slope,
00137 double intercept,
00138 const larutil::PxPoint *point1,
00139 larutil::PxPoint &pointout) const;
00140
00141 Int_t GetPointOnLineWSlopes(Double_t slope,
00142 Double_t intercept,
00143 Double_t ort_intercept,
00144 Double_t &wireout,
00145 Double_t &timeout) const;
00146
00147 Int_t GetPointOnLineWSlopes(double slope,
00148 double intercept,
00149 double ort_intercept,
00150 larutil::PxPoint &pointonline) const;
00151
00152
00153 const larlight::hit* FindClosestHit(const std::vector<larlight::hit*> &hitlist,
00154 UInt_t wire,
00155 Double_t time) const;
00156
00157 UInt_t FindClosestHitIndex(const std::vector<larlight::hit*> &hitlist,
00158 UInt_t wirein,
00159 Double_t timein) const;
00160
00161
00162
00163
00164 PxPoint Get2DPointProjection(Double_t *xyz,Int_t plane) const;
00165
00166 PxPoint Get2DPointProjectionCM(std::vector< double > xyz, int plane) const;
00167
00168 PxPoint Get2DPointProjectionCM(double *xyz, int plane) const;
00169
00170 PxPoint Get2DPointProjectionCM(TLorentzVector *xyz, int plane) const;
00171
00172 Double_t GetTimeTicks(Double_t x, Int_t plane) const;
00173
00174
00175 Int_t GetPlaneAndTPC(const larlight::hit* h,
00176 UInt_t &p,
00177 UInt_t &w) const;
00178
00179 Int_t GetProjectedPoint(const PxPoint *p0,
00180 const PxPoint *p1,
00181 PxPoint &pN) const;
00182
00183 Int_t GetYZ(const PxPoint *p0,
00184 const PxPoint *p1,
00185 Double_t* yz) const;
00186
00187 Double_t PitchInView(UInt_t plane,
00188 Double_t phi,
00189 Double_t theta) const;
00190
00191 void GetDirectionCosines(Double_t phi,
00192 Double_t theta,
00193 Double_t *dirs) const;
00194
00195 void SelectLocalHitlist(const std::vector<larlight::hit*>& hitlist,
00196 std::vector <larlight::hit*> &hitlistlocal_index,
00197 Double_t wire_start,
00198 Double_t time_start,
00199 Double_t linearlimit,
00200 Double_t ortlimit,
00201 Double_t lineslopetest);
00202
00203 void SelectLocalHitlist(const std::vector<larlight::hit*>& hitlist,
00204 std::vector <UInt_t> &hitlistlocal_index,
00205 Double_t wire_start,
00206 Double_t time_start,
00207 Double_t linearlimit,
00208 Double_t ortlimit,
00209 Double_t lineslopetest);
00210
00211 void SelectLocalHitlist(const std::vector<larutil::PxHit> &hitlist,
00212 std::vector <const larutil::PxHit*> &hitlistlocal,
00213 larutil::PxPoint &startHit,
00214 Double_t& linearlimit,
00215 Double_t& ortlimit,
00216 Double_t& lineslopetest,
00217 larutil::PxHit &averageHit);
00218
00219 void SelectPolygonHitList(const std::vector<larutil::PxHit> &hitlist,
00220 std::vector <const larutil::PxHit*> &hitlistlocal);
00221
00222 std::vector<size_t> PolyOverlap( std::vector<const larutil::PxHit*> ordered_hits,
00223 std::vector<size_t> candidate_polygon);
00224
00225 bool Clockwise(double Ax, double Ay, double Bx, double By,
00226 double Cx, double Cy);
00227
00228 Double_t TimeToCm() const {return fTimetoCm;}
00229 Double_t WireToCm() const {return fWiretoCm;}
00230 Double_t WireTimeToCmCm() const {return fWireTimetoCmCm;}
00231
00232 private:
00233
00234 larutil::Geometry* geom;
00235 larutil::DetectorProperties* detp;
00236 larutil::LArProperties* larp;
00237
00238 std::vector< Double_t > vertangle;
00239 Double_t fWirePitch;
00240 Double_t fTimeTick;
00241 Double_t fDriftVelocity;
00242 UInt_t fNPlanes;
00243 Double_t fWiretoCm;
00244 Double_t fTimetoCm;
00245 Double_t fWireTimetoCmCm;
00246
00247 };
00248
00249 }
00250 #endif // UTIL_DETECTOR_PROPERTIES_H