Utils.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 //
4 // TCAlg utilities
5 //
6 // Bruce Baller
7 //
8 ///////////////////////////////////////////////////////////////////////
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 bool valsDecreasing(const SortEntry& c1, const SortEntry& c2);
36 bool valsIncreasing(const SortEntry& c1, const SortEntry& c2);
37 
38 namespace tca {
39 
40  typedef enum {
44  } HitStatus_t;
45 
46  // ****************************** General purpose ******************************
47  // dressed muons
48  void MakeHaloTj(TCSlice& slc, Trajectory& muTj, bool prt);
49  void DefineTjParents(TCSlice& slc, bool prt);
50  float MaxChargeAsymmetry(TCSlice& slc, std::vector<int>& tjIDs);
51  int PDGCodeVote(const TCSlice& slc, const std::vector<int>& tjIDs);
52  int NeutrinoPrimaryTjID(const TCSlice& slc, const Trajectory& tj);
53  int PrimaryID(const TCSlice& slc, const Trajectory& tj);
54  int PrimaryUID(const TCSlice& slc, const PFPStruct& pfp);
55  bool MergeTjIntoPFP(TCSlice& slc, int mtjid, PFPStruct& pfp, bool prt);
56  float PointPull(TCSlice& slc, Point2_t pos, float chg, const Trajectory& tj);
57  bool CompatibleMerge(const TCSlice& slc, std::vector<int>& tjIDs, bool prt);
58  bool CompatibleMerge(const TCSlice& slc, const Trajectory& tj1, const Trajectory& tj2, bool prt);
59  float OverlapFraction(const TCSlice& slc, const Trajectory& tj1, const Trajectory& tj2);
60  unsigned short AngleRange(TrajPoint const& tp);
61  void SetAngleCode(TrajPoint& tp);
62  unsigned short AngleRange(float angle);
63  void FitTraj(TCSlice& slc, Trajectory& tj);
64  void FitTraj(TCSlice& slc,
65  Trajectory& tj,
66  unsigned short originPt,
67  unsigned short npts,
68  short fitDir,
69  TrajPoint& tpFit);
70  unsigned short GetPFPIndex(const TCSlice& slc, int tjID);
71  void ReleaseHits(TCSlice& slc, Trajectory& tj);
72  void UnsetUsedHits(TCSlice& slc, TrajPoint& tp);
73  bool StoreTraj(TCSlice& slc, Trajectory& tj);
74  void FitPar(const TCSlice& slc,
75  const Trajectory& tj,
76  unsigned short originPt,
77  unsigned short npts,
78  short fitDir,
79  ParFit& pFit,
80  unsigned short usePar);
81  bool InTrajOK(TCSlice& slc, std::string someText);
82  void CheckTrajBeginChg(TCSlice& slc, unsigned short itj);
83  bool BraggSplit(TCSlice& slc, unsigned short itj);
84  void ChkEndKink(TCSlice& slc, Trajectory& tj, bool prt);
85  void TrimHiChgEndPts(TCSlice& slc, Trajectory& tj, bool prt);
86  void TrimEndPts(std::string fcnLabel,
87  TCSlice& slc,
88  Trajectory& tj,
89  const std::vector<float>& fQualityCuts,
90  bool prt);
91  void ChkMissedKink(TCSlice& slc, Trajectory& tj, bool prt);
92  void ChkChgAsymmetry(TCSlice& slc, Trajectory& tj, bool prt);
93  bool SignalBetween(const TCSlice& slc,
94  const TrajPoint& tp1,
95  const TrajPoint& tp2,
96  const float& MinWireSignalFraction);
97  bool SignalBetween(const TCSlice& slc,
98  TrajPoint tp,
99  float toPos0,
100  const float& MinWireSignalFraction);
101  float ChgFracBetween(const TCSlice& slc, TrajPoint tp, float toPos0);
102  bool TrajHitsOK(TCSlice& slc,
103  const std::vector<unsigned int>& iHitsInMultiplet,
104  const std::vector<unsigned int>& jHitsInMultiplet);
105  bool TrajHitsOK(TCSlice& slc, const unsigned int iht, const unsigned int jht);
106  float ExpectedHitsRMS(TCSlice& slc, const TrajPoint& tp);
107  bool SignalAtTpInSlc(const TCSlice& slc, const TrajPoint& tp);
108  bool SignalAtTp(TrajPoint& tp);
109  bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick);
110  float TpSumHitChg(const TCSlice& slc, TrajPoint const& tp);
111  unsigned short NumPtsWithCharge(const TCSlice& slc, const Trajectory& tj, bool includeDeadWires);
112  unsigned short NumPtsWithCharge(const TCSlice& slc,
113  const Trajectory& tj,
114  bool includeDeadWires,
115  unsigned short firstPt,
116  unsigned short lastPt);
117  float DeadWireCount(const TCSlice& slc, const TrajPoint& tp1, const TrajPoint& tp2);
118  float DeadWireCount(const TCSlice& slc,
119  const float& inWirePos1,
120  const float& inWirePos2,
121  CTP_t tCTP);
122  unsigned short PDGCodeIndex(int PDGCode);
123  void MakeTrajectoryObsolete(TCSlice& slc, unsigned int itj);
124  void RestoreObsoleteTrajectory(TCSlice& slc, unsigned int itj);
125  void MergeGhostTjs(TCSlice& slc, CTP_t inCTP);
126  // Split the allTraj trajectory itj at position pos into two trajectories
127  // with an optional vertex assignment
128  bool SplitTraj(TCSlice& slc,
129  unsigned short itj,
130  unsigned short pos,
131  unsigned short ivx,
132  bool prt);
133  bool SplitTraj(detinfo::DetectorPropertiesData const& detProp,
134  TCSlice& slc,
135  unsigned short itj,
136  float XPos,
137  bool makeVx2,
138  bool prt);
139  bool TrajClosestApproach(Trajectory const& tj,
140  float x,
141  float y,
142  unsigned short& closePt,
143  float& DOCA);
144  // returns the DOCA between a hit and a trajectory
145  float PointTrajDOCA(const TCSlice& slc, unsigned int iht, TrajPoint const& tp);
146  // returns the DOCA between a (W,T) point and a trajectory
147  float PointTrajDOCA(const TCSlice& slc, float wire, float time, TrajPoint const& tp);
148  // returns the DOCA^2 between a point and a trajectory
149  float PointTrajDOCA2(const TCSlice& slc, float wire, float time, TrajPoint const& tp);
150  // Fills tp.Hits sets tp.UseHit true for hits that are close to tp.Pos. Returns true if there are
151  // close hits OR if the wire at this position is dead
152  bool FindCloseHits(TCSlice& slc, TrajPoint& tp, float const& maxDelta, HitStatus_t hitRequest);
153  std::vector<unsigned int> FindCloseHits(const TCSlice& slc,
154  std::array<int, 2> const& wireWindow,
155  Point2_t const& timeWindow,
156  const unsigned short plane,
157  HitStatus_t hitRequest,
158  bool usePeakTime,
159  bool& hitsNear);
160  unsigned short NearbyCleanPt(const TCSlice& slc, const Trajectory& tj, unsigned short nearPt);
161  std::vector<int> FindCloseTjs(const TCSlice& slc,
162  const TrajPoint& fromTp,
163  const TrajPoint& toTp,
164  const float& maxDelta);
165  float ElectronLikelihood(const TCSlice& slc, const Trajectory& tj);
166  float KinkSignificance(TCSlice& slc,
167  Trajectory& tj1,
168  unsigned short end1,
169  Trajectory& tj2,
170  unsigned short end2,
171  unsigned short nPtsFit,
172  bool useChg,
173  bool prt);
174  float KinkSignificance(TCSlice& slc,
175  Trajectory& tj,
176  unsigned short kinkPt,
177  unsigned short nPtsFit,
178  bool useChg,
179  bool prt);
180  float ChgFracNearPos(const TCSlice& slc, const Point2_t& pos, const std::vector<int>& tjIDs);
181  float MaxHitDelta(TCSlice& slc, Trajectory& tj);
182  void ReverseTraj(TCSlice& slc, Trajectory& tj);
183  // returns the end of a trajectory that is closest to a point
184  unsigned short CloseEnd(const TCSlice& slc, const Trajectory& tj, const Point2_t& pos);
185  // returns the separation^2 between a point and a TP
186  float PointTrajSep2(float wire, float time, TrajPoint const& tp);
187  float PosSep(const Point2_t& pos1, const Point2_t& pos2);
188  float PosSep2(const Point2_t& pos1, const Point2_t& pos2);
189  // finds the point on trajectory tj that is closest to trajpoint tp
190  void TrajPointTrajDOCA(const TCSlice& slc,
191  TrajPoint const& tp,
192  Trajectory const& tj,
193  unsigned short& closePt,
194  float& minSep);
195  // returns the intersection position, intPos, of two trajectory points
196  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, Point2_t& pos);
197  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, float& x, float& y);
198  float MaxTjLen(const TCSlice& slc, std::vector<int>& tjIDs);
199  // Returns the separation distance between two trajectory points
200  float TrajPointSeparation(const TrajPoint& tp1, const TrajPoint& tp2);
201  float TrajLength(const Trajectory& tj);
202  // returns the separation^2 between two hits in WSE units
203  float HitSep2(const TCSlice& slc, unsigned int iht, unsigned int jht);
204  // Find the Distance Of Closest Approach between two trajectories, exceeding minSep
205  bool TrajTrajDOCA(const TCSlice& slc,
206  const Trajectory& tp1,
207  const Trajectory& tp2,
208  unsigned short& ipt1,
209  unsigned short& ipt2,
210  float& minSep);
211  bool TrajTrajDOCA(const TCSlice& slc,
212  const Trajectory& tp1,
213  const Trajectory& tp2,
214  unsigned short& ipt1,
215  unsigned short& ipt2,
216  float& minSep,
217  bool considerDeadWires);
218  // Calculates the angle between two TPs
219  float TwoTPAngle(const TrajPoint& tp1, const TrajPoint& tp2);
220  void TagJunkTj(TCSlice& slc, Trajectory& tj, bool prt);
221  std::vector<unsigned int> PutHitsInVector(const TCSlice& slc,
222  PFPStruct const& pfp,
223  HitStatus_t hitRequest);
224  // Put hits in each trajectory point into a flat vector.
225  std::vector<unsigned int> PutTrajHitsInVector(const Trajectory& tj, HitStatus_t hitRequest);
226  // returns true if a hit is associated with more than one point
227  bool HasDuplicateHits(const TCSlice& slc, Trajectory const& tj, bool prt);
228  // Project TP to a "wire position" Pos[0] and update Pos[1]
229  void MoveTPToWire(TrajPoint& tp, float wire);
230  bool PointInsideEnvelope(const Point2_t& Point, const std::vector<Point2_t>& Envelope);
231  bool SetMag(Vector2_t& v1, double mag);
232  void FindAlongTrans(Point2_t pos1, Vector2_t dir1, Point2_t pos2, Point2_t& alongTrans);
233  inline double
234  DotProd(const Vector2_t& v1, const Vector2_t& v2)
235  {
236  return v1[0] * v2[0] + v1[1] * v2[1];
237  }
238  double DeltaAngle(double Ang1, double Ang2);
239  double DeltaAngle2(double Ang1, double Ang2);
240  double DeltaAngle(const Point2_t& p1, const Point2_t& p2);
241  // Find the first (last) TPs, EndPt[0] (EndPt[1], that have charge
242  void SetEndPoints(Trajectory& tj);
243  // Returns the hit width using StartTick() and EndTick()
244  float TPHitsRMSTick(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
245  float TPHitsRMSTime(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
246  float HitsRMSTick(const TCSlice& slc,
247  const std::vector<unsigned int>& hitsInMultiplet,
248  HitStatus_t hitRequest);
249  float HitsRMSTime(const TCSlice& slc,
250  const std::vector<unsigned int>& hitsInMultiplet,
251  HitStatus_t hitRequest);
252  float HitsPosTick(const TCSlice& slc,
253  const std::vector<unsigned int>& hitsInMultiplet,
254  float& chg,
255  HitStatus_t hitRequest);
256  float HitsPosTime(const TCSlice& slc,
257  const std::vector<unsigned int>& hitsInMultiplet,
258  float& chg,
259  HitStatus_t hitRequest);
260  unsigned short NumHitsInTP(const TrajPoint& tp, HitStatus_t hitRequest);
261  unsigned short NumUsedHitsInTj(const TCSlice& slc, const Trajectory& tj);
262  unsigned short NearestPtWithChg(const TCSlice& slc, const Trajectory& tj, unsigned short thePt);
263  // Calculate MCS momentum
264  short MCSMom(const TCSlice& slc, const std::vector<int>& tjIDs);
265  short MCSMom(const TCSlice& slc, const Trajectory& tj);
266  short MCSMom(const TCSlice& slc,
267  const Trajectory& tj,
268  unsigned short FirstPt,
269  unsigned short lastPt);
270  // Calculate MCS theta RMS over the points specified. Returns MCS angle for the full length
271  double MCSThetaRMS(const TCSlice& slc,
272  const Trajectory& tj,
273  unsigned short firstPt,
274  unsigned short lastPt);
275  // Calculate MCS theta RMS over the entire length. Returns MCS angle for 1 WSE unit
276  float MCSThetaRMS(const TCSlice& slc, const Trajectory& tj);
277  void TjDeltaRMS(const TCSlice& slc,
278  const Trajectory& tj,
279  unsigned short firstPt,
280  unsigned short lastPt,
281  double& rms,
282  unsigned short& cnt);
283  void SetTPEnvironment(TCSlice& slc, CTP_t inCTP);
284  // Returns true if the trajectory has low hit multiplicity and is in a clean environment
285  bool TrajIsClean(TCSlice& slc, Trajectory& tj, bool prt);
286  void UpdateTjChgProperties(std::string inFcnLabel, TCSlice& slc, Trajectory& tj, bool prt);
287  void UpdateVxEnvironment(TCSlice& slc);
288  void UpdateVxEnvironment(TCSlice& slc, VtxStore& vx2, bool prt);
290  const TCSlice& slc,
291  const Point3_t& pos,
292  CTP_t inCTP);
293  // Make a bare trajectory point that only has position and direction defined
295  const TCSlice& slc,
296  const Point3_t& pos,
297  const Vector3_t& dir,
298  CTP_t inCTP);
299  bool MakeBareTrajPoint(const TCSlice& slc,
300  unsigned int fromHit,
301  unsigned int toHit,
302  TrajPoint& tp);
303  bool MakeBareTrajPoint(const TCSlice& slc,
304  float fromWire,
305  float fromTick,
306  float toWire,
307  float toTick,
308  CTP_t tCTP,
309  TrajPoint& tp);
310  bool MakeBareTrajPoint(const Point2_t& fromPos, const Point2_t& toPos, TrajPoint& tpOut);
311  bool MakeBareTrajPoint(const TCSlice& slc,
312  const TrajPoint& tpIn1,
313  const TrajPoint& tpIn2,
314  TrajPoint& tpOut);
315  unsigned short FarEnd(TCSlice& slc, const Trajectory& tj, const Point2_t& pos);
316  Vector2_t PointDirection(const Point2_t p1, const Point2_t p2);
317  void SetPDGCode(TCSlice& slc, Trajectory& tj);
318  void SetPDGCode(TCSlice& slc, unsigned short itj);
319  bool AnalyzeHits();
320  bool LongPulseHit(const recob::Hit& hit);
321  void FillWireHitRange(geo::TPCID inTPCID);
322  bool FillWireHitRange(detinfo::DetectorClocksData const& clockData,
323  detinfo::DetectorPropertiesData const& detProp,
324  TCSlice& slc);
325  // bool CheckWireHitRange(TCSlice& slc);
326  bool WireHitRangeOK(TCSlice& slc, const CTP_t& inCTP);
327  bool MergeAndStore(TCSlice& slc, unsigned int itj1, unsigned int itj2, bool doPrt);
328  std::vector<int> GetAssns(TCSlice& slc, std::string type1Name, int id, std::string type2Name);
329  // Start a trajectory going from fromHit to (toWire, toTick)
330  bool StartTraj(TCSlice& slc,
331  Trajectory& tj,
332  unsigned int fromhit,
333  unsigned int tohit,
334  unsigned short pass);
335  bool StartTraj(TCSlice& slc,
336  Trajectory& tj,
337  float fromWire,
338  float fromTick,
339  float toWire,
340  float toTick,
341  CTP_t& tCTP,
342  unsigned short pass);
343  bool Fit2D(short mode,
344  Point2_t inPt,
345  float& inPtErr,
346  Vector2_t& outVec,
347  Vector2_t& outVecErr,
348  float& chiDOF);
349  std::pair<unsigned short, unsigned short> GetSliceIndex(std::string typeName, int uID);
350  template <typename T>
351  std::vector<T> SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2);
352  template <typename T>
353  std::vector<T> SetDifference(const std::vector<T>& set1, const std::vector<T>& set2);
354  bool DecodeDebugString(std::string ctpwt);
355  // ****************************** Printing ******************************
356  void DumpTj();
357  void PrintDebugMode();
358  void PrintAll(detinfo::DetectorPropertiesData const& detProp, std::string someText);
359  void PrintP(std::string someText, mf::LogVerbatim& myprt, PFPStruct& pfp, bool& printHeader);
360  void Print3V(detinfo::DetectorPropertiesData const& detProp,
361  std::string someText,
362  mf::LogVerbatim& myprt,
363  Vtx3Store& vx3,
364  bool& printHeader);
365  void Print2V(std::string someText, mf::LogVerbatim& myprt, VtxStore& vx2, bool& printHeader);
366  void Print3S(detinfo::DetectorPropertiesData const& detProp,
367  std::string someText,
368  mf::LogVerbatim& myprt,
369  ShowerStruct3D& ss3);
370  void PrintT(std::string someText, mf::LogVerbatim& myprt, Trajectory& tj, bool& printHeader);
371  void PrintTrajectory(std::string someText,
372  const TCSlice& slc,
373  const Trajectory& tj,
374  unsigned short tPoint);
375  void PrintAllTraj(detinfo::DetectorPropertiesData const& detProp,
376  std::string someText,
377  TCSlice& slc,
378  unsigned short itj,
379  unsigned short ipt,
380  bool printVtx = true);
381  void PrintTPHeader(std::string someText);
382  void PrintTP(std::string someText,
383  const TCSlice& slc,
384  unsigned short ipt,
385  short dir,
386  unsigned short pass,
387  const TrajPoint& tp);
388  std::string TPEnvString(const TrajPoint& tp);
389  void PrintPFP(std::string someText, TCSlice& slc, const PFPStruct& pfp, bool printHeader);
390  void PrintPFPs(std::string someText, TCSlice& slc);
391  // Print clusters after calling MakeAllTrajClusters
392  void PrintClusters();
393  // Print a single hit in the standard format
394  std::string PrintHit(const TCHit& hit);
395  std::string PrintHitShort(const TCHit& hit);
396  // Print Trajectory position in the standard format
397  std::string PrintPos(const TCSlice& slc, const TrajPoint& tp);
398  std::string PrintPos(const TCSlice& slc, const Point2_t& pos);
399  std::string PrintEndFlag(const Trajectory& tj, unsigned short end);
400  std::string PrintEndFlag(const PFPStruct& pfp, unsigned short end);
401 
402  ////////////////////////////////////////////////
403  template <typename T>
404  std::vector<T>
405  SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2)
406  {
407  // returns a vector containing the elements of set1 and set2 that are common. This function
408  // is a replacement for std::set_intersection which fails in the following situation:
409  // set1 = {11 12 17 18} and set2 = {6 12 18}
410  // There is no requirement that the elements be sorted, unlike std::set_intersection
411  std::vector<T> shared;
412 
413  if (set1.empty()) return shared;
414  if (set2.empty()) return shared;
415  for (auto element1 : set1) {
416  // check for a common element
417  if (std::find(set2.begin(), set2.end(), element1) == set2.end()) continue;
418  // check for a duplicate
419  if (std::find(shared.begin(), shared.end(), element1) != shared.end()) continue;
420  shared.push_back(element1);
421  } // element1
422  return shared;
423  } // SetIntersection
424 
425  ////////////////////////////////////////////////
426  template <typename T>
427  std::vector<T>
428  SetDifference(const std::vector<T>& set1, const std::vector<T>& set2)
429  {
430  // returns the elements of set1 and set2 that are different
431  std::vector<T> different;
432  if (set1.empty() && set2.empty()) return different;
433  if (!set1.empty() && set2.empty()) return set1;
434  if (set1.empty() && !set2.empty()) return set2;
435  for (auto element1 : set1) {
436  // check for a common element
437  if (std::find(set2.begin(), set2.end(), element1) != set2.end()) continue;
438  // check for a duplicate
439  if (std::find(different.begin(), different.end(), element1) != different.end()) continue;
440  different.push_back(element1);
441  } // element1
442  for (auto element2 : set2) {
443  // check for a common element
444  if (std::find(set1.begin(), set1.end(), element2) != set1.end()) continue;
445  // check for a duplicate
446  if (std::find(different.begin(), different.end(), element2) != different.end()) continue;
447  different.push_back(element2);
448  } // element1
449  return different;
450  } // SetDifference
451 
452 } // namespace tca
453 
454 #endif // ifndef TRAJCLUSTERALGUTILS_H
void PrintAll(detinfo::DetectorPropertiesData const &detProp, std::string someText)
Definition: Utils.cxx:5519
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
float HitsPosTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:4277
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1335
void ReleaseHits(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1060
short MCSMom(const TCSlice &slc, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3466
unsigned short FarEnd(const TCSlice &slc, const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:3338
void SetEndPoints(Trajectory &tj)
Definition: Utils.cxx:3411
void FitPar(const TCSlice &slc, const Trajectory &tj, unsigned short originPt, unsigned short npts, short fitDir, ParFit &pFit, unsigned short usePar)
Definition: Utils.cxx:1217
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
Definition: Utils.cxx:1871
bool InTrajOK(TCSlice &slc, std::string someText)
Definition: Utils.cxx:1274
unsigned short CloseEnd(const TCSlice &slc, const Trajectory &tj, const Point2_t &pos)
Definition: Utils.cxx:2549
Reconstruction base classes.
struct of temporary 2D vertices (end points)
Definition: DataStructs.h:74
std::vector< int > GetAssns(TCSlice &slc, std::string type1Name, int id, std::string type2Name)
Definition: Utils.cxx:4847
std::vector< unsigned int > PutTrajHitsInVector(const Trajectory &tj, HitStatus_t hitRequest)
Definition: Utils.cxx:2752
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
std::array< double, 3 > Point3_t
Definition: DataStructs.h:43
bool SignalAtTp(TrajPoint &tp)
Definition: Utils.cxx:2002
void SetPDGCode(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:4348
std::string string
Definition: nybbler.cc:12
void Print2V(std::string someText, mf::LogVerbatim &myprt, VtxStore &vx2, bool &printHeader)
Definition: Utils.cxx:5766
void Print3V(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, Vtx3Store &vx3, bool &printHeader)
Definition: Utils.cxx:5689
void PrintPFP(std::string someText, TCSlice &slc, const PFPStruct &pfp, bool printHeader)
Definition: Utils.cxx:6371
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:3096
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
Definition: Utils.cxx:6193
void PrintClusters()
void PrintTP(std::string someText, const TCSlice &slc, unsigned short ipt, short dir, unsigned short pass, const TrajPoint &tp)
Definition: Utils.cxx:6294
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
bool WireHitRangeOK(TCSlice &slc, const CTP_t &inCTP)
Definition: Utils.cxx:4651
void UnsetUsedHits(TCSlice &slc, TrajPoint &tp)
Definition: Utils.cxx:1073
std::string PrintEndFlag(const PFPStruct &pfp, unsigned short end)
Definition: Utils.cxx:6461
void PrintT(std::string someText, mf::LogVerbatim &myprt, Trajectory &tj, bool &printHeader)
Definition: Utils.cxx:5858
bool StoreTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1087
float TpSumHitChg(const TCSlice &slc, TrajPoint const &tp)
Definition: Utils.cxx:2102
std::string PrintPos(const TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:6524
void ChkChgAsymmetry(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1739
float ExpectedHitsRMS(TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:1945
bool TrajClosestApproach(Trajectory const &tj, float x, float y, unsigned short &closePt, float &DOCA)
Definition: Utils.cxx:2688
void FillWireHitRange(geo::TPCID inTPCID)
Definition: Utils.cxx:4459
float TrajPointSeparation(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2678
void SetAngleCode(TrajPoint &tp)
Definition: Utils.cxx:771
void PrintP(std::string someText, mf::LogVerbatim &myprt, PFPStruct &pfp, bool &printHeader)
Definition: Utils.cxx:5603
float PointTrajDOCA(const TCSlice &slc, unsigned int iht, TrajPoint const &tp)
Definition: Utils.cxx:2570
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:2539
bool StartTraj(TCSlice &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
Definition: Utils.cxx:4999
string dir
bool MakeBareTrajPoint(const TCSlice &slc, unsigned int fromHit, unsigned int toHit, TrajPoint &tp)
Definition: Utils.cxx:4108
HitStatus_t
Definition: Utils.h:40
bool LongPulseHit(const recob::Hit &hit)
Definition: Utils.cxx:4450
float MCSThetaRMS(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:3539
float TPHitsRMSTime(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4200
unsigned short NumUsedHitsInTj(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:4312
std::string TPEnvString(const TrajPoint &tp)
Definition: Utils.cxx:6351
void PrintPFPs(std::string someText, TCSlice &slc)
Definition: Utils.cxx:6442
float MaxTjLen(const TCSlice &slc, std::vector< int > &tjIDs)
Definition: Utils.cxx:2628
void Print3S(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, ShowerStruct3D &ss3)
Definition: Utils.cxx:5817
bool MergeTjIntoPFP(TCSlice &slc, int mtjid, PFPStruct &pfp, bool prt)
Definition: Utils.cxx:511
double DeltaAngle2(double Ang1, double Ang2)
Definition: Utils.cxx:3391
std::vector< T > SetIntersection(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:405
std::string PrintHitShort(const TCHit &tch)
Definition: Utils.cxx:6504
TrajPoint MakeBareTP(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const Point3_t &pos, CTP_t inCTP)
Definition: Utils.cxx:4025
float OverlapFraction(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2)
Definition: Utils.cxx:711
float HitsRMSTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4235
bool CompatibleMerge(const TCSlice &slc, std::vector< int > &tjIDs, bool prt)
Definition: Utils.cxx:578
std::vector< unsigned int > PutHitsInVector(const TCSlice &slc, PFPStruct const &pfp, HitStatus_t hitRequest)
Definition: Utils.cxx:2729
float HitSep2(const TCSlice &slc, unsigned int iht, unsigned int jht)
Definition: Utils.cxx:2536
int NeutrinoPrimaryTjID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:442
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4244
struct of temporary 3D vertices
Definition: DataStructs.h:106
void PrintAllTraj(detinfo::DetectorPropertiesData const &detProp, std::string someText, TCSlice &slc, unsigned short itj, unsigned short ipt, bool prtVtx)
Definition: Utils.cxx:5950
int PrimaryID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:465
std::array< float, 2 > Point2_t
Definition: DataStructs.h:45
int PDGCodeVote(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:3351
bool TrajIsClean(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:3440
float DeadWireCount(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2139
bool BraggSplit(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1442
unsigned short NearbyCleanPt(const TCSlice &slc, const Trajectory &tj, unsigned short end)
Definition: Utils.cxx:2954
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:2547
void DumpTj()
Definition: Utils.cxx:5398
HLTPathStatus const pass
float ElectronLikelihood(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:3214
float TwoTPAngle(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2719
float KinkSignificance(TCSlice &slc, Trajectory &tj1, unsigned short end1, Trajectory &tj2, unsigned short end2, unsigned short nPtsFit, bool useChg, bool prt)
Definition: Utils.cxx:3054
float ChgFracNearPos(const TCSlice &slc, const Point2_t &pos, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3234
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:2841
float ChgFracBetween(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, Point3_t pos1, Point3_t pos2)
Definition: PFPUtils.cxx:3196
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
Definition: Utils.cxx:45
bool PointInsideEnvelope(const Point2_t &Point, const std::vector< Point2_t > &Envelope)
Definition: Utils.cxx:3321
void ChkEndKink(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1705
void TagJunkTj(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:2780
void MakeTrajectoryObsolete(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2182
float PointTrajDOCA2(const TCSlice &slc, float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2588
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2571
unsigned short GetPFPIndex(const TCSlice &slc, int tjID)
Definition: Utils.cxx:1048
void FitTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:806
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:6514
bool Fit2D(short mode, Point2_t inPt, float &inPtErr, Vector2_t &outVec, Vector2_t &outVecErr, float &chiDOF)
Definition: Utils.cxx:5127
bool SplitTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, unsigned short itj, float XPos, bool makeVx2, bool prt)
Definition: Utils.cxx:2270
void TrajPointTrajDOCA(const TCSlice &slc, TrajPoint const &tp, Trajectory const &tj, unsigned short &closePt, float &minSep)
Definition: Utils.cxx:2433
bool valsDecreasing(const SortEntry &c1, const SortEntry &c2)
Definition: Utils.cxx:38
General LArSoft Utilities.
double DotProd(const Vector2_t &v1, const Vector2_t &v2)
Definition: Utils.h:234
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
float MaxChargeAsymmetry(TCSlice &slc, std::vector< int > &tjIDs)
Definition: Utils.cxx:372
unsigned short NearestPtWithChg(const TCSlice &slc, const Trajectory &tj, unsigned short thePt)
Definition: Utils.cxx:3520
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:2582
std::array< double, 2 > Vector2_t
Definition: DataStructs.h:46
void ReverseTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:3292
unsigned short NumHitsInTP(const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4326
void TrimEndPts(std::string fcnLabel, TCSlice &slc, Trajectory &tj, const std::vector< float > &fQualityCuts, bool prt)
Definition: Utils.cxx:1598
void DefineTjParents(TCSlice &slc, bool prt)
Definition: Utils.cxx:166
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:4287
Detector simulation of raw signals on wires.
void UpdateTjChgProperties(std::string inFcnLabel, TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:3671
bool MergeAndStore(TCSlice &slc, unsigned int itj1, unsigned int itj2, bool doPrt)
Definition: Utils.cxx:4662
float PointPull(const PFPStruct &pfp, const TP3D &tp3d)
Definition: PFPUtils.cxx:2814
void RestoreObsoleteTrajectory(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2195
void TrajIntersection(TrajPoint const &tp1, TrajPoint const &tp2, Point2_t &pos)
Definition: Utils.cxx:2602
unsigned int CTP_t
Definition: DataStructs.h:49
bool DecodeDebugString(std::string strng)
Definition: Utils.cxx:5214
bool AnalyzeHits()
Definition: Utils.cxx:4392
Contains all timing reference information for the detector.
float MaxHitDelta(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:3274
float TrajLength(const Trajectory &tj)
Definition: Utils.cxx:2644
void UpdateVxEnvironment(TCSlice &slc)
Definition: Utils.cxx:3860
bool valsIncreasing(const SortEntry &c1, const SortEntry &c2)
Definition: Utils.cxx:39
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2564
void TrimHiChgEndPts(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1555
unsigned short PDGCodeIndex(int PDGCode)
Definition: Utils.cxx:2169
std::pair< unsigned short, unsigned short > GetSliceIndex(std::string typeName, int uID)
Definition: Utils.cxx:5086
float PointTrajSep2(float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2561
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:44
bool SignalAtTpInSlc(const TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:1960
void PrintDebugMode()
Definition: Utils.cxx:5448
std::vector< T > SetDifference(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:428
list x
Definition: train.py:276
bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick)
Definition: Utils.cxx:2069
void TjDeltaRMS(const TCSlice &slc, const Trajectory &tj, unsigned short firstPt, unsigned short lastPt, double &rms, unsigned short &cnt)
Definition: Utils.cxx:3582
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:2975
bool SignalBetween(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2, const float &MinWireSignalFraction)
Definition: Utils.cxx:1805
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
void MoveTPToWire(TrajPoint &tp, float wire)
Definition: Utils.cxx:2829
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
Definition: Utils.cxx:2114
void MergeGhostTjs(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:2218
int PrimaryUID(const TCSlice &slc, const PFPStruct &pfp)
Definition: Utils.cxx:485
bool TrajTrajDOCA(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2, unsigned short &ipt1, unsigned short &ipt2, float &minSep)
Definition: Utils.cxx:2458
LArSoft geometry interface.
Definition: ChannelGeo.h:16
float TPHitsRMSTick(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4207
void PrintTPHeader(std::string someText)
Definition: Utils.cxx:6285
unsigned short AngleRange(TrajPoint const &tp)
Definition: Utils.cxx:764
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:3624
bool HasDuplicateHits(const TCSlice &slc, Trajectory const &tj, bool prt)
Definition: Utils.cxx:2810
void ChkMissedKink(TCSlice &slc, Trajectory &tj, bool prt)