LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PFPUtils.h
Go to the documentation of this file.
1 //
3 //
4 // PFParticle utilities
5 //
6 // Bruce Baller
7 //
9 #ifndef TRAJCLUSTERALGSPTUTILS_H
10 #define TRAJCLUSTERALGSPTUTILS_H
11 
12 // C/C++ standard libraries
13 #include <string>
14 
15 // LArSoft libraries
17 namespace detinfo {
18  class DetectorClocksData;
19  class DetectorPropertiesData;
20 }
21 namespace geo {
22  struct TPCID;
23 }
24 
25 namespace tca {
26 
27  void StitchPFPs();
28  void FindPFParticles(detinfo::DetectorClocksData const& clockData,
29  detinfo::DetectorPropertiesData const& detProp,
30  TCSlice& slc);
31  void MakePFParticles(detinfo::DetectorClocksData const& clockData,
32  detinfo::DetectorPropertiesData const& detProp,
33  TCSlice& slc,
34  std::vector<MatchStruct> matVec,
35  unsigned short matVec_Iter);
36  bool ReconcileTPs(TCSlice& slc, PFPStruct& pfp, bool prt);
37  void ReconcileTPs(TCSlice& slc);
38  void MakePFPTjs(TCSlice& slc);
39  void FillWireIntersections(TCSlice& slc);
40  bool TCIntersectionPoint(unsigned int wir1,
41  unsigned int wir2,
42  unsigned int pln1,
43  unsigned int pln2,
44  float& y,
45  float& z);
46  void Match3Planes(TCSlice& slc, std::vector<MatchStruct>& matVec);
47  bool SptInTPC(const std::array<unsigned int, 3>& sptHits, unsigned int tpc);
48  void Match2Planes(TCSlice& slc, std::vector<MatchStruct>& matVec);
49  bool Update(detinfo::DetectorPropertiesData const& detProp, const TCSlice& slc, PFPStruct& pfp);
50  bool ReSection(detinfo::DetectorPropertiesData const& detProp,
51  const TCSlice& slc,
52  PFPStruct& pfp,
53  bool prt);
54  void CountBadPoints(const TCSlice& slc,
55  const PFPStruct& pfp,
56  unsigned short fromPt,
57  unsigned short toPt,
58  unsigned short& nBadPts,
59  unsigned short& firstBadPt);
60  bool CanSection(const TCSlice& slc, const PFPStruct& pfp);
61  unsigned short Find3DRecoRange(const TCSlice& slc,
62  const PFPStruct& pfp,
63  unsigned short fromPt,
64  unsigned short min2DPts,
65  short dir);
66  void GetRange(const PFPStruct& pfp,
67  unsigned short sfIndex,
68  unsigned short& fromPt,
69  unsigned short& npts);
70  bool FitSection(detinfo::DetectorPropertiesData const& detProp,
71  const TCSlice& slc,
72  PFPStruct& pfp,
73  unsigned short sfIndex);
74  SectionFit FitTP3Ds(detinfo::DetectorPropertiesData const& detProp,
75  const TCSlice& slc,
76  const std::vector<TP3D>& tp3ds,
77  unsigned short fromPt,
78  short fitDir,
79  unsigned short nPtsFit);
80  bool FitTP3Ds(detinfo::DetectorPropertiesData const& detProp,
81  const TCSlice& slc,
82  PFPStruct& pfp,
83  unsigned short fromPt,
84  unsigned short npts,
85  unsigned short sfIndex);
86  void ReconcileVertices(TCSlice& slc, PFPStruct& pfp, bool prt);
87  void FillGaps3D(detinfo::DetectorClocksData const& clockData,
88  detinfo::DetectorPropertiesData const& detProp,
89  TCSlice& slc,
90  PFPStruct& pfp,
91  bool prt);
93  const TCSlice& slc,
94  const PFPStruct& pfp);
95  void AddPointsInRange(detinfo::DetectorClocksData const& clockData,
96  detinfo::DetectorPropertiesData const& detProp,
97  TCSlice& slc,
98  PFPStruct& pfp,
99  unsigned short fromPt,
100  unsigned short toPt,
101  CTP_t inCTP,
102  float maxPull,
103  unsigned short& nWires,
104  unsigned short& nAdd,
105  bool prt);
106  unsigned short InsertTP3D(PFPStruct& pfp, TP3D& tp3d);
107  bool SortSection(PFPStruct& pfp, unsigned short sectionFitIndex);
108  void Recover(detinfo::DetectorPropertiesData const& detProp,
109  TCSlice& slc,
110  PFPStruct& pfp,
111  bool prt);
112  bool MakeTP3Ds(detinfo::DetectorPropertiesData const& detProp,
113  TCSlice& slc,
114  PFPStruct& pfp,
115  bool prt);
117  TCSlice& slc,
118  PFPStruct& pfp,
119  bool prt);
120  void Reverse(PFPStruct& pfp);
121  void FillmAllTraj(detinfo::DetectorPropertiesData const& detProp, TCSlice& slc);
122  TP3D MakeTP3D(detinfo::DetectorPropertiesData const& detProp,
123  const TrajPoint& itp,
124  const TrajPoint& jtp);
125  double DeltaAngle(const Vector3_t v1, const Vector3_t v2);
126  inline double DotProd(const Vector3_t& v1, const Vector3_t& v2)
127  {
128  return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
129  }
130  Vector3_t PointDirection(const Point3_t p1, const Point3_t p2);
131  double PosSep(const Point3_t& pos1, const Point3_t& pos2);
132  double PosSep2(const Point3_t& pos1, const Point3_t& pos2);
133  bool SetMag(Vector3_t& v1, double mag);
134  void FilldEdx(detinfo::DetectorClocksData const& clockData,
135  detinfo::DetectorPropertiesData const& detProp,
136  const TCSlice& slc,
137  PFPStruct& pfp);
138  float dEdx(detinfo::DetectorClocksData const& clockData,
139  detinfo::DetectorPropertiesData const& detProp,
140  const TCSlice& slc,
141  TP3D& tp3d);
142  void Average_dEdX(detinfo::DetectorClocksData const& clockData,
143  detinfo::DetectorPropertiesData const& detProp,
144  const TCSlice& slc,
145  PFPStruct& pfp,
146  float& dEdXAve,
147  float& dEdXRms);
149  const TCSlice& slc,
150  int tjID,
151  unsigned short tjPt);
152  bool SetSection(detinfo::DetectorPropertiesData const& detProp, PFPStruct& pfp, TP3D& tp3d);
153  float PointPull(const TP3D& tp3d);
154  PFPStruct CreatePFP(const TCSlice& slc);
155  void PFPVertexCheck(TCSlice& tcs);
156  void DefinePFPParents(TCSlice& slc);
157  bool StorePFP(TCSlice& slc, PFPStruct& pfp);
158  bool InsideFV(const TCSlice& slc, const PFPStruct& pfp, unsigned short end);
159  bool InsideTPC(const Point3_t& pos, geo::TPCID& inTPCID);
160  void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t& alongTrans);
161  bool PointDirIntersect(Point3_t p1,
162  Vector3_t p1Dir,
163  Point3_t p2,
164  Vector3_t p2Dir,
165  Point3_t& intersect,
166  float& doca);
167  bool LineLineIntersect(Point3_t p1,
168  Point3_t p2,
169  Point3_t p3,
170  Point3_t p4,
171  Point3_t& intersect,
172  float& doca);
173  float ChgFracBetween(detinfo::DetectorPropertiesData const& detProp,
174  const TCSlice& slc,
175  Point3_t pos1,
176  Point3_t pos2);
177  float ChgFracNearEnd(detinfo::DetectorPropertiesData const& detProp,
178  const TCSlice& slc,
179  const PFPStruct& pfp,
180  unsigned short end);
181  Point3_t PosAtEnd(const PFPStruct& pfp, unsigned short end);
182  Vector3_t DirAtEnd(const PFPStruct& pfp, unsigned short end);
183  float Length(const PFPStruct& pfp);
184  bool SectionStartEnd(const PFPStruct& pfp,
185  unsigned short sfIndex,
186  unsigned short& startPt,
187  unsigned short& endPt);
188  unsigned short FarEnd(const PFPStruct& pfp, const Point3_t& pos);
189  int PDGCodeVote(detinfo::DetectorClocksData const& clockData,
190  detinfo::DetectorPropertiesData const& detProp,
191  const TCSlice& slc,
192  PFPStruct& pfp);
193  void PrintTP3Ds(detinfo::DetectorClocksData const& clockData,
194  detinfo::DetectorPropertiesData const& detProp,
195  std::string someText,
196  const TCSlice& slc,
197  const PFPStruct& pfp,
198  short printPts);
199 } // namespace tca
200 
201 #endif // ifndef TRAJCLUSTERALGSPTUTILS_H
float Length(const PFPStruct &pfp)
Definition: PFPUtils.cxx:3269
void Average_dEdX(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp, float &dEdXAve, float &dEdXRms)
Definition: PFPUtils.cxx:2639
void MakePFParticles(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, std::vector< MatchStruct > matVec, unsigned short matVec_Iter)
Definition: PFPUtils.cxx:265
bool ReconcileTPs(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:423
bool InsideFV(const TCSlice &slc, const PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:3022
bool InsideTPC(const Point3_t &pos, geo::TPCID &inTPCID)
Definition: PFPUtils.cxx:3048
std::array< double, 3 > Point3_t
Definition: DataStructs.h:41
bool SortSection(PFPStruct &pfp, unsigned short sfIndex)
Definition: PFPUtils.cxx:2005
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:3069
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
bool LineLineIntersect(Point3_t p1, Point3_t p2, Point3_t p3, Point3_t p4, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:3103
PFPStruct CreatePFP(const TCSlice &slc)
Definition: PFPUtils.cxx:2805
Point3_t PosAtEnd(const PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:3259
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:2535
void Match2Planes(TCSlice &slc, std::vector< MatchStruct > &matVec)
Definition: PFPUtils.cxx:942
bool CanSection(const TCSlice &slc, const PFPStruct &pfp)
Definition: PFPUtils.cxx:1330
void FilldEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:2587
void ReconcileVertices(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1632
bool Update(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:1055
void MakePFPTjs(TCSlice &slc)
Definition: PFPUtils.cxx:507
unsigned short Find3DRecoRange(const TCSlice &slc, const PFPStruct &pfp, unsigned short fromPt, unsigned short min2DPts, short dir)
Definition: PFPUtils.cxx:1345
bool MakeSmallAnglePFP(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2195
void AddPointsInRange(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, unsigned short fromPt, unsigned short toPt, CTP_t inCTP, float maxPull, unsigned short &nWires, unsigned short &nAdd, bool prt)
Definition: PFPUtils.cxx:1817
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void PFPVertexCheck(TCSlice &slc)
Definition: PFPUtils.cxx:2825
void FillGaps3D(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1726
std::array< float, 2 > Point2_t
Definition: DataStructs.h:43
int PDGCodeVote(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:3314
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:2542
void FillWireIntersections(TCSlice &slc)
Definition: PFPUtils.cxx:606
bool MakeTP3Ds(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2103
void Match3Planes(TCSlice &slc, std::vector< MatchStruct > &matVec)
Definition: PFPUtils.cxx:812
bool TCIntersectionPoint(unsigned int wir1, unsigned int wir2, unsigned int pln1, unsigned int pln2, float &y, float &z)
Definition: PFPUtils.cxx:670
bool FitSection(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp, unsigned short sfIndex)
Definition: PFPUtils.cxx:1398
float ChgFracBetween(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, Point3_t pos1, Point3_t pos2)
Definition: PFPUtils.cxx:3166
void CountBadPoints(const TCSlice &slc, const PFPStruct &pfp, unsigned short fromPt, unsigned short toPt, unsigned short &nBadPts, unsigned short &firstBadPt)
Definition: PFPUtils.cxx:1297
bool ReSection(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1104
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2564
General LArSoft Utilities.
bool SectionStartEnd(const PFPStruct &pfp, unsigned short sfIndex, unsigned short &startPt, unsigned short &endPt)
Definition: PFPUtils.cxx:3276
bool PointDirIntersect(Point3_t p1, Vector3_t p1Dir, Point3_t p2, Vector3_t p2Dir, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:3086
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:2574
unsigned short FarEnd(const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:3302
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
void GetRange(const PFPStruct &pfp, unsigned short sfIndex, unsigned short &fromPt, unsigned short &npts)
Definition: PFPUtils.cxx:1377
unsigned short InsertTP3D(PFPStruct &pfp, TP3D &tp3d)
Definition: PFPUtils.cxx:1967
SectionFit FitTP3Ds(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const std::vector< TP3D > &tp3ds, unsigned short fromPt, short fitDir, unsigned short nPtsFit)
Definition: PFPUtils.cxx:1428
void Recover(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2065
TP3D CreateTP3D(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, int tjID, unsigned short tpIndex)
Definition: PFPUtils.cxx:2710
bool ValidTwoPlaneMatch(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const PFPStruct &pfp)
Definition: PFPUtils.cxx:1777
double DotProd(const Vector3_t &v1, const Vector3_t &v2)
Definition: PFPUtils.h:126
unsigned int CTP_t
Definition: DataStructs.h:47
void FillmAllTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc)
Definition: PFPUtils.cxx:2375
Contains all timing reference information for the detector.
TDirectory * dir
Definition: macro.C:5
TP3D MakeTP3D(detinfo::DetectorPropertiesData const &detProp, const TrajPoint &itp, const TrajPoint &jtp)
Definition: PFPUtils.cxx:2441
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2558
float PointPull(const TP3D &tp3d)
Definition: PFPUtils.cxx:2797
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:42
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void FindPFParticles(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TCSlice &slc)
Definition: PFPUtils.cxx:189
bool StorePFP(TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:2982
float ChgFracNearEnd(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:3200
void PrintTP3Ds(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::string someText, const TCSlice &slc, const PFPStruct &pfp, short printPts)
Definition: PFPUtils.cxx:3358
Vector3_t DirAtEnd(const PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:3251
Namespace collecting geometry-related classes utilities.
void StitchPFPs()
Definition: PFPUtils.cxx:41
bool SetSection(detinfo::DetectorPropertiesData const &detProp, PFPStruct &pfp, TP3D &tp3d)
Definition: PFPUtils.cxx:2756
void DefinePFPParents(TCSlice &slc)
Definition: PFPUtils.cxx:2863
bool SptInTPC(const std::array< unsigned int, 3 > &sptHits, unsigned int tpc)
Definition: PFPUtils.cxx:792
void Reverse(PFPStruct &pfp)
Definition: PFPUtils.cxx:2354