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 namespace tca {
36 
37  typedef enum {
41  } HitStatus_t;
42 
43  // ****************************** General purpose ******************************
44  // dressed muons
45  void MakeHaloTj(TCSlice& slc, Trajectory& muTj, bool prt);
46  void DefineTjParents(TCSlice& slc, bool prt);
47  float MaxChargeAsymmetry(TCSlice& slc, std::vector<int>& tjIDs);
48  int PDGCodeVote(const TCSlice& slc, const std::vector<int>& tjIDs);
49  int NeutrinoPrimaryTjID(const TCSlice& slc, const Trajectory& tj);
50  int PrimaryID(const TCSlice& slc, const Trajectory& tj);
51  int PrimaryUID(const TCSlice& slc, const PFPStruct& pfp);
52  bool MergeTjIntoPFP(TCSlice& slc, int mtjid, PFPStruct& pfp, bool prt);
53  float PointPull(TCSlice& slc, Point2_t pos, float chg, const Trajectory& tj);
54  bool CompatibleMerge(const TCSlice& slc, std::vector<int>& tjIDs, bool prt);
55  bool CompatibleMerge(const TCSlice& slc, const Trajectory& tj1, const Trajectory& tj2, bool prt);
56  float OverlapFraction(const TCSlice& slc, const Trajectory& tj1, const Trajectory& tj2);
57  unsigned short AngleRange(TrajPoint const& tp);
58  void SetAngleCode(TrajPoint& tp);
59  unsigned short AngleRange(float angle);
60  void FitTraj(TCSlice& slc, Trajectory& tj);
61  void FitTraj(TCSlice& slc,
62  Trajectory& tj,
63  unsigned short originPt,
64  unsigned short npts,
65  short fitDir,
66  TrajPoint& tpFit);
67  unsigned short GetPFPIndex(const TCSlice& slc, int tjID);
68  void ReleaseHits(TCSlice& slc, Trajectory& tj);
69  void UnsetUsedHits(TCSlice& slc, TrajPoint& tp);
70  bool StoreTraj(TCSlice& slc, Trajectory& tj);
71  void FitPar(const TCSlice& slc,
72  const Trajectory& tj,
73  unsigned short originPt,
74  unsigned short npts,
75  short fitDir,
76  ParFit& pFit,
77  unsigned short usePar);
78  bool InTrajOK(TCSlice& slc, std::string someText);
79  void CheckTrajBeginChg(TCSlice& slc, unsigned short itj);
80  bool BraggSplit(TCSlice& slc, unsigned short itj);
81  void ChkEndKink(TCSlice& slc, Trajectory& tj, bool prt);
82  void TrimHiChgEndPts(TCSlice& slc, Trajectory& tj, bool prt);
83  void TrimEndPts(std::string fcnLabel,
84  TCSlice& slc,
85  Trajectory& tj,
86  const std::vector<float>& fQualityCuts,
87  bool prt);
88  void ChkMissedKink(TCSlice& slc, Trajectory& tj, bool prt);
89  void ChkChgAsymmetry(TCSlice& slc, Trajectory& tj, bool prt);
90  bool SignalBetween(const TCSlice& slc,
91  const TrajPoint& tp1,
92  const TrajPoint& tp2,
93  const float& MinWireSignalFraction);
94  bool SignalBetween(const TCSlice& slc,
95  TrajPoint tp,
96  float toPos0,
97  const float& MinWireSignalFraction);
98  float ChgFracBetween(const TCSlice& slc, TrajPoint tp, float toPos0);
99  bool TrajHitsOK(TCSlice& slc,
100  const std::vector<unsigned int>& iHitsInMultiplet,
101  const std::vector<unsigned int>& jHitsInMultiplet);
102  bool TrajHitsOK(TCSlice& slc, const unsigned int iht, const unsigned int jht);
103  float ExpectedHitsRMS(TCSlice& slc, const TrajPoint& tp);
104  bool SignalAtTpInSlc(const TCSlice& slc, const TrajPoint& tp);
105  bool SignalAtTp(TrajPoint& tp);
106  bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick);
107  float TpSumHitChg(const TCSlice& slc, TrajPoint const& tp);
108  unsigned short NumPtsWithCharge(const TCSlice& slc, const Trajectory& tj, bool includeDeadWires);
109  unsigned short NumPtsWithCharge(const TCSlice& slc,
110  const Trajectory& tj,
111  bool includeDeadWires,
112  unsigned short firstPt,
113  unsigned short lastPt);
114  float DeadWireCount(const TCSlice& slc, const TrajPoint& tp1, const TrajPoint& tp2);
115  float DeadWireCount(const TCSlice& slc,
116  const float& inWirePos1,
117  const float& inWirePos2,
118  CTP_t tCTP);
119  unsigned short PDGCodeIndex(int PDGCode);
120  void MakeTrajectoryObsolete(TCSlice& slc, unsigned int itj);
121  void RestoreObsoleteTrajectory(TCSlice& slc, unsigned int itj);
122  void MergeGhostTjs(TCSlice& slc, CTP_t inCTP);
123  // Split the allTraj trajectory itj at position pos into two trajectories
124  // with an optional vertex assignment
125  bool SplitTraj(TCSlice& slc,
126  unsigned short itj,
127  unsigned short pos,
128  unsigned short ivx,
129  bool prt);
130  bool SplitTraj(detinfo::DetectorPropertiesData const& detProp,
131  TCSlice& slc,
132  unsigned short itj,
133  float XPos,
134  bool makeVx2,
135  bool prt);
136  bool TrajClosestApproach(Trajectory const& tj,
137  float x,
138  float y,
139  unsigned short& closePt,
140  float& DOCA);
141  // returns the DOCA between a hit and a trajectory
142  float PointTrajDOCA(const TCSlice& slc, unsigned int iht, TrajPoint const& tp);
143  // returns the DOCA between a (W,T) point and a trajectory
144  float PointTrajDOCA(const TCSlice& slc, float wire, float time, TrajPoint const& tp);
145  // returns the DOCA^2 between a point and a trajectory
146  float PointTrajDOCA2(const TCSlice& slc, float wire, float time, TrajPoint const& tp);
147  // Fills tp.Hits sets tp.UseHit true for hits that are close to tp.Pos. Returns true if there are
148  // close hits OR if the wire at this position is dead
149  bool FindCloseHits(TCSlice& slc, TrajPoint& tp, float const& maxDelta, HitStatus_t hitRequest);
150  std::vector<unsigned int> FindCloseHits(const TCSlice& slc,
151  std::array<int, 2> const& wireWindow,
152  Point2_t const& timeWindow,
153  const unsigned short plane,
154  HitStatus_t hitRequest,
155  bool usePeakTime,
156  bool& hitsNear);
157  unsigned short NearbyCleanPt(const TCSlice& slc, const Trajectory& tj, unsigned short nearPt);
158  std::vector<int> FindCloseTjs(const TCSlice& slc,
159  const TrajPoint& fromTp,
160  const TrajPoint& toTp,
161  const float& maxDelta);
162  float ElectronLikelihood(const TCSlice& slc, const Trajectory& tj);
163  float KinkSignificance(TCSlice& slc,
164  Trajectory& tj1,
165  unsigned short end1,
166  Trajectory& tj2,
167  unsigned short end2,
168  unsigned short nPtsFit,
169  bool useChg,
170  bool prt);
171  float KinkSignificance(TCSlice& slc,
172  Trajectory& tj,
173  unsigned short kinkPt,
174  unsigned short nPtsFit,
175  bool useChg,
176  bool prt);
177  float ChgFracNearPos(const TCSlice& slc, const Point2_t& pos, const std::vector<int>& tjIDs);
178  float MaxHitDelta(TCSlice& slc, Trajectory& tj);
179  void ReverseTraj(TCSlice& slc, Trajectory& tj);
180  // returns the end of a trajectory that is closest to a point
181  unsigned short CloseEnd(const TCSlice& slc, const Trajectory& tj, const Point2_t& pos);
182  // returns the separation^2 between a point and a TP
183  float PointTrajSep2(float wire, float time, TrajPoint const& tp);
184  float PosSep(const Point2_t& pos1, const Point2_t& pos2);
185  float PosSep2(const Point2_t& pos1, const Point2_t& pos2);
186  // finds the point on trajectory tj that is closest to trajpoint tp
187  void TrajPointTrajDOCA(const TCSlice& slc,
188  TrajPoint const& tp,
189  Trajectory const& tj,
190  unsigned short& closePt,
191  float& minSep);
192  // returns the intersection position, intPos, of two trajectory points
193  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, Point2_t& pos);
194  void TrajIntersection(TrajPoint const& tp1, TrajPoint const& tp2, float& x, float& y);
195  float MaxTjLen(const TCSlice& slc, std::vector<int>& tjIDs);
196  // Returns the separation distance between two trajectory points
197  float TrajPointSeparation(const TrajPoint& tp1, const TrajPoint& tp2);
198  float TrajLength(const Trajectory& tj);
199  // returns the separation^2 between two hits in WSE units
200  float HitSep2(const TCSlice& slc, unsigned int iht, unsigned int jht);
201  // Find the Distance Of Closest Approach between two trajectories, exceeding minSep
202  bool TrajTrajDOCA(const TCSlice& slc,
203  const Trajectory& tp1,
204  const Trajectory& tp2,
205  unsigned short& ipt1,
206  unsigned short& ipt2,
207  float& minSep);
208  bool TrajTrajDOCA(const TCSlice& slc,
209  const Trajectory& tp1,
210  const Trajectory& tp2,
211  unsigned short& ipt1,
212  unsigned short& ipt2,
213  float& minSep,
214  bool considerDeadWires);
215  // Calculates the angle between two TPs
216  float TwoTPAngle(const TrajPoint& tp1, const TrajPoint& tp2);
217  void TagJunkTj(TCSlice& slc, Trajectory& tj, bool prt);
218  std::vector<unsigned int> PutHitsInVector(const TCSlice& slc,
219  PFPStruct const& pfp,
220  HitStatus_t hitRequest);
221  // Put hits in each trajectory point into a flat vector.
222  std::vector<unsigned int> PutTrajHitsInVector(const Trajectory& tj, HitStatus_t hitRequest);
223  // returns true if a hit is associated with more than one point
224  bool HasDuplicateHits(const TCSlice& slc, Trajectory const& tj, bool prt);
225  // Project TP to a "wire position" Pos[0] and update Pos[1]
226  void MoveTPToWire(TrajPoint& tp, float wire);
227  bool PointInsideEnvelope(const Point2_t& Point, const std::vector<Point2_t>& Envelope);
228  bool SetMag(Vector2_t& v1, double mag);
229  void FindAlongTrans(Point2_t pos1, Vector2_t dir1, Point2_t pos2, Point2_t& alongTrans);
230  inline double
231  DotProd(const Vector2_t& v1, const Vector2_t& v2)
232  {
233  return v1[0] * v2[0] + v1[1] * v2[1];
234  }
235  double DeltaAngle(double Ang1, double Ang2);
236  double DeltaAngle2(double Ang1, double Ang2);
237  double DeltaAngle(const Point2_t& p1, const Point2_t& p2);
238  // Find the first (last) TPs, EndPt[0] (EndPt[1], that have charge
239  void SetEndPoints(Trajectory& tj);
240  // Returns the hit width using StartTick() and EndTick()
241  float TPHitsRMSTick(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
242  float TPHitsRMSTime(const TCSlice& slc, const TrajPoint& tp, HitStatus_t hitRequest);
243  float HitsRMSTick(const TCSlice& slc,
244  const std::vector<unsigned int>& hitsInMultiplet,
245  HitStatus_t hitRequest);
246  float HitsRMSTime(const TCSlice& slc,
247  const std::vector<unsigned int>& hitsInMultiplet,
248  HitStatus_t hitRequest);
249  float HitsPosTick(const TCSlice& slc,
250  const std::vector<unsigned int>& hitsInMultiplet,
251  float& chg,
252  HitStatus_t hitRequest);
253  float HitsPosTime(const TCSlice& slc,
254  const std::vector<unsigned int>& hitsInMultiplet,
255  float& chg,
256  HitStatus_t hitRequest);
257  unsigned short NumHitsInTP(const TrajPoint& tp, HitStatus_t hitRequest);
258  unsigned short NumUsedHitsInTj(const TCSlice& slc, const Trajectory& tj);
259  unsigned short NearestPtWithChg(const TCSlice& slc, const Trajectory& tj, unsigned short thePt);
260  // Calculate MCS momentum
261  short MCSMom(const TCSlice& slc, const std::vector<int>& tjIDs);
262  short MCSMom(const TCSlice& slc, const Trajectory& tj);
263  short MCSMom(const TCSlice& slc,
264  const Trajectory& tj,
265  unsigned short FirstPt,
266  unsigned short lastPt);
267  // Calculate MCS theta RMS over the points specified. Returns MCS angle for the full length
268  double MCSThetaRMS(const TCSlice& slc,
269  const Trajectory& tj,
270  unsigned short firstPt,
271  unsigned short lastPt);
272  // Calculate MCS theta RMS over the entire length. Returns MCS angle for 1 WSE unit
273  float MCSThetaRMS(const TCSlice& slc, const Trajectory& tj);
274  void TjDeltaRMS(const TCSlice& slc,
275  const Trajectory& tj,
276  unsigned short firstPt,
277  unsigned short lastPt,
278  double& rms,
279  unsigned short& cnt);
280  void SetTPEnvironment(TCSlice& slc, CTP_t inCTP);
281  // Returns true if the trajectory has low hit multiplicity and is in a clean environment
282  bool TrajIsClean(TCSlice& slc, Trajectory& tj, bool prt);
283  void UpdateTjChgProperties(std::string inFcnLabel, TCSlice& slc, Trajectory& tj, bool prt);
284  void UpdateVxEnvironment(TCSlice& slc);
285  void UpdateVxEnvironment(TCSlice& slc, VtxStore& vx2, bool prt);
287  const TCSlice& slc,
288  const Point3_t& pos,
289  CTP_t inCTP);
290  // Make a bare trajectory point that only has position and direction defined
292  const TCSlice& slc,
293  const Point3_t& pos,
294  const Vector3_t& dir,
295  CTP_t inCTP);
296  bool MakeBareTrajPoint(const TCSlice& slc,
297  unsigned int fromHit,
298  unsigned int toHit,
299  TrajPoint& tp);
300  bool MakeBareTrajPoint(const TCSlice& slc,
301  float fromWire,
302  float fromTick,
303  float toWire,
304  float toTick,
305  CTP_t tCTP,
306  TrajPoint& tp);
307  bool MakeBareTrajPoint(const Point2_t& fromPos, const Point2_t& toPos, TrajPoint& tpOut);
308  bool MakeBareTrajPoint(const TCSlice& slc,
309  const TrajPoint& tpIn1,
310  const TrajPoint& tpIn2,
311  TrajPoint& tpOut);
312  unsigned short FarEnd(TCSlice& slc, const Trajectory& tj, const Point2_t& pos);
313  Vector2_t PointDirection(const Point2_t p1, const Point2_t p2);
314  void SetPDGCode(TCSlice& slc, Trajectory& tj);
315  void SetPDGCode(TCSlice& slc, unsigned short itj);
316  bool AnalyzeHits();
317  bool LongPulseHit(const recob::Hit& hit);
318  void FillWireHitRange(geo::TPCID inTPCID);
319  bool FillWireHitRange(detinfo::DetectorClocksData const& clockData,
320  detinfo::DetectorPropertiesData const& detProp,
321  TCSlice& slc);
322  // bool CheckWireHitRange(TCSlice& slc);
323  bool WireHitRangeOK(TCSlice& slc, const CTP_t& inCTP);
324  bool MergeAndStore(TCSlice& slc, unsigned int itj1, unsigned int itj2, bool doPrt);
325  std::vector<int> GetAssns(TCSlice& slc, std::string type1Name, int id, std::string type2Name);
326  // Start a trajectory going from fromHit to (toWire, toTick)
327  bool StartTraj(TCSlice& slc,
328  Trajectory& tj,
329  unsigned int fromhit,
330  unsigned int tohit,
331  unsigned short pass);
332  bool StartTraj(TCSlice& slc,
333  Trajectory& tj,
334  float fromWire,
335  float fromTick,
336  float toWire,
337  float toTick,
338  CTP_t& tCTP,
339  unsigned short pass);
340  bool Fit2D(short mode,
341  Point2_t inPt,
342  float& inPtErr,
343  Vector2_t& outVec,
344  Vector2_t& outVecErr,
345  float& chiDOF);
346  std::pair<unsigned short, unsigned short> GetSliceIndex(std::string typeName, int uID);
347  template <typename T>
348  std::vector<T> SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2);
349  template <typename T>
350  std::vector<T> SetDifference(const std::vector<T>& set1, const std::vector<T>& set2);
351  bool DecodeDebugString(std::string ctpwt);
352  // ****************************** Printing ******************************
353  void DumpTj();
354  void PrintDebugMode();
355  void PrintAll(detinfo::DetectorPropertiesData const& detProp, std::string someText);
356  void PrintP(std::string someText, mf::LogVerbatim& myprt, PFPStruct& pfp, bool& printHeader);
357  void Print3V(detinfo::DetectorPropertiesData const& detProp,
358  std::string someText,
359  mf::LogVerbatim& myprt,
360  Vtx3Store& vx3,
361  bool& printHeader);
362  void Print2V(std::string someText, mf::LogVerbatim& myprt, VtxStore& vx2, bool& printHeader);
363  void Print3S(detinfo::DetectorPropertiesData const& detProp,
364  std::string someText,
365  mf::LogVerbatim& myprt,
366  ShowerStruct3D& ss3);
367  void PrintT(std::string someText, mf::LogVerbatim& myprt, Trajectory& tj, bool& printHeader);
368  void PrintTrajectory(std::string someText,
369  const TCSlice& slc,
370  const Trajectory& tj,
371  unsigned short tPoint);
372  void PrintAllTraj(detinfo::DetectorPropertiesData const& detProp,
373  std::string someText,
374  TCSlice& slc,
375  unsigned short itj,
376  unsigned short ipt,
377  bool printVtx = true);
378  void PrintTPHeader(std::string someText);
379  void PrintTP(std::string someText,
380  const TCSlice& slc,
381  unsigned short ipt,
382  short dir,
383  unsigned short pass,
384  const TrajPoint& tp);
385  std::string TPEnvString(const TrajPoint& tp);
386  void PrintPFP(std::string someText, TCSlice& slc, const PFPStruct& pfp, bool printHeader);
387  void PrintPFPs(std::string someText, TCSlice& slc);
388  // Print clusters after calling MakeAllTrajClusters
389  void PrintClusters();
390  // Print a single hit in the standard format
391  std::string PrintHit(const TCHit& hit);
392  std::string PrintHitShort(const TCHit& hit);
393  // Print Trajectory position in the standard format
394  std::string PrintPos(const TCSlice& slc, const TrajPoint& tp);
395  std::string PrintPos(const TCSlice& slc, const Point2_t& pos);
396  std::string PrintEndFlag(const Trajectory& tj, unsigned short end);
397  std::string PrintEndFlag(const PFPStruct& pfp, unsigned short end);
398 
399  ////////////////////////////////////////////////
400  template <typename T>
401  std::vector<T>
402  SetIntersection(const std::vector<T>& set1, const std::vector<T>& set2)
403  {
404  // returns a vector containing the elements of set1 and set2 that are common. This function
405  // is a replacement for std::set_intersection which fails in the following situation:
406  // set1 = {11 12 17 18} and set2 = {6 12 18}
407  // There is no requirement that the elements be sorted, unlike std::set_intersection
408  std::vector<T> shared;
409 
410  if (set1.empty()) return shared;
411  if (set2.empty()) return shared;
412  for (auto element1 : set1) {
413  // check for a common element
414  if (std::find(set2.begin(), set2.end(), element1) == set2.end()) continue;
415  // check for a duplicate
416  if (std::find(shared.begin(), shared.end(), element1) != shared.end()) continue;
417  shared.push_back(element1);
418  } // element1
419  return shared;
420  } // SetIntersection
421 
422  ////////////////////////////////////////////////
423  template <typename T>
424  std::vector<T>
425  SetDifference(const std::vector<T>& set1, const std::vector<T>& set2)
426  {
427  // returns the elements of set1 and set2 that are different
428  std::vector<T> different;
429  if (set1.empty() && set2.empty()) return different;
430  if (!set1.empty() && set2.empty()) return set1;
431  if (set1.empty() && !set2.empty()) return set2;
432  for (auto element1 : set1) {
433  // check for a common element
434  if (std::find(set2.begin(), set2.end(), element1) != set2.end()) continue;
435  // check for a duplicate
436  if (std::find(different.begin(), different.end(), element1) != different.end()) continue;
437  different.push_back(element1);
438  } // element1
439  for (auto element2 : set2) {
440  // check for a common element
441  if (std::find(set1.begin(), set1.end(), element2) != set1.end()) continue;
442  // check for a duplicate
443  if (std::find(different.begin(), different.end(), element2) != different.end()) continue;
444  different.push_back(element2);
445  } // element1
446  return different;
447  } // SetDifference
448 
449 } // namespace tca
450 
451 #endif // ifndef TRAJCLUSTERALGUTILS_H
void PrintAll(detinfo::DetectorPropertiesData const &detProp, std::string someText)
Definition: Utils.cxx:5529
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:4287
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1345
void ReleaseHits(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1070
short MCSMom(const TCSlice &slc, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3476
unsigned short FarEnd(const TCSlice &slc, const PFPStruct &pfp, const Point3_t &pos)
Definition: PFPUtils.cxx:3206
void SetEndPoints(Trajectory &tj)
Definition: Utils.cxx:3421
void FitPar(const TCSlice &slc, const Trajectory &tj, unsigned short originPt, unsigned short npts, short fitDir, ParFit &pFit, unsigned short usePar)
Definition: Utils.cxx:1227
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
Definition: Utils.cxx:1881
bool InTrajOK(TCSlice &slc, std::string someText)
Definition: Utils.cxx:1284
unsigned short CloseEnd(const TCSlice &slc, const Trajectory &tj, const Point2_t &pos)
Definition: Utils.cxx:2559
Reconstruction base classes.
struct of temporary 2D vertices (end points)
Definition: DataStructs.h:70
std::vector< int > GetAssns(TCSlice &slc, std::string type1Name, int id, std::string type2Name)
Definition: Utils.cxx:4857
std::vector< unsigned int > PutTrajHitsInVector(const Trajectory &tj, HitStatus_t hitRequest)
Definition: Utils.cxx:2762
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
std::array< double, 3 > Point3_t
Definition: DataStructs.h:39
bool SignalAtTp(TrajPoint &tp)
Definition: Utils.cxx:2012
void SetPDGCode(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:4358
std::string string
Definition: nybbler.cc:12
void Print2V(std::string someText, mf::LogVerbatim &myprt, VtxStore &vx2, bool &printHeader)
Definition: Utils.cxx:5776
void Print3V(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, Vtx3Store &vx3, bool &printHeader)
Definition: Utils.cxx:5699
void PrintPFP(std::string someText, TCSlice &slc, const PFPStruct &pfp, bool printHeader)
Definition: Utils.cxx:6381
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
Definition: PFPUtils.cxx:2964
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
Definition: Utils.cxx:6203
void PrintClusters()
void PrintTP(std::string someText, const TCSlice &slc, unsigned short ipt, short dir, unsigned short pass, const TrajPoint &tp)
Definition: Utils.cxx:6304
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
bool WireHitRangeOK(TCSlice &slc, const CTP_t &inCTP)
Definition: Utils.cxx:4661
void UnsetUsedHits(TCSlice &slc, TrajPoint &tp)
Definition: Utils.cxx:1083
std::string PrintEndFlag(const PFPStruct &pfp, unsigned short end)
Definition: Utils.cxx:6471
void PrintT(std::string someText, mf::LogVerbatim &myprt, Trajectory &tj, bool &printHeader)
Definition: Utils.cxx:5868
bool StoreTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1097
float TpSumHitChg(const TCSlice &slc, TrajPoint const &tp)
Definition: Utils.cxx:2112
std::string PrintPos(const TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:6534
void ChkChgAsymmetry(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1749
float ExpectedHitsRMS(TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:1955
bool TrajClosestApproach(Trajectory const &tj, float x, float y, unsigned short &closePt, float &DOCA)
Definition: Utils.cxx:2698
void FillWireHitRange(geo::TPCID inTPCID)
Definition: Utils.cxx:4469
float TrajPointSeparation(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2688
void SetAngleCode(TrajPoint &tp)
Definition: Utils.cxx:781
void PrintP(std::string someText, mf::LogVerbatim &myprt, PFPStruct &pfp, bool &printHeader)
Definition: Utils.cxx:5613
float PointTrajDOCA(const TCSlice &slc, unsigned int iht, TrajPoint const &tp)
Definition: Utils.cxx:2580
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
Definition: PFPUtils.cxx:2416
bool StartTraj(TCSlice &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
Definition: Utils.cxx:5009
string dir
bool MakeBareTrajPoint(const TCSlice &slc, unsigned int fromHit, unsigned int toHit, TrajPoint &tp)
Definition: Utils.cxx:4118
HitStatus_t
Definition: Utils.h:37
bool LongPulseHit(const recob::Hit &hit)
Definition: Utils.cxx:4460
float MCSThetaRMS(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:3549
float TPHitsRMSTime(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4210
unsigned short NumUsedHitsInTj(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:4322
std::string TPEnvString(const TrajPoint &tp)
Definition: Utils.cxx:6361
void PrintPFPs(std::string someText, TCSlice &slc)
Definition: Utils.cxx:6452
float MaxTjLen(const TCSlice &slc, std::vector< int > &tjIDs)
Definition: Utils.cxx:2638
void Print3S(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, ShowerStruct3D &ss3)
Definition: Utils.cxx:5827
bool MergeTjIntoPFP(TCSlice &slc, int mtjid, PFPStruct &pfp, bool prt)
Definition: Utils.cxx:521
double DeltaAngle2(double Ang1, double Ang2)
Definition: Utils.cxx:3401
std::vector< T > SetIntersection(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:402
std::string PrintHitShort(const TCHit &tch)
Definition: Utils.cxx:6514
TrajPoint MakeBareTP(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const Point3_t &pos, CTP_t inCTP)
Definition: Utils.cxx:4035
float OverlapFraction(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2)
Definition: Utils.cxx:721
float HitsRMSTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4245
bool CompatibleMerge(const TCSlice &slc, std::vector< int > &tjIDs, bool prt)
Definition: Utils.cxx:588
double y
std::vector< unsigned int > PutHitsInVector(const TCSlice &slc, PFPStruct const &pfp, HitStatus_t hitRequest)
Definition: Utils.cxx:2739
float HitSep2(const TCSlice &slc, unsigned int iht, unsigned int jht)
Definition: Utils.cxx:2546
const HLTPathStatus pass
int NeutrinoPrimaryTjID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:452
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:4254
struct of temporary 3D vertices
Definition: DataStructs.h:102
void PrintAllTraj(detinfo::DetectorPropertiesData const &detProp, std::string someText, TCSlice &slc, unsigned short itj, unsigned short ipt, bool prtVtx)
Definition: Utils.cxx:5960
int PrimaryID(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:475
std::array< float, 2 > Point2_t
Definition: DataStructs.h:41
int PDGCodeVote(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:3219
bool TrajIsClean(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:3450
float DeadWireCount(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2149
bool BraggSplit(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1452
unsigned short NearbyCleanPt(const TCSlice &slc, const Trajectory &tj, unsigned short end)
Definition: Utils.cxx:2964
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
Definition: PFPUtils.cxx:2424
void DumpTj()
Definition: Utils.cxx:5408
float ElectronLikelihood(const TCSlice &slc, const Trajectory &tj)
Definition: Utils.cxx:3224
float TwoTPAngle(const TrajPoint &tp1, const TrajPoint &tp2)
Definition: Utils.cxx:2729
float KinkSignificance(TCSlice &slc, Trajectory &tj1, unsigned short end1, Trajectory &tj2, unsigned short end2, unsigned short nPtsFit, bool useChg, bool prt)
Definition: Utils.cxx:3064
float ChgFracNearPos(const TCSlice &slc, const Point2_t &pos, const std::vector< int > &tjIDs)
Definition: Utils.cxx:3244
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:2851
void TrimEndPts(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, PFPStruct &pfp, bool prt)
Definition: PFPUtils.cxx:1866
float ChgFracBetween(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, Point3_t pos1, Point3_t pos2)
Definition: PFPUtils.cxx:3064
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
Definition: Utils.cxx:55
bool PointInsideEnvelope(const Point2_t &Point, const std::vector< Point2_t > &Envelope)
Definition: Utils.cxx:3331
void ChkEndKink(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1715
void TagJunkTj(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:2790
void MakeTrajectoryObsolete(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2192
float PointTrajDOCA2(const TCSlice &slc, float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2598
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2448
unsigned short GetPFPIndex(const TCSlice &slc, int tjID)
Definition: Utils.cxx:1058
void FitTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:816
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:6524
bool Fit2D(short mode, Point2_t inPt, float &inPtErr, Vector2_t &outVec, Vector2_t &outVecErr, float &chiDOF)
Definition: Utils.cxx:5137
bool SplitTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, unsigned short itj, float XPos, bool makeVx2, bool prt)
Definition: Utils.cxx:2280
void TrajPointTrajDOCA(const TCSlice &slc, TrajPoint const &tp, Trajectory const &tj, unsigned short &closePt, float &minSep)
Definition: Utils.cxx:2443
General LArSoft Utilities.
double DotProd(const Vector2_t &v1, const Vector2_t &v2)
Definition: Utils.h:231
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
float MaxChargeAsymmetry(TCSlice &slc, std::vector< int > &tjIDs)
Definition: Utils.cxx:382
unsigned short NearestPtWithChg(const TCSlice &slc, const Trajectory &tj, unsigned short thePt)
Definition: Utils.cxx:3530
bool SetMag(Vector3_t &v1, double mag)
Definition: PFPUtils.cxx:2459
std::array< double, 2 > Vector2_t
Definition: DataStructs.h:42
void ReverseTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:3302
unsigned short NumHitsInTP(const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4336
void DefineTjParents(TCSlice &slc, bool prt)
Definition: Utils.cxx:176
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:4297
Detector simulation of raw signals on wires.
void UpdateTjChgProperties(std::string inFcnLabel, TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:3681
bool MergeAndStore(TCSlice &slc, unsigned int itj1, unsigned int itj2, bool doPrt)
Definition: Utils.cxx:4672
float PointPull(const PFPStruct &pfp, const TP3D &tp3d)
Definition: PFPUtils.cxx:2690
void RestoreObsoleteTrajectory(TCSlice &slc, unsigned int itj)
Definition: Utils.cxx:2205
void TrajIntersection(TrajPoint const &tp1, TrajPoint const &tp2, Point2_t &pos)
Definition: Utils.cxx:2612
unsigned int CTP_t
Definition: DataStructs.h:45
bool DecodeDebugString(std::string strng)
Definition: Utils.cxx:5224
bool AnalyzeHits()
Definition: Utils.cxx:4402
Contains all timing reference information for the detector.
float MaxHitDelta(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:3284
float TrajLength(const Trajectory &tj)
Definition: Utils.cxx:2654
void UpdateVxEnvironment(TCSlice &slc)
Definition: Utils.cxx:3870
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
Definition: PFPUtils.cxx:2441
void TrimHiChgEndPts(TCSlice &slc, Trajectory &tj, bool prt)
Definition: Utils.cxx:1565
unsigned short PDGCodeIndex(int PDGCode)
Definition: Utils.cxx:2179
std::pair< unsigned short, unsigned short > GetSliceIndex(std::string typeName, int uID)
Definition: Utils.cxx:5096
float PointTrajSep2(float wire, float time, TrajPoint const &tp)
Definition: Utils.cxx:2571
std::array< double, 3 > Vector3_t
Definition: DataStructs.h:40
bool SignalAtTpInSlc(const TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:1970
void PrintDebugMode()
Definition: Utils.cxx:5458
std::vector< T > SetDifference(const std::vector< T > &set1, const std::vector< T > &set2)
Definition: Utils.h:425
list x
Definition: train.py:276
bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick)
Definition: Utils.cxx:2079
void TjDeltaRMS(const TCSlice &slc, const Trajectory &tj, unsigned short firstPt, unsigned short lastPt, double &rms, unsigned short &cnt)
Definition: Utils.cxx:3592
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:2985
bool SignalBetween(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2, const float &MinWireSignalFraction)
Definition: Utils.cxx:1815
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
void MoveTPToWire(TrajPoint &tp, float wire)
Definition: Utils.cxx:2839
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
Definition: Utils.cxx:2124
void MergeGhostTjs(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:2228
int PrimaryUID(const TCSlice &slc, const PFPStruct &pfp)
Definition: Utils.cxx:495
bool TrajTrajDOCA(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2, unsigned short &ipt1, unsigned short &ipt2, float &minSep)
Definition: Utils.cxx:2468
Namespace collecting geometry-related classes utilities.
float TPHitsRMSTick(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
Definition: Utils.cxx:4217
void PrintTPHeader(std::string someText)
Definition: Utils.cxx:6295
unsigned short AngleRange(TrajPoint const &tp)
Definition: Utils.cxx:774
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
Definition: Utils.cxx:3634
bool HasDuplicateHits(const TCSlice &slc, Trajectory const &tj, bool prt)
Definition: Utils.cxx:2820
void ChkMissedKink(TCSlice &slc, Trajectory &tj, bool prt)