LArSoft  v07_13_02
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  void StitchPFPs();
38  void UpdateMatchStructs(TCSlice& slc, int oldTj, int newTj);
39  void UpdateTp3s(TCSlice& slc, PFPStruct& pfp, int oldTj, int newTj);
40  void FillmAllTraj(TCSlice& slc);
41  bool SetStart(TCSlice& slc, PFPStruct& pfp, bool prt);
42  void FollowTp3s(TCSlice& slc, PFPStruct& pfp, bool prt);
43  bool FitTp3s(TCSlice& slc, const std::vector<TrajPoint3>& tp3s, Point3_t& pos, Vector3_t& dir, float& rCorr);
44  bool FitTp3s(TCSlice& slc, const std::vector<TrajPoint3>& tp3s, unsigned short fromPt, unsigned short toPt, Point3_t& pos, Vector3_t& dir, float& rCorr);
45  bool FitTp3(TCSlice& slc, TrajPoint3& tp3, const std::vector<Tj2Pt>& tj2pts);
46  void FindCompleteness(TCSlice& slc, PFPStruct& pfp, bool doFit, bool fillTp3s, bool prt);
47  void FindMissedTjsInTp3s(TCSlice& slc, PFPStruct& pfp, std::vector<int>& missTjs, std::vector<float>& missFrac);
48  bool SharesHighScoreVx(TCSlice& slc, 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  float AspectRatio(TCSlice& slc, std::vector<int>& tjids, CTP_t inCTP);
51  unsigned short WiresSkippedInCTP(TCSlice& slc, std::vector<int>& tjids, CTP_t inCTP);
52  float LengthInCTP(TCSlice& slc, std::vector<int>& tjids, CTP_t inCTP);
53  bool AddMissedTj(TCSlice& slc, PFPStruct& pfp, unsigned short itj, bool looseCuts, bool prt);
54  void CleanTjs(TCSlice& slc, PFPStruct& pfp, bool prt);
55  bool MergePFPTjs(TCSlice& slc, PFPStruct& pfp, bool prt);
56  void FindXMatches(TCSlice& slc, unsigned short numPlanes, short maxScore, std::vector<MatchStruct>& matVec, bool prt);
57  bool MakeTp3(TCSlice& slc, const TrajPoint& itp, const TrajPoint& jtp, TrajPoint3& tp3, bool findDirection);
58  double DeltaAngle(const Vector3_t v1, const Vector3_t v2);
59  inline double DotProd(const Vector3_t& v1, const Vector3_t& v2) {return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; }
60  Vector3_t PointDirection(const Point3_t p1, const Point3_t p2);
61  double PosSep(const Point3_t& pos1, const Point3_t& pos2);
62  double PosSep2(const Point3_t& pos1, const Point3_t& pos2);
63  bool SetMag(Vector3_t& v1, double mag);
64  void FilldEdx(TCSlice& slc, PFPStruct& pfp);
65  void FilldEdx(TCSlice& slc, TrajPoint3& tp3);
66  float PFPDOCA(const PFPStruct& pfp1, const PFPStruct& pfp2, unsigned short& close1, unsigned short& close2);
67  bool Split3DKink(TCSlice& slc, PFPStruct& pfp, double sep, bool prt);
68  std::vector<unsigned short> FindKinks(TCSlice& slc, PFPStruct& pfp, double sep, bool prt);
69  double KinkAngle(TCSlice& slc, const std::vector<TrajPoint3>& tp3s, unsigned short atPt, double sep);
71  void FindPFParticles(TCSlice& slc);
72  bool DefinePFP(std::string inFcnLabel, TCSlice& slc, PFPStruct& pfp, bool prt);
73  bool PFPVxTjOK(TCSlice& slc, PFPStruct& pfp, bool prt);
74  void PFPVertexCheck(TCSlice& tcs);
75  bool AnalyzePFP(TCSlice& slc, PFPStruct& pfp, bool prt);
76  void DefinePFPParents(TCSlice& slc, bool prt);
77  void DefinePFPParentsTestBeam(TCSlice& slc, bool prt);
78  bool StorePFP(TCSlice& slc, PFPStruct& pfp);
79  bool InsideFV(TCSlice& slc, PFPStruct& pfp, unsigned short end);
80  bool InsideTPC(const 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(TCSlice& slc, PFPStruct& pfp);
85  float ChgFracBetween(TCSlice& slc, Point3_t pos1, Point3_t pos2);
86  float ChgFracNearEnd(TCSlice& slc, PFPStruct& pfp, unsigned short end);
87  unsigned short FarEnd(TCSlice& slc, const PFPStruct& pfp, const Point3_t& pos);
88  void PrintTp3(std::string fcnLabel, TCSlice& slc, const TrajPoint3& tp3);
89  void PrintTp3s(std::string someText, TCSlice& slc, const PFPStruct& pfp, short printPts);
90 
91 } // namespace tca
92 
93 #endif // ifndef TRAJCLUSTERALGSPTUTILS_H
void Fit3D(unsigned short mode, Point3_t point, Vector3_t dir, Point3_t &fitPos, Vector3_t &fitDir)
Definition: PFPUtils.cxx:1042
void PrintTp3(std::string someText, TCSlice &slc, const TrajPoint3 &tp3)
Definition: PFPUtils.cxx:3041
void FindCompleteness(TCSlice &slc, PFPStruct &pfp, bool doFit, bool fillTp3s, bool prt)
Definition: PFPUtils.cxx:737
bool InsideTPC(const Point3_t &pos, geo::TPCID &inTPCID)
Definition: PFPUtils.cxx:2825
bool FitTp3(TCSlice &slc, TrajPoint3 &tp3, const std::vector< Tj2Pt > &tj2pts)
Definition: PFPUtils.cxx:646
std::array< double, 3 > Point3_t
Definition: DataStructs.h:35
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:2849
float PFPDOCA(const PFPStruct &pfp1, const PFPStruct &pfp2, unsigned short &close1, unsigned short &close2)
Definition: PFPUtils.cxx:1790
unsigned short WiresSkippedInCTP(TCSlice &slc, std::vector< int > &tjids, CTP_t inCTP)
Definition: PFPUtils.cxx:1089
bool MakeTp3(TCSlice &slc, const TrajPoint &itp, const TrajPoint &jtp, TrajPoint3 &tp3, bool findDirection)
Definition: PFPUtils.cxx:1555
bool LineLineIntersect(Point3_t p1, Point3_t p2, Point3_t p3, Point3_t p4, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:2879
void FindXMatches(TCSlice &slc, unsigned short numPlanes, short maxScore, std::vector< MatchStruct > &matVec, bool prt)
Definition: PFPUtils.cxx:1355
bool MergePFPTjs(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1203
float LengthInCTP(TCSlice &slc, std::vector< int > &tjids, CTP_t inCTP)
Definition: PFPUtils.cxx:1135
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:1636
std::vector< unsigned short > FindKinks(TCSlice &slc, PFPStruct &pfp, double sep, bool prt)
Definition: PFPUtils.cxx:1901
bool Split3DKink(TCSlice &slc, PFPStruct &pfp, double sep, bool prt)
Definition: PFPUtils.cxx:1811
void PrintTp3s(std::string someText, TCSlice &slc, const PFPStruct &pfp, short printPts)
Definition: PFPUtils.cxx:3057
void UpdateTp3s(TCSlice &slc, PFPStruct &pfp, int oldTj, int newTj)
Definition: PFPUtils.cxx:229
void PFPVertexCheck(TCSlice &slc)
Definition: PFPUtils.cxx:2502
std::array< float, 2 > Point2_t
Definition: DataStructs.h:37
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:1643
void CleanTjs(TCSlice &slc, PFPStruct &pfp, bool prt)
bool DefinePFP(std::string inFcnLabel, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2233
void UpdateMatchStructs(TCSlice &slc, int oldTj, int newTj)
Definition: PFPUtils.cxx:160
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:1660
void FollowTp3s(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:405
bool PointDirIntersect(Point3_t p1, Vector3_t p1Dir, Point3_t p2, Vector3_t p2Dir, Point3_t &intersect, float &doca)
Definition: PFPUtils.cxx:2867
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
void FindMissedTjsInTp3s(TCSlice &slc, PFPStruct &pfp, std::vector< int > &missTjs, std::vector< float > &missFrac)
Definition: PFPUtils.cxx:950
unsigned short FarEnd(TCSlice &slc, const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:3032
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:1670
Definition of data types for geometry description.
bool AnalyzePFP(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2421
void FindPFParticles(TCSlice &slc)
Definition: PFPUtils.cxx:1998
void FilldEdx(TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:1683
bool InsideFV(TCSlice &slc, PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:2810
double DotProd(const Vector3_t &v1, const Vector3_t &v2)
Definition: PFPUtils.h:59
unsigned int CTP_t
Definition: DataStructs.h:41
TDirectory * dir
Definition: macro.C:5
PFPStruct CreatePFP(TCSlice &slc)
Definition: PFPUtils.cxx:1973
void ReversePFP(TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:2935
bool SetStart(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:351
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:1654
bool FitTp3s(TCSlice &slc, const std::vector< TrajPoint3 > &tp3s, Point3_t &pos, Vector3_t &dir, float &rCorr)
Definition: PFPUtils.cxx:556
double KinkAngle(TCSlice &slc, const std::vector< TrajPoint3 > &tp3s, unsigned short atPt, double sep)
Definition: PFPUtils.cxx:1943
void FillmAllTraj(TCSlice &slc)
Definition: PFPUtils.cxx:271
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:36
bool SharesHighScoreVx(TCSlice &slc, const PFPStruct &pfp, const Trajectory &tj)
Definition: PFPUtils.cxx:1026
bool PFPVxTjOK(TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:2366
bool AddMissedTj(TCSlice &slc, PFPStruct &pfp, unsigned short itj, bool looseCuts, bool prt)
Definition: PFPUtils.cxx:1159
void DefinePFPParents(TCSlice &slc, bool prt)
Definition: PFPUtils.cxx:2530
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
float ChgFracBetween(TCSlice &slc, Point3_t pos1, Point3_t pos2)
Definition: PFPUtils.cxx:2957
float ChgFracNearEnd(TCSlice &slc, PFPStruct &pfp, unsigned short end)
Definition: PFPUtils.cxx:2986
bool StorePFP(TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:2749
void StitchPFPs()
Definition: PFPUtils.cxx:16
float AspectRatio(TCSlice &slc, std::vector< int > &tjids, CTP_t inCTP)
void DefinePFPParentsTestBeam(TCSlice &slc, bool prt)
Definition: PFPUtils.cxx:2661