LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
Utilities.h
Go to the documentation of this file.
1 
12 #ifndef Utilities_h
13 #define Utilities_h
14 
17 
18 #include <functional>
19 
20 #include "TVector2.h"
21 #include "TVector3.h"
22 
23 #include "Math/GenVector/DisplacementVector2D.h"
24 #include "Math/GenVector/DisplacementVector3D.h"
25 
26 namespace pma
27 {
28  typedef ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D<double> > Vector2D;
30 
31  typedef std::map< size_t, std::vector<double> > dedx_map;
32 
33  class Hit3D;
34  class TrkCandidate;
35  class bSegmentProjLess;
36  class bDistCenterLess2D;
37  class bDistCenterLess3D;
39  struct bTrajectory3DDistLess;
40  struct bTrack3DLonger;
41 
42  double Dist2(const TVector2 & v1, const TVector2 & v2);
43  double Dist2(const Vector2D & v1, const Vector2D & v2);
44 
45  double Dist2(const TVector3 & v1, const TVector3 & v2);
46  double Dist2(const Vector3D & v1, const Vector3D & v2);
47 
48  size_t GetHitsCount(const std::vector< pma::Hit3D* >& hits, unsigned int view);
49  double GetSummedADC(const std::vector< pma::Hit3D* >& hits, unsigned int view = geo::kUnknown);
50  double GetSummedAmpl(const std::vector< pma::Hit3D* >& hits, unsigned int view = geo::kUnknown);
51 
52  double GetHitsRadius3D(const std::vector< pma::Hit3D* >& hits, bool exact = false);
53  double GetHitsRadius2D(const std::vector< pma::Hit3D* >& hits, bool exact = false);
54 
55  double GetSegmentProjVector(const TVector2& p, const TVector2& p0, const TVector2& p1);
56  double GetSegmentProjVector(const Vector2D& p, const Vector2D& p0, const Vector2D& p1);
57 
58  double GetSegmentProjVector(const TVector3& p, const TVector3& p0, const TVector3& p1);
59  double GetSegmentProjVector(const Vector3D& p, const Vector3D& p0, const Vector3D& p1);
60 
61  TVector2 GetProjectionToSegment(const TVector2& p, const TVector2& p0, const TVector2& p1);
62  TVector3 GetProjectionToSegment(const TVector3& p, const TVector3& p0, const TVector3& p1);
63 
64  double SolveLeastSquares3D(const std::vector< std::pair<TVector3, TVector3> >& lines, TVector3& result);
65 
66  TVector2 GetProjectionToPlane(const TVector3& p, unsigned int plane, unsigned int tpc, unsigned int cryo);
67  TVector2 GetVectorProjectionToPlane(const TVector3& v, unsigned int plane, unsigned int tpc, unsigned int cryo);
68  TVector2 WireDriftToCm(unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo);
69  TVector2 CmToWireDrift(float xw, float yd, unsigned int plane, unsigned int tpc, unsigned int cryo);
70 }
71 
72 
74  public std::binary_function<pma::Hit3D*, pma::Hit3D*, bool>
75 {
77 };
78 
80  public std::binary_function<pma::Hit3D*, pma::Hit3D*, bool>
81 {
83 };
84 
86  public std::binary_function<const pma::TrkCandidate &, const pma::TrkCandidate &, bool>
87 {
88  bool operator() (const pma::TrkCandidate & t1, const pma::TrkCandidate & t2);
89 };
90 
92  public std::binary_function<TVector3*, TVector3*, bool>
93 {
94 public:
95  bSegmentProjLess(const TVector3& s0, const TVector3& s1);
96 
97  bool operator() (TVector3* p1, TVector3* p2)
98  {
99  if (p1 && p2)
100  {
101  double b1 = pma::GetSegmentProjVector(*p1, segStart, segStop);
102  double b2 = pma::GetSegmentProjVector(*p1, segStart, segStop);
103  return b1 < b2;
104  }
105  else return false;
106  }
107 
108 private:
109  TVector3 segStart, segStop;
110 };
111 
113  public std::binary_function<TVector2, TVector2, bool>
114 {
115 public:
116  bDistCenterLess2D(const TVector2& c) : center(c) {}
117 
118  bool operator() (TVector2 p1, TVector2 p2)
119  {
120  double b1 = pma::Dist2(p1, center);
121  double b2 = pma::Dist2(p2, center);
122  return b1 < b2;
123  }
124 
125 private:
126  TVector2 center;
127 };
128 
130  public std::binary_function<TVector3, TVector3, bool>
131 {
132 public:
133  bDistCenterLess3D(const TVector3& c) : center(c) {}
134 
135  bool operator() (TVector3 p1, TVector3 p2)
136  {
137  double b1 = pma::Dist2(p1, center);
138  double b2 = pma::Dist2(p2, center);
139  return b1 < b2;
140  }
141 
142 private:
143  TVector3 center;
144 };
145 
146 #endif
147 
double GetSummedAmpl(const std::vector< pma::Hit3D * > &hits, unsigned int view=geo::kUnknown)
Definition: Utilities.cxx:58
TTree * t1
Definition: plottest35.C:26
double GetHitsRadius2D(const std::vector< pma::Hit3D * > &hits, bool exact=false)
Definition: Utilities.cxx:89
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
Unknown view.
Definition: geo_types.h:83
bDistCenterLess3D(const TVector3 &c)
Definition: Utilities.h:133
double GetHitsRadius3D(const std::vector< pma::Hit3D * > &hits, bool exact=false)
Definition: Utilities.cxx:67
recob::tracking::Vector_t Vector3D
Definition: Utilities.h:29
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void hits()
Definition: readHits.C:15
size_t GetHitsCount(const std::vector< pma::Hit3D * > &hits, unsigned int view)
Definition: Utilities.cxx:41
TVector2 GetProjectionToSegment(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:167
geo::Vector_t Vector_t
Type for representation of momenta in 3D space.
Definition: TrackingTypes.h:23
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
Definition: Utilities.h:28
bDistCenterLess2D(const TVector2 &c)
Definition: Utilities.h:116
TVector2 GetVectorProjectionToPlane(const TVector3 &v, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:298
double SolveLeastSquares3D(const std::vector< std::pair< TVector3, TVector3 > > &lines, TVector3 &result)
Definition: Utilities.cxx:187
TTree * t2
Definition: plottest35.C:36
TH1F * h2
Definition: plot.C:46
bool operator()(pma::Hit3D *h1, pma::Hit3D *h2)
Definition: Utilities.cxx:329
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:111
TVector2 WireDriftToCm(unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:307
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:291
TH1F * h1
Definition: plot.C:43
TVector2 CmToWireDrift(float xw, float yd, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:318
std::map< size_t, std::vector< double > > dedx_map
Definition: Utilities.h:31
double GetSummedADC(const std::vector< pma::Hit3D * > &hits, unsigned int view=geo::kUnknown)
Definition: Utilities.cxx:49
art framework interface to geometry description