All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KalmanFilterAlg.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file KalmanFilterAlg.h
4 ///
5 /// \brief Kalman Filter.
6 ///
7 /// \author H. Greenlee
8 ///
9 /// Configuration parameters:
10 ///
11 /// Trace - Trace flag.
12 /// MaxPErr - Maximum pointing error for free propagation.
13 /// GoodPErr - Pointing error threshold for switching to free propagation.
14 /// MaxIncChisq - Maximum incremental chisquare to accept a hit.
15 /// MaxSeedIncChisq - Maximum incremental chisquare to accept in seed phase.
16 /// MaxSmoothIncChisq - Maximum incremental chisquare to accept in smooth phase.
17 /// MaxEndChisq - Maximum incremental chisquare for endpoint hit.
18 /// MinLHits - Minimum number of hits to turn off linearized propagation.
19 /// MaxLDist - Maximum distance for linearized propagation.
20 /// MaxPredDist - Maximum prediciton distance to accept a hit.
21 /// MaxSeedPredDist - Maximum prediciton distance to accept a hit in seed phase.
22 /// MaxPropDist - Maximum propagation distance to candidate surface.
23 /// MinSortDist - Sort low distance threshold.
24 /// MaxSortDist - Sort high distance threshold.
25 /// MaxSamePlane - Maximum consecutive hits in same plane.
26 /// GapDist - Minimum gap distance.
27 /// MaxNoiseHits - Maximum number of hits in noise cluster.
28 /// MinSampleDist - Minimum sample distance (for momentum measurement).
29 /// FitMomRange - Fit momentum using range.
30 /// FitMomMS - Fit momentum using multiple scattering.
31 /// GTrace - Graphical trace flag.
32 /// GTraceWW - Graphical trace window width (pixels).
33 /// GTraceWH - Graphical trace window height (pixels).
34 /// GTraceXMin - Graphical trace minimum x (same for each view).
35 /// GTraceXMax - Graphical trace maximum x (same for each view).
36 /// GTraceZMin - Graphical trace minimum z (vector).
37 /// GTraceZMax - Graphical trace maximum z (vector).
38 ///
39 ////////////////////////////////////////////////////////////////////////
40 
41 #ifndef KALMANFILTERALG_H
42 #define KALMANFILTERALG_H
43 
44 #include <map>
45 #include <memory>
46 #include <vector>
47 
49 
50 namespace fhicl {
51  class ParameterSet;
52 }
53 namespace trkf {
54  class KETrack;
55  class KGTrack;
56  class KTrack;
57  class KHitContainer;
58 }
59 
60 #include "TCanvas.h"
61 
62 class TMarker;
63 class TPaveText;
64 class TVirtualPad;
65 
66 namespace trkf {
67 
69  public:
70  KalmanFilterAlg(const fhicl::ParameterSet& pset);
71 
72  // Accessors.
73 
74  bool
75  getTrace() const
76  {
77  return fTrace;
78  } ///< Trace config parameters.
79  int
80  getPlane() const
81  {
82  return fPlane;
83  } ///< Preferred view plane.
84 
85  // Modifiers.
86 
87  void
89  {
90  fTrace = trace;
91  } ///< Set trace config parameter.
92  void
93  setPlane(int plane)
94  {
95  fPlane = plane;
96  } ///< Set preferred view plane.
97 
98  // Methods.
99 
100  /// Make a new track.
101  bool buildTrack(const KTrack& trk, // Starting track.
102  KGTrack& trg, // Result global track.
103  const Propagator& prop, // Propagator.
104  const Propagator::PropDirection dir, // Direction.
105  KHitContainer& hits, // Candidate measurements.
106  bool linear) const; // Linear flag.
107 
108  /// Smooth track.
109  bool smoothTrack(KGTrack& trg, // Global track to be smoothed.
110  KGTrack* trg1, // Result of unidirectional fit.
111  const Propagator& prop) const; // Propagator.
112 
113  /// Add hits to existing track.
114  bool extendTrack(KGTrack& trg, // Global track.
115  const Propagator& prop, // Propagator.
116  KHitContainer& hits) const; // Candidate measurements.
117 
118  /// Estimate track momentum using range.
119  bool fitMomentumRange(const KGTrack& trg, // Global track.
120  KETrack& tremom) const; // Track with updated momentum.
121 
122  /// Estimate track momentum using multiple scattering.
123  bool fitMomentumMS(const KGTrack& trg, // Global track.
124  const Propagator& prop, // Propagator.
125  KETrack& tremom) const; // Track with updated momentum.
126 
127  /// Estimate track momentum using either range or multiple scattering.
128  bool fitMomentum(const KGTrack& trg, // Global track.
129  const Propagator& prop, // Propagator.
130  KETrack& tremom) const; // Track with updated momentum.
131 
132  /// Set track momentum at each track surface.
133  bool updateMomentum(const KETrack& tremom, // Track with momentum estimate.
134  const Propagator& prop, // Propagator.
135  KGTrack& trg) const; // Global track to be updated.
136 
137  /// Iteratively smooth a track.
138  bool smoothTrackIter(int niter, // Number of iterations.
139  KGTrack& trg, // Global track.
140  const Propagator& prop) const; // Propagator.
141 
142  /// Clean track by removing noise hits near endpoints.
143  void cleanTrack(KGTrack& trg) const;
144 
145  private:
146  // Fcl parameters.
147 
148  bool fTrace; ///< Trace flag.
149  double fMaxPErr; ///< Maximum pointing error for free propagation.
150  double fGoodPErr; ///< Pointing error threshold for switching to free propagation.
151  double fMaxIncChisq; ///< Maximum incremental chisquare to accept a hit.
152  double fMaxSeedIncChisq; ///< Maximum incremental chisquare to accept a hit in seed phase.
153  double fMaxSmoothIncChisq; ///< Maximum incremental chisquare to accept a hit in smooth phase.
154  double fMaxEndChisq; ///< Maximum incremental chisquare for endpoint hit.
155  int fMinLHits; ///< Minimum number of hits to turn off linearized propagation.
156  double fMaxLDist; ///< Maximum distance for linearized propagation.
157  double fMaxPredDist; ///< Maximum prediciton distance to accept a hit.
158  double fMaxSeedPredDist; ///< Maximum prediciton distance to accept a hit in seed phase.
159  double fMaxPropDist; ///< Maximum propagation distance to candidate surface.
160  double fMinSortDist; ///< Sort low distance threshold.
161  double fMaxSortDist; ///< Sort high distance threshold.
162  int fMaxSamePlane; ///< Maximum consecutive hits in same plane.
163  double fGapDist; ///< Minimum gap distance.
164  int fMaxNoiseHits; ///< Maximum number of hits in noise cluster.
165  double fMinSampleDist; ///< Minimum sample distance (for momentum measurement).
166  bool fFitMomRange; ///< Fit momentum using range.
167  bool fFitMomMS; ///< Fit momentum using multiple scattering.
168  bool fGTrace; ///< Graphical trace flag.
169  double fGTraceWW; ///< Window width.
170  double fGTraceWH; ///< Window height.
171  double fGTraceXMin; ///< Graphical trace minimum x.
172  double fGTraceXMax; ///< Graphical trace maximum x.
173  std::vector<double> fGTraceZMin; ///< Graphical trace minimum z for each view.
174  std::vector<double> fGTraceZMax; ///< Graphical trace maximum z for each view.
175 
176  // Other attributes.
177 
178  int fPlane; ///< Preferred view plane.
179  mutable std::vector<std::unique_ptr<TCanvas>> fCanvases; ///< Graphical trace canvases.
180  mutable std::vector<TVirtualPad*> fPads; ///< View pads in current canvas.
181  mutable TVirtualPad* fInfoPad; ///< Information pad.
182  mutable TPaveText* fMessages; ///< Message box.
183  mutable std::map<int, TMarker*> fMarkerMap; ///< Markers in current canvas.
184  };
185 }
186 
187 #endif
bool fGTrace
Graphical trace flag.
bool fFitMomRange
Fit momentum using range.
double fMaxPropDist
Maximum propagation distance to candidate surface.
double fGapDist
Minimum gap distance.
bool fFitMomMS
Fit momentum using multiple scattering.
std::map< int, TMarker * > fMarkerMap
Markers in current canvas.
bool smoothTrackIter(int niter, KGTrack &trg, const Propagator &prop) const
Iteratively smooth a track.
double fMaxEndChisq
Maximum incremental chisquare for endpoint hit.
bool fTrace
Trace flag.
KalmanFilterAlg(const fhicl::ParameterSet &pset)
Constructor.
void cleanTrack(KGTrack &trg) const
Clean track by removing noise hits near endpoints.
void setTrace(bool trace)
Set trace config parameter.
std::vector< double > fGTraceZMin
Graphical trace minimum z for each view.
double fMaxLDist
Maximum distance for linearized propagation.
double fMaxSortDist
Sort high distance threshold.
double fMaxSeedPredDist
Maximum prediciton distance to accept a hit in seed phase.
double fMaxPredDist
Maximum prediciton distance to accept a hit.
M::value_type trace(const M &m)
bool fitMomentumMS(const KGTrack &trg, const Propagator &prop, KETrack &tremom) const
Estimate track momentum using multiple scattering.
bool buildTrack(const KTrack &trk, KGTrack &trg, const Propagator &prop, const Propagator::PropDirection dir, KHitContainer &hits, bool linear) const
Make a new track.
double fGTraceWH
Window height.
TVirtualPad * fInfoPad
Information pad.
bool extendTrack(KGTrack &trg, const Propagator &prop, KHitContainer &hits) const
Add hits to existing track.
std::vector< std::unique_ptr< TCanvas > > fCanvases
Graphical trace canvases.
double fGTraceXMin
Graphical trace minimum x.
Base class for Kalman filter track propagator.
double fGoodPErr
Pointing error threshold for switching to free propagation.
TPaveText * fMessages
Message box.
double fMaxSeedIncChisq
Maximum incremental chisquare to accept a hit in seed phase.
double fMaxSmoothIncChisq
Maximum incremental chisquare to accept a hit in smooth phase.
double fMaxIncChisq
Maximum incremental chisquare to accept a hit.
bool smoothTrack(KGTrack &trg, KGTrack *trg1, const Propagator &prop) const
Smooth track.
double fMinSampleDist
Minimum sample distance (for momentum measurement).
tuple dir
Definition: dropbox.py:28
double fMinSortDist
Sort low distance threshold.
double fGTraceXMax
Graphical trace maximum x.
std::vector< TVirtualPad * > fPads
View pads in current canvas.
void setPlane(int plane)
Set preferred view plane.
double fGTraceWW
Window width.
int getPlane() const
Preferred view plane.
std::vector< double > fGTraceZMax
Graphical trace maximum z for each view.
int fMaxSamePlane
Maximum consecutive hits in same plane.
int fMaxNoiseHits
Maximum number of hits in noise cluster.
bool getTrace() const
Trace config parameters.
double fMaxPErr
Maximum pointing error for free propagation.
bool fitMomentumRange(const KGTrack &trg, KETrack &tremom) const
Estimate track momentum using range.
bool fitMomentum(const KGTrack &trg, const Propagator &prop, KETrack &tremom) const
Estimate track momentum using either range or multiple scattering.
bool updateMomentum(const KETrack &tremom, const Propagator &prop, KGTrack &trg) const
Set track momentum at each track surface.
int fMinLHits
Minimum number of hits to turn off linearized propagation.
PropDirection
Propagation direction enum.
Definition: Propagator.h:94
int fPlane
Preferred view plane.