LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Utils.h
Go to the documentation of this file.
1 //
3 //
4 // TCAlg utilities
5 //
6 // Bruce Baller
7 //
9 #ifndef TRAJCLUSTERALGUTILS_H
10 #define TRAJCLUSTERALGUTILS_H
11 
12 // C++ standard libraries
13 #include <algorithm>
14 #include <array>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 // Framework libraries
21 
22 // LArSoft
24 namespace detinfo {
25  class DetectorClocksData;
26  class DetectorPropertiesData;
27 }
28 namespace geo {
29  struct TPCID;
30 }
31 namespace recob {
32  class Hit;
33 }
34 
35 namespace tca {
36 
37  namespace detail {
38  bool valsDecreasing(const SortEntry& c1, const SortEntry& c2);
39  bool valsIncreasing(const SortEntry& c1, const SortEntry& c2);
40  }
41 
42  typedef enum {
46  } HitStatus_t;
47 
48  // ****************************** General purpose ******************************
49  // dressed muons
50  void MakeHaloTj(TCSlice& slc, Trajectory& muTj, bool prt);
51  void DefineTjParents(TCSlice& slc, bool prt);
52  float MaxChargeAsymmetry(TCSlice& slc, std::vector<int> const& tjIDs);
53  int PDGCodeVote(const TCSlice& slc, const std::vector<int>& tjIDs);
54  int NeutrinoPrimaryTjID(const TCSlice& slc, const Trajectory& tj);
55  int PrimaryID(const TCSlice& slc, const Trajectory& tj);
56  int PrimaryUID(const PFPStruct& pfp);
57  bool MergeTjIntoPFP(TCSlice& slc, int mtjid, PFPStruct& pfp, bool prt);
58  float PointPull(Point2_t pos, float chg, const Trajectory& tj);
59  bool CompatibleMerge(const TCSlice& slc, std::vector<int> const& tjIDs, bool prt);
60  bool CompatibleMerge(const Trajectory& tj1, const Trajectory& tj2, bool prt);
61  float OverlapFraction(const Trajectory& tj1, const Trajectory& tj2);
62  unsigned short AngleRange(TrajPoint const& tp);
63  void SetAngleCode(TrajPoint& tp);
64  unsigned short AngleRange(float angle);
65  void FitTraj(TCSlice const& slc, Trajectory& tj);
66  void FitTraj(TCSlice const& slc,
67  Trajectory& tj,
68  unsigned short originPt,
69  unsigned short npts,
70  short fitDir,
71  TrajPoint& tpFit);
72  unsigned short GetPFPIndex(const TCSlice& slc, int tjID);
73  void ReleaseHits(TCSlice& slc, Trajectory const& tj);
74  void UnsetUsedHits(TCSlice& slc, TrajPoint& tp);
75  bool StoreTraj(TCSlice& slc, Trajectory& tj);
76  void FitPar(const Trajectory& tj,
77  unsigned short originPt,
78  unsigned short npts,
79  short fitDir,
80  ParFit& pFit,
81  unsigned short usePar);
82  bool InTrajOK(TCSlice& slc, std::string someText);
83  void CheckTrajBeginChg(TCSlice& slc, unsigned short itj);
84  bool BraggSplit(TCSlice& slc, unsigned short itj);
85  void ChkEndKink(TCSlice const& slc, Trajectory& tj, bool prt);
86  void TrimHiChgEndPts(TCSlice& slc, Trajectory& tj, bool prt);
87  void TrimEndPts(std::string fcnLabel,
88  TCSlice& slc,
89  Trajectory& tj,
90  const std::vector<float>& fQualityCuts,
91  bool prt);
92  void ChkChgAsymmetry(TCSlice& slc, Trajectory& tj, bool prt);
93  bool SignalBetween(const TrajPoint& tp1, const TrajPoint& tp2, float MinWireSignalFraction);
94  bool SignalBetween(TrajPoint tp, float toPos0, float MinWireSignalFraction);
95  float ChgFracBetween(TrajPoint tp, float toPos0);
96  bool TrajHitsOK(TCSlice const& slc,
97  const std::vector<unsigned int>& iHitsInMultiplet,
98  const std::vector<unsigned int>& jHitsInMultiplet);
99  bool TrajHitsOK(TCSlice const& slc, const unsigned int iht, const unsigned int jht);
100  float ExpectedHitsRMS(const TrajPoint& tp);
101  bool SignalAtTpInSlc(const TCSlice& slc, const TrajPoint& tp);
102  bool SignalAtTp(TrajPoint& tp);
103  bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick);
104  float TpSumHitChg(const TCSlice& slc, TrajPoint const& tp);
105  unsigned short NumPtsWithCharge(const TCSlice& slc, const Trajectory& tj, bool includeDeadWires);
106  unsigned short NumPtsWithCharge(const TCSlice& slc,
107  const Trajectory& tj,
108  bool includeDeadWires,
109  unsigned short firstPt,
110  unsigned short lastPt);
111  float DeadWireCount(const TCSlice& slc, const TrajPoint& tp1, const TrajPoint& tp2);
112  float DeadWireCount(const TCSlice& slc,
113  const float& inWirePos1,
114  const float& inWirePos2,
115  CTP_t tCTP);
116  unsigned short PDGCodeIndex(int PDGCode);
117  void MakeTrajectoryObsolete(TCSlice& slc, unsigned int itj);
118  void RestoreObsoleteTrajectory(TCSlice& slc, unsigned int itj);
119  void MergeGhostTjs(TCSlice& slc, CTP_t inCTP);
120  // Split the allTraj trajectory itj at position pos into two trajectories
121  // with an optional vertex assignment
122  bool SplitTraj(TCSlice& slc,
123  unsigned short itj,
124  unsigned short pos,
125  unsigned short ivx,
126  bool prt);
127  bool SplitTraj(detinfo::DetectorPropertiesData const& detProp,
128  TCSlice& slc,
129  unsigned short itj,
130  float XPos,
131  bool makeVx2,
132  bool prt);
133  bool TrajClosestApproach(Trajectory const& tj,
134  float x,
135  float y,
136  unsigned short& closePt,
137  float& DOCA);
138  // returns the DOCA between a hit and a trajectory
139  float PointTrajDOCA(const TCSlice& slc, unsigned int iht, TrajPoint const& tp);
140  // returns the DOCA between a (W,T) point and a trajectory
141  float PointTrajDOCA(float wire, float time, TrajPoint const& tp);
142  // returns the DOCA^2 between a point and a trajectory
143  float PointTrajDOCA2(float wire, float time, TrajPoint const& tp);
144  // Fills tp.Hits sets tp.UseHit true for hits that are close to tp.Pos. Returns true if there are
145  // close hits OR if the wire at this position is dead
146  bool FindCloseHits(TCSlice const& slc, TrajPoint& tp, float maxDelta, HitStatus_t hitRequest);
147  std::vector<unsigned int> FindCloseHits(const TCSlice& slc,
148  std::array<int, 2> const& wireWindow,
149  Point2_t const& timeWindow,
150  const unsigned short plane,
151  HitStatus_t hitRequest,
152  bool usePeakTime,
153  bool& hitsNear);
154  unsigned short NearbyCleanPt(const Trajectory& tj, unsigned short nearPt);
155  std::vector<int> FindCloseTjs(const TCSlice& slc,
156  const TrajPoint& fromTp,
157  const TrajPoint& toTp,
158  const float& maxDelta);
159  float ElectronLikelihood(const TCSlice& slc, const Trajectory& tj);
160  float KinkSignificance(TCSlice const& slc,
161  Trajectory const& tj1,
162  unsigned short end1,
163  Trajectory const& tj2,
164  unsigned short end2,
165  unsigned short nPtsFit,
166  bool useChg,
167  bool prt);
168  float KinkSignificance(TCSlice const& slc,
169  Trajectory& tj,
170  unsigned short kinkPt,
171  unsigned short nPtsFit,
172  bool useChg,
173  bool prt);
174  float ChgFracNearPos(const TCSlice& slc, const Point2_t& pos, const std::vector<int>& tjIDs);
175  float MaxHitDelta(TCSlice& slc, Trajectory& tj);
176  void ReverseTraj(Trajectory& tj);
177  // returns the end of a trajectory that is closest to a point
178  unsigned short CloseEnd(const Trajectory& tj, const Point2_t& pos);
179  // returns the separation^2 between a point and a TP
180  float PointTrajSep2(float wire, float time, TrajPoint const& tp);
181  float PosSep(const Point2_t& pos1, const Point2_t& pos2);
182  float PosSep2(const Point2_t& pos1, const Point2_t& pos2);
183  // finds the point on trajectory tj that is closest to trajpoint tp
184  void TrajPointTrajDOCA(TrajPoint const& tp,
185  Trajectory const& tj,
186  unsigned short& closePt,
187  float& minSep);
188  // returns the intersection position, intPos, of two trajectory points
189  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, Point2_t& pos);
190  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, float& x, float& y);
191  float MaxTjLen(const TCSlice& slc, std::vector<int>& tjIDs);
192  // Returns the separation distance between two trajectory points
193  float TrajPointSeparation(const TrajPoint& tp1, const TrajPoint& tp2);
194  float TrajLength(const Trajectory& tj);
195  // returns the separation^2 between two hits in WSE units
196  float HitSep2(const TCSlice& slc, unsigned int iht, unsigned int jht);
197  // Find the Distance Of Closest Approach between two trajectories, exceeding minSep
198  bool TrajTrajDOCA(const TCSlice& slc,
199  const Trajectory& tp1,
200  const Trajectory& tp2,
201  unsigned short& ipt1,
202  unsigned short& ipt2,
203  float& minSep);
204  bool TrajTrajDOCA(const TCSlice& slc,
205  const Trajectory& tp1,
206  const Trajectory& tp2,
207  unsigned short& ipt1,
208  unsigned short& ipt2,
209  float& minSep,
210  bool considerDeadWires);
211  // Calculates the angle between two TPs
212  float TwoTPAngle(const TrajPoint& tp1, const TrajPoint& tp2);
213  void TagJunkTj(Trajectory& tj, bool prt);
214  std::vector<unsigned int> PutHitsInVector(const TCSlice& slc,
215  PFPStruct const& pfp,
216  HitStatus_t hitRequest);
217  // Put hits in each trajectory point into a flat vector.
218  std::vector<unsigned int> PutTrajHitsInVector(const Trajectory& tj, HitStatus_t hitRequest);
219  // returns true if a hit is associated with more than one point
220  bool HasDuplicateHits(const TCSlice& slc, Trajectory const& tj, bool prt);
221  // Project TP to a "wire position" Pos[0] and update Pos[1]
222  void MoveTPToWire(TrajPoint& tp, float wire);
223  bool PointInsideEnvelope(const Point2_t& Point, const std::vector<Point2_t>& Envelope);
224  bool SetMag(Vector2_t& v1, double mag);
225  void FindAlongTrans(Point2_t pos1, Vector2_t dir1, Point2_t pos2, Point2_t& alongTrans);
226  inline double DotProd(const Vector2_t& v1, const Vector2_t& v2)
227  {
228  return v1[0] * v2[0] + v1[1] * v2[1];
229  }
230  double DeltaAngle(double Ang1, double Ang2);
231  double DeltaAngle2(double Ang1, double Ang2);
232  double DeltaAngle(const Point2_t& p1, const Point2_t& p2);
233  // Find the first (last) TPs, EndPt[0] (EndPt[1], that have charge
234  void SetEndPoints(Trajectory& tj);
235  // Returns the hit width using StartTick() and EndTick()
236  float TPHitsRMSTick(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
237  float TPHitsRMSTime(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
238  float HitsRMSTick(const TCSlice& slc,
239  const std::vector<unsigned int>& hitsInMultiplet,
240  HitStatus_t hitRequest);
241  float HitsRMSTime(const TCSlice& slc,
242  const std::vector<unsigned int>& hitsInMultiplet,
243  HitStatus_t hitRequest);
244  float HitsPosTick(const TCSlice& slc,
245  const std::vector<unsigned int>& hitsInMultiplet,
246  float& chg,
247  HitStatus_t hitRequest);
248  float HitsPosTime(const TCSlice& slc,
249  const std::vector<unsigned int>& hitsInMultiplet,
250  float& chg,
251  HitStatus_t hitRequest);
252  unsigned short NumHitsInTP(const TrajPoint& tp, HitStatus_t hitRequest);
253  unsigned short NearestPtWithChg(const Trajectory& tj, unsigned short thePt);
254  // Calculate MCS momentum
255  short MCSMom(const TCSlice& slc, const std::vector<int>& tjIDs);
256  short MCSMom(const TCSlice& slc, const Trajectory& tj);
257  short MCSMom(const TCSlice& slc,
258  const Trajectory& tj,
259  unsigned short FirstPt,
260  unsigned short lastPt);
261  // Calculate MCS theta RMS over the points specified. Returns MCS angle for the full length
262  double MCSThetaRMS(const Trajectory& tj, unsigned short firstPt, unsigned short lastPt);
263  // Calculate MCS theta RMS over the entire length. Returns MCS angle for 1 WSE unit
264  float MCSThetaRMS(const Trajectory& tj);
265  void TjDeltaRMS(const Trajectory& tj,
266  unsigned short firstPt,
267  unsigned short lastPt,
268  double& rms,
269  unsigned short& cnt);
270  void SetTPEnvironment(TCSlice& slc, CTP_t inCTP);
271  // Returns true if the trajectory has low hit multiplicity and is in a clean environment
272  bool TrajIsClean(Trajectory const& tj, bool prt);
273  void UpdateTjChgProperties(std::string inFcnLabel, TCSlice const& slc, Trajectory& tj, bool prt);
274  void UpdateVxEnvironment(TCSlice& slc);
275  void UpdateVxEnvironment(TCSlice& slc, VtxStore& vx2, bool prt);
277  const Point3_t& pos,
278  CTP_t inCTP);
279  // Make a bare trajectory point that only has position and direction defined
281  const Point3_t& pos,
282  const Vector3_t& dir,
283  CTP_t inCTP);
284  bool MakeBareTrajPoint(const TCSlice& slc,
285  unsigned int fromHit,
286  unsigned int toHit,
287  TrajPoint& tp);
288  bool MakeBareTrajPoint(float fromWire,
289  float fromTick,
290  float toWire,
291  float toTick,
292  CTP_t tCTP,
293  TrajPoint& tp);
294  bool MakeBareTrajPoint(const Point2_t& fromPos, const Point2_t& toPos, TrajPoint& tpOut);
295  bool MakeBareTrajPoint(const TrajPoint& tpIn1, const TrajPoint& tpIn2, TrajPoint& tpOut);
296  unsigned short FarEnd(const Trajectory& tj, const Point2_t& pos);
297  Vector2_t PointDirection(const Point2_t p1, const Point2_t p2);
298  void SetPDGCode(TCSlice const& slc, Trajectory& tj);
299  void SetPDGCode(TCSlice& slc, unsigned short itj);
300  bool AnalyzeHits();
301  bool LongPulseHit(const recob::Hit& hit);
302  void FillWireHitRange(geo::TPCID inTPCID);
303  bool FillWireHitRange(detinfo::DetectorClocksData const& clockData,
304  detinfo::DetectorPropertiesData const& detProp,
305  TCSlice& slc);
306  // bool CheckWireHitRange(TCSlice& slc);
307  bool WireHitRangeOK(TCSlice const& slc, const CTP_t& inCTP);
308  bool MergeAndStore(TCSlice& slc, unsigned int itj1, unsigned int itj2, bool doPrt);
309  std::vector<int> GetAssns(TCSlice const& slc,
310  std::string type1Name,
311  int id,
312  std::string type2Name);
313  // Start a trajectory going from fromHit to (toWire, toTick)
314  bool StartTraj(TCSlice const& slc,
315  Trajectory& tj,
316  unsigned int fromhit,
317  unsigned int tohit,
318  unsigned short pass);
319  bool StartTraj(Trajectory& tj,
320  float fromWire,
321  float fromTick,
322  float toWire,
323  float toTick,
324  CTP_t& tCTP,
325  unsigned short pass);
326  bool Fit2D(short mode,
327  Point2_t inPt,
328  float& inPtErr,
329  Vector2_t& outVec,
330  Vector2_t& outVecErr,
331  float& chiDOF);
332  std::pair<unsigned short, unsigned short> GetSliceIndex(std::string typeName, int uID);
333  template <typename T>
334  std::vector<T> SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2);
335  template <typename T>
336  std::vector<T> SetDifference(const std::vector<T>& set1, const std::vector<T>& set2);
337  bool DecodeDebugString(std::string ctpwt);
338  // ****************************** Printing ******************************
339  void DumpTj();
340  void PrintDebugMode();
341  void PrintAll(detinfo::DetectorPropertiesData const& detProp, std::string someText);
342  void PrintP(mf::LogVerbatim& myprt, PFPStruct const& pfp, bool& printHeader);
343  void Print3V(detinfo::DetectorPropertiesData const& detProp,
344  mf::LogVerbatim& myprt,
345  Vtx3Store const& vx3,
346  bool& printHeader);
347  void Print2V(mf::LogVerbatim& myprt, VtxStore const& vx2, bool& printHeader);
348  void Print3S(detinfo::DetectorPropertiesData const& detProp,
349  mf::LogVerbatim& myprt,
350  ShowerStruct3D const& ss3);
351  void PrintT(mf::LogVerbatim& myprt, Trajectory const& tj, bool& printHeader);
352  void PrintTrajectory(std::string someText,
353  const TCSlice& slc,
354  const Trajectory& tj,
355  unsigned short tPoint);
356  void PrintAllTraj(detinfo::DetectorPropertiesData const& detProp,
357  std::string someText,
358  TCSlice const& slc,
359  unsigned short itj,
360  unsigned short ipt,
361  bool printVtx = true);
362  void PrintTPHeader(std::string someText);
363  void PrintTP(std::string someText,
364  const TCSlice& slc,
365  unsigned short ipt,
366  short dir,
367  unsigned short pass,
368  const TrajPoint& tp);
369  std::string TPEnvString(const TrajPoint& tp);
370  void PrintPFP(std::string someText, TCSlice const& slc, const PFPStruct& pfp, bool printHeader);
371  void PrintPFPs(std::string someText, TCSlice const& slc);
372  // Print clusters after calling MakeAllTrajClusters
373  void PrintClusters();
374  // Print a single hit in the standard format
375  std::string PrintHit(const TCHit& hit);
376  std::string PrintHitShort(const TCHit& hit);
377  // Print Trajectory position in the standard format
378  std::string PrintPos(const TrajPoint& tp);
379  std::string PrintPos(const Point2_t& pos);
380  std::string PrintEndFlag(const Trajectory& tj, unsigned short end);
381  std::string PrintEndFlag(const PFPStruct& pfp, unsigned short end);
382 
384  template <typename T>
385  std::vector<T> SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2)
386  {
387  // returns a vector containing the elements of set1 and set2 that are common. This function
388  // is a replacement for std::set_intersection which fails in the following situation:
389  // set1 = {11 12 17 18} and set2 = {6 12 18}
390  // There is no requirement that the elements be sorted, unlike std::set_intersection
391  std::vector<T> shared;
392 
393  if (set1.empty()) return shared;
394  if (set2.empty()) return shared;
395  for (auto element1 : set1) {
396  // check for a common element
397  if (std::find(set2.begin(), set2.end(), element1) == set2.end()) continue;
398  // check for a duplicate
399  if (std::find(shared.begin(), shared.end(), element1) != shared.end()) continue;
400  shared.push_back(element1);
401  } // element1
402  return shared;
403  } // SetIntersection
404 
406  template <typename T>
407  std::vector<T> SetDifference(const std::vector<T>& set1, const std::vector<T>& set2)
408  {
409  // returns the elements of set1 and set2 that are different
410  std::vector<T> different;
411  if (set1.empty() && set2.empty()) return different;
412  if (!set1.empty() && set2.empty()) return set1;
413  if (set1.empty() && !set2.empty()) return set2;
414  for (auto element1 : set1) {
415  // check for a common element
416  if (std::find(set2.begin(), set2.end(), element1) != set2.end()) continue;
417  // check for a duplicate
418  if (std::find(different.begin(), different.end(), element1) != different.end()) continue;
419  different.push_back(element1);
420  } // element1
421  for (auto element2 : set2) {
422  // check for a common element
423  if (std::find(set1.begin(), set1.end(), element2) != set1.end()) continue;
424  // check for a duplicate
425  if (std::find(different.begin(), different.end(), element2) != different.end()) continue;
426  different.push_back(element2);
427  } // element1
428  return different;
429  } // SetDifference
430 
431 } // namespace tca
432 
433 #endif // ifndef TRAJCLUSTERALGUTILS_H
Float_t x
Definition: compare.C:6
void PrintAll(detinfo::DetectorPropertiesData const &detProp, std::string someText)
Definition: Utils.cxx:5367
float HitsPosTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:4163
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1316
short MCSMom(const TCSlice &slc, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3380
void FitTraj(TCSlice const &slc, Trajectory &tj)
Definition: Utils.cxx:797
void SetEndPoints(Trajectory &tj)
Definition: Utils.cxx:3329
bool TrajHitsOK(TCSlice const &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
Definition: Utils.cxx:1838
bool InTrajOK(TCSlice &slc, std::string someText)
Definition: Utils.cxx:1256
Reconstruction base classes.
struct of temporary 2D vertices (end points)
Definition: DataStructs.h:69
std::vector< unsigned int > PutTrajHitsInVector(const Trajectory &tj, HitStatus_t hitRequest)
Definition: Utils.cxx:2688
std::array< double, 3 > Point3_t
Definition: DataStructs.h:41
bool SignalAtTp(TrajPoint &tp)
Definition: Utils.cxx:1963
void SetPDGCode(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:4217
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:3069
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
Definition: Utils.cxx:6032
Float_t y
Definition: compare.C:6
void PrintClusters()
bool StartTraj(TCSlice const &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
Definition: Utils.cxx:4855
void PrintTP(std::string someText, const TCSlice &slc, unsigned short ipt, short dir, unsigned short pass, const TrajPoint &tp)
Definition: Utils.cxx:6131
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
void UnsetUsedHits(TCSlice &slc, TrajPoint &tp)
Definition: Utils.cxx:1060
std::string PrintEndFlag(const PFPStruct &pfp, unsigned short end)
Definition: Utils.cxx:6294
bool StoreTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1073
float TpSumHitChg(const TCSlice &slc, TrajPoint const &tp)
Definition: Utils.cxx:2060
void ChkChgAsymmetry(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1713
bool TrajClosestApproach(Trajectory const &tj, float x, float y, unsigned short &closePt, float &DOCA)
Definition: Utils.cxx:2621
void FillWireHitRange(geo::TPCID inTPCID)
Definition: Utils.cxx:4323
float TrajPointSeparation(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2612
bool CompatibleMerge(const TCSlice &slc, std::vector< int > const &tjIDs, bool prt)
Definition: Utils.cxx:576
void SetAngleCode(TrajPoint &tp)
Definition: Utils.cxx:764
float PointTrajDOCA(const TCSlice &slc, unsigned int iht, TrajPoint const &tp)
Definition: Utils.cxx:2513
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:2535
bool MakeBareTrajPoint(const TCSlice &slc, unsigned int fromHit, unsigned int toHit, TrajPoint &tp)
Definition: Utils.cxx:4006
void Print2V(mf::LogVerbatim &myprt, VtxStore const &vx2, bool &printHeader)
Definition: Utils.cxx:5610
HitStatus_t
Definition: Utils.h:42
bool LongPulseHit(const recob::Hit &hit)
Definition: Utils.cxx:4315
void PrintPFPs(std::string someText, TCSlice const &slc)
Definition: Utils.cxx:6276
float TPHitsRMSTime(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4090
std::string TPEnvString(const TrajPoint &tp)
Definition: Utils.cxx:6187
std::string PrintPos(const TrajPoint &tp)
Definition: Utils.cxx:6353
float MaxTjLen(const TCSlice &slc, std::vector< int > &tjIDs)
Definition: Utils.cxx:2566
bool MergeTjIntoPFP(TCSlice &slc, int mtjid, PFPStruct &pfp, bool prt)
Definition: Utils.cxx:511
void Print3S(detinfo::DetectorPropertiesData const &detProp, mf::LogVerbatim &myprt, ShowerStruct3D const &ss3)
Definition: Utils.cxx:5660
double DeltaAngle2(double Ang1, double Ang2)
Definition: Utils.cxx:3311
std::vector< T > SetIntersection(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:385
bool SignalBetween(const TrajPoint &tp1, const TrajPoint &tp2, const float MinWireSignalFraction)
Definition: Utils.cxx:1778
float MaxChargeAsymmetry(TCSlice &slc, std::vector< int > const &tjIDs)
Definition: Utils.cxx:377
float OverlapFraction(const Trajectory &tj1, const Trajectory &tj2)
Definition: Utils.cxx:706
std::string PrintHitShort(const TCHit &tch)
Definition: Utils.cxx:6335
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
float HitsRMSTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4123
void FitPar(const Trajectory &tj, unsigned short originPt, unsigned short npts, short fitDir, ParFit &pFit, unsigned short usePar)
Definition: Utils.cxx:1201
std::vector< unsigned int > PutHitsInVector(const TCSlice &slc, PFPStruct const &pfp, HitStatus_t hitRequest)
Definition: Utils.cxx:2664
float HitSep2(const TCSlice &slc, unsigned int iht, unsigned int jht)
Definition: Utils.cxx:2482
int NeutrinoPrimaryTjID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:445
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4131
struct of temporary 3D vertices
Definition: DataStructs.h:101
int PrimaryID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:467
TCanvas * c1
Definition: plotHisto.C:7
unsigned short NearestPtWithChg(const Trajectory &tj, unsigned short thePt)
Definition: Utils.cxx:3434
TCanvas * c2
Definition: plot_hist.C:75
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
float DeadWireCount(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2094
bool BraggSplit(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1422
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:2542
float PointTrajDOCA2(float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2529
void DumpTj()
Definition: Utils.cxx:5248
float ElectronLikelihood(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:3143
float TwoTPAngle(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2655
void TjDeltaRMS(const Trajectory &tj, unsigned short firstPt, unsigned short lastPt, double &rms, unsigned short &cnt)
Definition: Utils.cxx:3490
float ChgFracNearPos(const TCSlice &slc, const Point2_t &pos, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3162
std::vector< unsigned int > FindCloseHits(const TCSlice &slc, std::array< int, 2 > const &wireWindow, Point2_t const &timeWindow, const unsigned short plane, HitStatus_t hitRequest, bool usePeakTime, bool &hitsNear)
Definition: Utils.cxx:2773
float ChgFracBetween(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, Point3_t pos1, Point3_t pos2)
Definition: PFPUtils.cxx:3166
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
Definition: Utils.cxx:52
TrajPoint MakeBareTP(detinfo::DetectorPropertiesData const &detProp, const Point3_t &pos, CTP_t inCTP)
Definition: Utils.cxx:3927
void PrintT(mf::LogVerbatim &myprt, Trajectory const &tj, bool &printHeader)
Definition: Utils.cxx:5699
bool PointInsideEnvelope(const Point2_t &Point, const std::vector< Point2_t > &Envelope)
Definition: Utils.cxx:3245
void MakeTrajectoryObsolete(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2137
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2564
unsigned short GetPFPIndex(const TCSlice &slc, int tjID)
Definition: Utils.cxx:1037
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:6344
bool Fit2D(short mode, Point2_t inPt, float &inPtErr, Vector2_t &outVec, Vector2_t &outVecErr, float &chiDOF)
Definition: Utils.cxx:4979
bool SplitTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, unsigned short itj, float XPos, bool makeVx2, bool prt)
Definition: Utils.cxx:2222
General LArSoft Utilities.
double DotProd(const Vector2_t &v1, const Vector2_t &v2)
Definition: Utils.h:226
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
void PrintP(mf::LogVerbatim &myprt, PFPStruct const &pfp, bool &printHeader)
Definition: Utils.cxx:5450
float ExpectedHitsRMS(const TrajPoint &tp)
Definition: Utils.cxx:1910
bool valsIncreasing(const SortEntry &c1, const SortEntry &c2)
Definition: Utils.cxx:42
void ReleaseHits(TCSlice &slc, Trajectory const &tj)
Definition: Utils.cxx:1048
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:2574
std::array< double, 2 > Vector2_t
Definition: DataStructs.h:44
unsigned short NumHitsInTP(const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4196
void TrimEndPts(std::string fcnLabel, TCSlice &slc, Trajectory &tj, const std::vector< float > &fQualityCuts, bool prt)
Definition: Utils.cxx:1575
unsigned short FarEnd(const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:3302
void DefineTjParents(TCSlice &slc, bool prt)
Definition: Utils.cxx:172
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:4172
Detector simulation of raw signals on wires.
float MCSThetaRMS(const Trajectory &tj)
Definition: Utils.cxx:3452
unsigned short NearbyCleanPt(const Trajectory &tj, unsigned short end)
Definition: Utils.cxx:2887
bool MergeAndStore(TCSlice &slc, unsigned int itj1, unsigned int itj2, bool doPrt)
Definition: Utils.cxx:4518
void RestoreObsoleteTrajectory(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2149
void PrintPFP(std::string someText, TCSlice const &slc, const PFPStruct &pfp, bool printHeader)
Definition: Utils.cxx:6206
std::vector< int > GetAssns(TCSlice const &slc, std::string type1Name, int id, std::string type2Name)
Definition: Utils.cxx:4701
void TrajIntersection(TrajPoint const &tp1, TrajPoint const &tp2, Point2_t &pos)
Definition: Utils.cxx:2542
int PrimaryUID(const PFPStruct &pfp)
Definition: Utils.cxx:486
unsigned int CTP_t
Definition: DataStructs.h:47
void UpdateTjChgProperties(std::string inFcnLabel, TCSlice const &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:3576
float KinkSignificance(TCSlice const &slc, Trajectory const &tj1, unsigned short end1, Trajectory const &tj2, unsigned short end2, unsigned short nPtsFit, bool useChg, bool prt)
Definition: Utils.cxx:2985
void Print3V(detinfo::DetectorPropertiesData const &detProp, mf::LogVerbatim &myprt, Vtx3Store const &vx3, bool &printHeader)
Definition: Utils.cxx:5535
bool DecodeDebugString(std::string strng)
Definition: Utils.cxx:5065
bool AnalyzeHits()
Definition: Utils.cxx:4259
Contains all timing reference information for the detector.
TDirectory * dir
Definition: macro.C:5
float MaxHitDelta(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:3201
float TrajLength(const Trajectory &tj)
Definition: Utils.cxx:2581
void UpdateVxEnvironment(TCSlice &slc)
Definition: Utils.cxx:3764
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
void TagJunkTj(Trajectory &tj, bool prt)
Definition: Utils.cxx:2715
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2558
void TrimHiChgEndPts(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1533
unsigned short PDGCodeIndex(int PDGCode)
Definition: Utils.cxx:2125
float PointPull(const TP3D &tp3d)
Definition: PFPUtils.cxx:2797
bool valsDecreasing(const SortEntry &c1, const SortEntry &c2)
Definition: Utils.cxx:38
std::pair< unsigned short, unsigned short > GetSliceIndex(std::string typeName, int uID)
Definition: Utils.cxx:4939
float PointTrajSep2(float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2505
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:42
bool SignalAtTpInSlc(const TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:1922
void PrintDebugMode()
Definition: Utils.cxx:5297
std::vector< T > SetDifference(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:407
bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick)
Definition: Utils.cxx:2029
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
std::vector< int > FindCloseTjs(const TCSlice &slc, const TrajPoint &fromTp, const TrajPoint &toTp, const float &maxDelta)
Definition: Utils.cxx:2907
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
void PrintAllTraj(detinfo::DetectorPropertiesData const &detProp, std::string someText, TCSlice const &slc, unsigned short itj, unsigned short ipt, bool prtVtx)
Definition: Utils.cxx:5790
void MoveTPToWire(TrajPoint &tp, float wire)
Definition: Utils.cxx:2762
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
Definition: Utils.cxx:2071
unsigned short CloseEnd(const Trajectory &tj, const Point2_t &pos)
Definition: Utils.cxx:2494
void MergeGhostTjs(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:2171
bool TrajIsClean(Trajectory const &tj, bool prt)
Definition: Utils.cxx:3357
bool TrajTrajDOCA(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2, unsigned short &ipt1, unsigned short &ipt2, float &minSep)
Definition: Utils.cxx:2406
Namespace collecting geometry-related classes utilities.
bool WireHitRangeOK(TCSlice const &slc, const CTP_t &inCTP)
Definition: Utils.cxx:4508
void TrajPointTrajDOCA(TrajPoint const &tp, Trajectory const &tj, unsigned short &closePt, float &minSep)
Definition: Utils.cxx:2383
float TPHitsRMSTick(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4096
void PrintTPHeader(std::string someText)
Definition: Utils.cxx:6123
void ChkEndKink(TCSlice const &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1681
unsigned short AngleRange(TrajPoint const &tp)
Definition: Utils.cxx:758
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:3530
bool HasDuplicateHits(const TCSlice &slc, Trajectory const &tj, bool prt)
Definition: Utils.cxx:2744
void ReverseTraj(Trajectory &tj)
Definition: Utils.cxx:3218