Belle II Software  release-05-01-25
AbsKalmanFitter.h
1 /* Copyright 2013, Ludwig-Maximilians Universität München,
2  Authors: Tobias Schlüter & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
23 #ifndef genfit_AbsKalmanFitter_h
24 #define genfit_AbsKalmanFitter_h
25 
26 #include "AbsFitter.h"
27 #include "MeasurementOnPlane.h"
28 #include "TrackPoint.h"
29 
30 
31 namespace genfit {
32 
33 class KalmanFitterInfo;
34 
46 };
47 
51 class AbsKalmanFitter : public AbsFitter {
52 
53  public:
54 
55  AbsKalmanFitter(unsigned int maxIterations = 4, double deltaPval = 1e-3, double blowUpFactor = 1e3)
56  : AbsFitter(), minIterations_(2), maxIterations_(maxIterations), deltaPval_(deltaPval), relChi2Change_(0.2),
57  blowUpFactor_(blowUpFactor), resetOffDiagonals_(true), blowUpMaxVal_(1.E6),
59  maxFailedHits_(-1) {
62  }
63 
64  virtual ~AbsKalmanFitter() {;}
65 
66  //virtual void fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction) = 0;
67 
68  void getChiSquNdf(const Track* tr, const AbsTrackRep* rep, double& bChi2, double& fChi2, double& bNdf, double& fNdf) const;
69  double getChiSqu(const Track* tr, const AbsTrackRep* rep, int direction = -1) const;
70  double getNdf(const Track* tr, const AbsTrackRep* rep, int direction = -1) const;
71  double getRedChiSqu(const Track* tr, const AbsTrackRep* rep, int direction = -1) const;
72  double getPVal(const Track* tr, const AbsTrackRep* rep, int direction = -1) const;
73 
74  unsigned int getMinIterations() const {return minIterations_;}
75  unsigned int getMaxIterations() const {return maxIterations_;}
76  double getDeltaPval() const {return deltaPval_;}
77  double getRelChi2Change() const {return relChi2Change_;}
78  double getBlowUpFactor() const {return blowUpFactor_;}
79  bool getResetOffDiagonals() const {return resetOffDiagonals_;}
80  double getBlowUpMaxVal() const {return blowUpMaxVal_;}
81  eMultipleMeasurementHandling getMultipleMeasurementHandling() const {return multipleMeasurementHandling_;}
82  int getMaxFailedHits() const {return maxFailedHits_;}
83 
85  virtual void setMinIterations(unsigned int n) {minIterations_ = std::max((unsigned int)1,n); if (maxIterations_ < minIterations_) maxIterations_ = minIterations_;}
88 
95  void setDeltaPval(double deltaPval) {deltaPval_ = deltaPval;}
96 
106  void setRelChi2Change(double relChi2Change) {relChi2Change_ = relChi2Change;}
107 
108  void setBlowUpFactor(double blowUpFactor) {blowUpFactor_ = blowUpFactor;}
109  void setResetOffDiagonals(bool resetOffDiagonals) {resetOffDiagonals_ = resetOffDiagonals;}
111 
119  void setBlowUpMaxVal(double blowUpMaxVal) {blowUpMaxVal_= blowUpMaxVal;}
120 
123 
124  virtual void setMaxFailedHits(int val) {maxFailedHits_ = val;}
125 
126  bool isTrackPrepared(const Track* tr, const AbsTrackRep* rep) const;
127  bool isTrackFitted(const Track* tr, const AbsTrackRep* rep) const;
128 
130  bool canIgnoreWeights() const;
131 
132  protected:
133 
135  const std::vector<MeasurementOnPlane *> getMeasurements(const KalmanFitterInfo* fi, const TrackPoint* tp, int direction) const;
136 
138  unsigned int minIterations_;
139 
141  unsigned int maxIterations_;
148  double deltaPval_;
159 
166 
169 
173 
174  public:
175 
176  ClassDef(AbsKalmanFitter, 2)
177 
178 };
179 
180 } /* End of namespace genfit */
183 #endif //genfit_AbsKalmanFitter_h
genfit::unweightedClosestToReferenceWire
@ unweightedClosestToReferenceWire
if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with 1.
Definition: AbsKalmanFitter.h:43
genfit::unweightedClosestToPredictionWire
@ unweightedClosestToPredictionWire
if corresponding TrackPoint has one WireMeasurement, select closest to prediction,...
Definition: AbsKalmanFitter.h:45
genfit::AbsKalmanFitter::getMeasurements
const std::vector< MeasurementOnPlane * > getMeasurements(const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const
get the measurementsOnPlane taking the multipleMeasurementHandling_ into account
Definition: AbsKalmanFitter.cc:177
genfit::AbsKalmanFitter::setMaxIterations
virtual void setMaxIterations(unsigned int n)
Set the maximum number of iterations.
Definition: AbsKalmanFitter.h:87
genfit::unweightedClosestToReference
@ unweightedClosestToReference
closest to reference, weighted with 1
Definition: AbsKalmanFitter.h:39
genfit::weightedClosestToReference
@ weightedClosestToReference
closest to reference, weighted with its weight_
Definition: AbsKalmanFitter.h:38
genfit
Defines for I/O streams used for error and debug printing.
Definition: AlignablePXDRecoHit.h:19
genfit::Track
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
genfit::AbsKalmanFitter::blowUpFactor_
double blowUpFactor_
Blow up the covariance of the forward (backward) fit by this factor before seeding the backward (forw...
Definition: AbsKalmanFitter.h:161
genfit::AbsTrackRep
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
genfit::AbsKalmanFitter::setMultipleMeasurementHandling
void setMultipleMeasurementHandling(eMultipleMeasurementHandling mmh)
How should multiple measurements be handled?
Definition: AbsKalmanFitter.h:122
genfit::unweightedAverage
@ unweightedAverage
average between measurements, all weighted with 1
Definition: AbsKalmanFitter.h:37
genfit::weightedClosestToPrediction
@ weightedClosestToPrediction
closest to prediction, weighted with its weight_
Definition: AbsKalmanFitter.h:40
genfit::AbsKalmanFitter::multipleMeasurementHandling_
eMultipleMeasurementHandling multipleMeasurementHandling_
How to handle if there are multiple MeasurementsOnPlane.
Definition: AbsKalmanFitter.h:168
genfit::AbsKalmanFitter::relChi2Change_
double relChi2Change_
@ brief Non-convergence criterion
Definition: AbsKalmanFitter.h:158
genfit::AbsKalmanFitter::blowUpMaxVal_
double blowUpMaxVal_
Limit the cov entries to this maxuimum value when blowing up the cov.
Definition: AbsKalmanFitter.h:165
genfit::unweightedClosestToPrediction
@ unweightedClosestToPrediction
closest to prediction, weighted with 1
Definition: AbsKalmanFitter.h:41
genfit::AbsKalmanFitter::setDeltaPval
void setDeltaPval(double deltaPval)
Set Convergence criterion.
Definition: AbsKalmanFitter.h:95
genfit::AbsKalmanFitter::deltaPval_
double deltaPval_
Convergence criterion.
Definition: AbsKalmanFitter.h:148
genfit::weightedClosestToReferenceWire
@ weightedClosestToReferenceWire
if corresponding TrackPoint has one WireMeasurement, select closest to reference, weighted with its w...
Definition: AbsKalmanFitter.h:42
genfit::AbsKalmanFitter::canIgnoreWeights
bool canIgnoreWeights() const
returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight...
Definition: AbsKalmanFitter.cc:256
genfit::AbsKalmanFitter
Abstract base class for Kalman fitter and derived fitting algorithms.
Definition: AbsKalmanFitter.h:51
genfit::weightedAverage
@ weightedAverage
weighted average between measurements; used by DAF
Definition: AbsKalmanFitter.h:36
genfit::AbsKalmanFitter::resetOffDiagonals_
bool resetOffDiagonals_
Reset the off-diagonals to 0 when blowing up the cov.
Definition: AbsKalmanFitter.h:163
genfit::AbsKalmanFitter::setRelChi2Change
void setRelChi2Change(double relChi2Change)
@ brief Set Non-convergence criterion
Definition: AbsKalmanFitter.h:106
genfit::eMultipleMeasurementHandling
eMultipleMeasurementHandling
Definition: AbsKalmanFitter.h:35
genfit::AbsKalmanFitter::maxIterations_
unsigned int maxIterations_
Maximum number of iterations to attempt. Forward and backward are counted as one iteration.
Definition: AbsKalmanFitter.h:141
genfit::AbsKalmanFitter::setMinIterations
virtual void setMinIterations(unsigned int n)
Set the minimum number of iterations.
Definition: AbsKalmanFitter.h:85
genfit::AbsKalmanFitter::maxFailedHits_
int maxFailedHits_
after how many failed hits (exception during construction of plane, extrapolation etc....
Definition: AbsKalmanFitter.h:172
genfit::AbsKalmanFitter::setBlowUpMaxVal
void setBlowUpMaxVal(double blowUpMaxVal)
Limit the cov entries to this maximum value when blowing up the cov. Set to negative value to disable...
Definition: AbsKalmanFitter.h:119
genfit::weightedClosestToPredictionWire
@ weightedClosestToPredictionWire
if corresponding TrackPoint has one WireMeasurement, select closest to prediction,...
Definition: AbsKalmanFitter.h:44
genfit::AbsFitter
Abstract base class for fitters.
Definition: AbsFitter.h:35
genfit::AbsKalmanFitter::minIterations_
unsigned int minIterations_
Minimum number of iterations to attempt. Forward and backward are counted as one iteration.
Definition: AbsKalmanFitter.h:138