LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
StepUtils.h
Go to the documentation of this file.
1 //
3 //
4 // StepUtils - Core stepping algorithms
5 //
6 // Bruce Baller
7 //
9 #ifndef STEPUTILS_H
10 #define STEPUTILS_H
11 
13 
14 // C/C++ standard libraries
15 #include <array>
16 #include <vector>
17 #include <utility> // std::pair<>
18 #include <cmath>
19 #include <iostream>
20 #include <fstream>
21 #include <iomanip>
22 #include <algorithm>
23 
25 
26 // LArSoft libraries
28 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h"
29 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h"
35 
36 namespace tca {
37 
38  // Main stepping/crawling routine
39  void StepAway(TCSlice& slc, Trajectory& tj);
40  void SetStrategy(TCSlice& slc, Trajectory& tj);
41  void Forecast(TCSlice& slc, Trajectory& tj);
42  // Updates the last added trajectory point fit, average hit rms, etc.
43  void UpdateTraj(TCSlice& slc, Trajectory& tj);
44  // Version with a different strategy for tracking high energy electrons
45  void UpdateStiffEl(TCSlice& slc, Trajectory& tj);
46  // Check the quality of the trajectory and possibly trim it
47  void CheckTraj(TCSlice& slc, Trajectory& tj);
48  void CheckStiffEl(TCSlice& slc, Trajectory& tj);
49  // Add hits on the trajectory point ipt that are close to the trajectory point Pos
50  void AddHits(TCSlice& slc, Trajectory& tj, unsigned short ipt, bool& sigOK);
51  // Large Angle version
52  void AddLAHits(TCSlice& slc, Trajectory& tj, unsigned short ipt, bool& sigOK);
53  // Try to use unused nearby hits in all trajectories after stepping is done
54 // void UseUnusedHits(TCSlice& slc);
55  // Step through TPs starting at the end and moving to the beginning
56  void ReversePropagate(TCSlice& slc, Trajectory& tj);
57  void GetHitMultiplet(TCSlice& slc, unsigned int theHit, std::vector<unsigned int>& hitsInMultiplet);
58  void GetHitMultiplet(TCSlice& slc, unsigned int theHit, std::vector<unsigned int>& hitsInMultiplet, unsigned short& localIndex);
59  // Returns fHits[iht]->RMS() * fScaleF * fHitErrFac * fHits[iht]->Multiplicity();
60  float HitTimeErr(TCSlice& slc, const unsigned int iht);
61  // Estimates the error^2 of the time using all hits in hitVec
62  float HitsTimeErr2(TCSlice& slc, const std::vector<unsigned int>& hitVec);
63  // defines HitPos, HitPosErr2 and Chg for the used hits in the trajectory point
64  void ChkStopEndPts(TCSlice& slc, Trajectory& tj, bool prt);
65  void DefineHitPos(TCSlice& slc, TrajPoint& tp);
66  // Decide which hits to use to determine the trajectory point
67  // fit, charge, etc. This is done by setting UseHit true and
68  // setting inTraj < 0
69  void FindUseHits(TCSlice& slc, Trajectory& tj, unsigned short ipt, float maxDelta, bool useChg);
70  // Truncates the trajectory if a soft kink is found in it
71  void FindSoftKink(TCSlice& slc, Trajectory& tj);
72  // Fill gaps in the trajectory
73  void FillGaps(TCSlice& slc, Trajectory& tj);
74  // Check for many unused hits and try to use them
75  void CheckHiMultUnusedHits(TCSlice& slc, Trajectory& tj);
76  void CheckHiMultEndHits(TCSlice& slc, Trajectory& tj);
77  // Check for high values of Delta at the beginning of the trajectory
78  void HiEndDelta(TCSlice& slc, Trajectory& tj);
79 
80  // Estimate the Delta RMS of the TPs on the end of tj.
81  void UpdateDeltaRMS(TCSlice& slc, Trajectory& tj);
82  void MaskBadTPs(TCSlice& slc, Trajectory& tj, float const& maxChi);
83  // The hits in the TP at the end of the trajectory were masked off. Decide whether to continue stepping with the
84  // current configuration or whether to stop and possibly try with the next pass settings
85  bool MaskedHitsOK(TCSlice& slc, Trajectory& tj);
86  // Any re-sizing should have been done by the calling routine. This code updates the Pass and adjusts the number of
87  // fitted points to get FitCHi < 2
88  bool StopIfBadFits(TCSlice& slc, Trajectory& tj);
89  // Does a local fit of just-added TPs to identify a kink while stepping.
90  // Truncates the vector and returns true if one is found.
91  void GottaKink(TCSlice& slc, Trajectory& tj, unsigned short& killPts);
92  // Update the parameters at the beginning of the trajectory
93  void FixTrajBegin(TCSlice& slc, Trajectory& tj);
94  void FixTrajBegin(TCSlice& slc, Trajectory& tj, unsigned short atPt);
95  void FixTrajEnd(TCSlice& slc, Trajectory& tj, unsigned short atPt);
96  bool IsGhost(TCSlice& slc, std::vector<unsigned int>& tHits);
97  bool IsGhost(TCSlice& slc, Trajectory& tj);
98  void EndMerge(TCSlice& slc, CTP_t inCTP, bool lastPass);
99  void MaskTrajEndPoints(TCSlice& slc, Trajectory& tj, unsigned short nPts);
100  // Sets the StopsAtEnd bits for the trajectory
101  void ChkStop(TCSlice& slc, Trajectory& tj);
102  // Check the Michel electron topology, lastGoodPt is the last point of muon
103  bool ChkMichel(TCSlice& slc, Trajectory& tj, unsigned short& lastGoodPt);
104  // TY: Split high charge hits near the trajectory end
105  void ChkHiChgHits(TCSlice& slc, CTP_t inCTP);
106  void SplitHiChgHits(TCSlice& slc, Trajectory& tj);
107  // Make a junk trajectory using the list of hits in tHits
108  bool MakeJunkTraj(TCSlice& slc, std::vector<unsigned int> tHits);
109 } // namespace tca
110 
111 #endif // ifndef STEPUTILS_H
void StepAway(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:15
bool MaskedHitsOK(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2710
void UpdateTraj(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:655
void FixTrajEnd(TCSlice &slc, Trajectory &tj, unsigned short atPt)
Definition: StepUtils.cxx:3173
void FindSoftKink(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2211
bool IsGhost(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:3221
void AddHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, bool &sigOK)
Definition: StepUtils.cxx:1091
Declaration of signal hit object.
void SetStrategy(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:303
void FillGaps(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2264
void FindUseHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, float maxDelta, bool useChg)
Definition: StepUtils.cxx:1923
void GetHitMultiplet(TCSlice &slc, unsigned int theHit, std::vector< unsigned int > &hitsInMultiplet)
Definition: StepUtils.cxx:1573
bool MakeJunkTraj(TCSlice &slc, std::vector< unsigned int > tHits)
Definition: StepUtils.cxx:4223
void HiEndDelta(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2566
void DefineHitPos(TCSlice &slc, TrajPoint &tp)
Definition: StepUtils.cxx:1840
void SplitHiChgHits(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:4120
void CheckStiffEl(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:898
void ChkHiChgHits(TCSlice &slc, CTP_t inCTP)
Definition: StepUtils.cxx:4105
void FixTrajBegin(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2988
void GottaKink(TCSlice &slc, Trajectory &tj, unsigned short &killPts)
Definition: StepUtils.cxx:2842
Definition of data types for geometry description.
void UpdateStiffEl(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:633
void ChkStop(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:3952
float HitTimeErr(TCSlice &slc, unsigned int iht)
Definition: StepUtils.cxx:1693
bool StopIfBadFits(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2815
void MaskBadTPs(TCSlice &slc, Trajectory &tj, float const &maxChi)
Definition: StepUtils.cxx:2665
void CheckTraj(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:911
unsigned int CTP_t
Definition: DataStructs.h:41
void AddLAHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, bool &sigOK)
Definition: StepUtils.cxx:1277
float HitsTimeErr2(TCSlice &slc, const std::vector< unsigned int > &hitVec)
Definition: StepUtils.cxx:1701
void CheckHiMultUnusedHits(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2378
void Forecast(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:404
void EndMerge(TCSlice &slc, CTP_t inCTP, bool lastPass)
Definition: StepUtils.cxx:3464
void MaskTrajEndPoints(TCSlice &slc, Trajectory &tj, unsigned short nPts)
Definition: StepUtils.cxx:3887
void UpdateDeltaRMS(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2635
void ChkStopEndPts(TCSlice &slc, Trajectory &tj, bool prt)
Definition: StepUtils.cxx:1711
void ReversePropagate(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:1414
void CheckHiMultEndHits(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:2526
bool ChkMichel(TCSlice &slc, Trajectory &tj, unsigned short &lastGoodPt)
Definition: StepUtils.cxx:4049