LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PFPUtils.h
Go to the documentation of this file.
1 
3 //
4 //
5 // PFParticle utilities
6 //
7 // Bruce Baller
8 //
10 #ifndef TRAJCLUSTERALGSPTUTILS_H
11 #define TRAJCLUSTERALGSPTUTILS_H
12 
13 // C/C++ standard libraries
14 #include <array>
15 #include <vector>
16 #include <bitset>
17 #include <utility> // std::pair<>
18 #include <cmath>
19 #include <iostream>
20 #include <iomanip>
21 #include <algorithm>
22 
23 #include "TVectorD.h"
24 #include "TDecompSVD.h"
25 #include "TMatrixD.h"
26 
28 
29 // LArSoft libraries
34 
35 namespace tca {
36 
37 
38  void UpdateMatchStructs(TjStuff& tjs, int oldTj, int newTj);
39  void UpdateTp3s(TjStuff& tjs, PFPStruct& pfp, int oldTj, int newTj);
40  void FillmAllTraj(TjStuff& tjs, const geo::TPCID& tpcid);
41  bool SetStart(TjStuff& tjs, PFPStruct& pfp, bool prt);
42  void FollowTp3s(TjStuff& tjs, PFPStruct& pfp, bool prt);
43  bool FitTp3s(TjStuff& tjs, const std::vector<TrajPoint3>& tp3s, Point3_t& pos, Vector3_t& dir, float& rCorr);
44  bool FitTp3s(TjStuff& tjs, const std::vector<TrajPoint3>& tp3s, unsigned short fromPt, unsigned short toPt, Point3_t& pos, Vector3_t& dir, float& rCorr);
45  bool FitTp3(TjStuff& tjs, TrajPoint3& tp3, const std::vector<Tj2Pt>& tj2pts);
46  void FindCompleteness(TjStuff& tjs, PFPStruct& pfp, bool doFit, bool fillTp3s, bool prt);
47  void FindMissedTjsInTp3s(TjStuff& tjs, PFPStruct& pfp, std::vector<int>& missTjs, std::vector<float>& missFrac);
48  bool SharesHighScoreVx(TjStuff& tjs, const PFPStruct& pfp, const Trajectory& tj);
49  void Fit3D(unsigned short mode, Point3_t point, Vector3_t dir, Point3_t& fitPos, Vector3_t& fitDir);
50 // bool CheckAndMerge(TjStuff& tjs, PFPStruct& pfp, bool prt);
51  float AspectRatio(TjStuff& tjs, std::vector<int>& tjids, CTP_t inCTP);
52  unsigned short WiresSkippedInCTP(TjStuff& tjs, std::vector<int>& tjids, CTP_t inCTP);
53  float LengthInCTP(TjStuff& tjs, std::vector<int>& tjids, CTP_t inCTP);
54  bool AddMissedTj(TjStuff& tjs, PFPStruct& pfp, unsigned short itj, bool looseCuts, bool prt);
55  void CleanTjs(TjStuff& tjs, PFPStruct& pfp, bool prt);
56  bool MergePFPTjs(TjStuff& tjs, PFPStruct& pfp, bool prt);
57  void FindXMatches(TjStuff& tjs, unsigned short numPlanes, short maxScore, std::vector<MatchStruct>& matVec, bool prt);
58  bool MakeTp3(TjStuff& tjs, const TrajPoint& itp, const TrajPoint& jtp, TrajPoint3& tp3, bool findDirection);
59  double DeltaAngle(const Vector3_t v1, const Vector3_t v2);
60  inline double DotProd(const Vector3_t& v1, const Vector3_t& v2) {return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; }
61  Vector3_t PointDirection(const Point3_t p1, const Point3_t p2);
62  double PosSep(const Point3_t& pos1, const Point3_t& pos2);
63  double PosSep2(const Point3_t& pos1, const Point3_t& pos2);
64  bool SetMag(Vector3_t& v1, double mag);
65  void FilldEdx(TjStuff& tjs, PFPStruct& pfp);
66  void FilldEdx(TjStuff& tjs, TrajPoint3& tp3);
67  float PFPDOCA(const PFPStruct& pfp1, const PFPStruct& pfp2, unsigned short& close1, unsigned short& close2);
68  bool Split3DKink(TjStuff& tjs, PFPStruct& pfp, double sep, bool prt);
69  std::vector<unsigned short> FindKinks(const TjStuff& tjs, PFPStruct& pfp, double sep, bool prt);
70  double KinkAngle(const TjStuff& tjs, const std::vector<TrajPoint3>& tp3s, unsigned short atPt, double sep);
71  PFPStruct CreatePFP(const TjStuff& tjs, const geo::TPCID& tpcid);
72  void FindPFParticles(TjStuff& tjs, const geo::TPCID& tpcid, bool prt);
73  bool DefinePFP(std::string inFcnLabel, TjStuff& tjs, PFPStruct& pfp, bool prt);
74  bool PFPVxTjOK(TjStuff& tjs, PFPStruct& pfp, bool prt);
75  void PFPVertexCheck(TjStuff& tjs);
76  bool AnalyzePFP(TjStuff& tjs, PFPStruct& pfp, bool prt);
77  void DefinePFPParents(TjStuff& tjs, const geo::TPCID& tpcid, bool prt);
78  void DefinePFPParentsTestBeam(TjStuff& tjs, const geo::TPCID& tpcid, bool prt);
79  bool StorePFP(TjStuff& tjs, PFPStruct& pfp);
80  bool InsideTPC(const TjStuff& tjs, Point3_t& pos, geo::TPCID& inTPCID);
81  void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t& alongTrans);
82  bool PointDirIntersect(Point3_t p1, Vector3_t p1Dir, Point3_t p2, Vector3_t p2Dir, Point3_t& intersect, float& doca);
83  bool LineLineIntersect(Point3_t p1, Point3_t p2, Point3_t p3, Point3_t p4, Point3_t& intersect, float& doca);
84  void ReversePFP(TjStuff& tjs, PFPStruct& pfp);
85  float ChgFracBetween(TjStuff& tjs, Point3_t pos1, Point3_t pos2, geo::TPCID tpcid);
86  float ChgFracNearEnd(TjStuff& tjs, PFPStruct& pfp, unsigned short end);
87  unsigned short FarEnd(const TjStuff& tjs, const PFPStruct& pfp, const Point3_t& pos);
88  void PrintTp3(std::string fcnLabel, const TjStuff& tjs, const TrajPoint3& tp3);
89  void PrintTp3s(std::string someText, const TjStuff& tjs, const PFPStruct& pfp, short printPts);
90 
91 } // namespace tca
92 
93 #endif // ifndef TRAJCLUSTERALGSPTUTILS_H
bool SetStart(TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:207
void PrintTp3s(std::string someText, const TjStuff &tjs, const PFPStruct &pfp, short printPts)
Definition: PFPUtils.cxx:2961
void Fit3D(unsigned short mode, Point3_t point, Vector3_t dir, Point3_t &fitPos, Vector3_t &fitDir)
Definition: PFPUtils.cxx:899
unsigned short WiresSkippedInCTP(TjStuff &tjs, std::vector< int > &tjids, CTP_t inCTP)
Definition: PFPUtils.cxx:1060
void FindMissedTjsInTp3s(TjStuff &tjs, PFPStruct &pfp, std::vector< int > &missTjs, std::vector< float > &missFrac)
Definition: PFPUtils.cxx:807
bool AddMissedTj(TjStuff &tjs, PFPStruct &pfp, unsigned short itj, bool looseCuts, bool prt)
Definition: PFPUtils.cxx:1130
void FollowTp3s(TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:261
std::array< double, 3 > Point3_t
Definition: DataStructs.h:35
bool AnalyzePFP(TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2339
float ChgFracBetween(TjStuff &tjs, Point3_t pos1, Point3_t pos2, geo::TPCID tpcid)
Definition: PFPUtils.cxx:2860
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:2751
float PFPDOCA(const PFPStruct &pfp1, const PFPStruct &pfp2, unsigned short &close1, unsigned short &close2)
Definition: PFPUtils.cxx:1761
bool LineLineIntersect(Point3_t p1, Point3_t p2, Point3_t p3, Point3_t p4, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:2781
bool DefinePFP(std::string inFcnLabel, TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2159
void ReversePFP(TjStuff &tjs, PFPStruct &pfp)
Definition: PFPUtils.cxx:2837
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:1607
bool MakeTp3(TjStuff &tjs, const TrajPoint &itp, const TrajPoint &jtp, TrajPoint3 &tp3, bool findDirection)
Definition: PFPUtils.cxx:1526
bool SharesHighScoreVx(TjStuff &tjs, const PFPStruct &pfp, const Trajectory &tj)
Definition: PFPUtils.cxx:883
void UpdateTp3s(TjStuff &tjs, PFPStruct &pfp, int oldTj, int newTj)
Definition: PFPUtils.cxx:85
unsigned short FarEnd(const TjStuff &tjs, const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:2936
void FindPFParticles(TjStuff &tjs, const geo::TPCID &tpcid, bool prt)
Definition: PFPUtils.cxx:1968
std::array< float, 2 > Point2_t
Definition: DataStructs.h:37
void DefinePFPParentsTestBeam(TjStuff &tjs, const geo::TPCID &tpcid, bool prt)
Definition: PFPUtils.cxx:2572
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:1614
bool FitTp3(TjStuff &tjs, TrajPoint3 &tp3, const std::vector< Tj2Pt > &tj2pts)
Definition: PFPUtils.cxx:502
void UpdateMatchStructs(TjStuff &tjs, int oldTj, int newTj)
Definition: PFPUtils.cxx:16
float AspectRatio(TjStuff &tjs, std::vector< int > &tjids, CTP_t inCTP)
void PFPVertexCheck(TjStuff &tjs)
Definition: PFPUtils.cxx:2418
void FillmAllTraj(TjStuff &tjs, const geo::TPCID &tpcid)
Definition: PFPUtils.cxx:127
void CleanTjs(TjStuff &tjs, PFPStruct &pfp, bool prt)
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:1631
double KinkAngle(const TjStuff &tjs, const std::vector< TrajPoint3 > &tp3s, unsigned short atPt, double sep)
Definition: PFPUtils.cxx:1913
bool PointDirIntersect(Point3_t p1, Vector3_t p1Dir, Point3_t p2, Vector3_t p2Dir, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:2769
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
bool PFPVxTjOK(TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2283
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:1641
Definition of data types for geometry description.
float ChgFracNearEnd(TjStuff &tjs, PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:2890
void PrintTp3(std::string someText, const TjStuff &tjs, const TrajPoint3 &tp3)
Definition: PFPUtils.cxx:2945
std::vector< unsigned short > FindKinks(const TjStuff &tjs, PFPStruct &pfp, double sep, bool prt)
Definition: PFPUtils.cxx:1870
double DotProd(const Vector3_t &v1, const Vector3_t &v2)
Definition: PFPUtils.h:60
unsigned int CTP_t
Definition: DataStructs.h:41
PFPStruct CreatePFP(const TjStuff &tjs, const geo::TPCID &tpcid)
Definition: PFPUtils.cxx:1943
TDirectory * dir
Definition: macro.C:5
bool Split3DKink(TjStuff &tjs, PFPStruct &pfp, double sep, bool prt)
Definition: PFPUtils.cxx:1782
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:1625
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:36
float LengthInCTP(TjStuff &tjs, std::vector< int > &tjids, CTP_t inCTP)
Definition: PFPUtils.cxx:1106
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void FindXMatches(TjStuff &tjs, unsigned short numPlanes, short maxScore, std::vector< MatchStruct > &matVec, bool prt)
Definition: PFPUtils.cxx:1326
bool InsideTPC(const TjStuff &tjs, Point3_t &pos, geo::TPCID &inTPCID)
Definition: PFPUtils.cxx:2725
void FindCompleteness(TjStuff &tjs, PFPStruct &pfp, bool doFit, bool fillTp3s, bool prt)
Definition: PFPUtils.cxx:593
bool MergePFPTjs(TjStuff &tjs, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1174
void DefinePFPParents(TjStuff &tjs, const geo::TPCID &tpcid, bool prt)
Definition: PFPUtils.cxx:2441
bool StorePFP(TjStuff &tjs, PFPStruct &pfp)
Definition: PFPUtils.cxx:2660
bool FitTp3s(TjStuff &tjs, const std::vector< TrajPoint3 > &tp3s, Point3_t &pos, Vector3_t &dir, float &rCorr)
Definition: PFPUtils.cxx:412
void FilldEdx(TjStuff &tjs, PFPStruct &pfp)
Definition: PFPUtils.cxx:1654