PandaRoot
AbsKalmanFitter.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2013, Ludwig-Maximilians Universität München,
14  Authors: Tobias Schlüter & Johannes Rauch
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
35 #ifndef genfit_AbsKalmanFitter_h
36 #define genfit_AbsKalmanFitter_h
37 
38 #include "AbsFitter.h"
39 #include "MeasurementOnPlane.h"
40 #include "TrackPoint.h"
41 
42 namespace genfit {
43 
44 class KalmanFitterInfo;
45 
60 };
61 
65 class AbsKalmanFitter : public AbsFitter {
66 
67  public:
68  AbsKalmanFitter(unsigned int maxIterations = 4, double deltaPval = 1e-3, double blowUpFactor = 1e3)
69  : AbsFitter(), minIterations_(2), maxIterations_(maxIterations), deltaPval_(deltaPval), relChi2Change_(0.2), blowUpFactor_(blowUpFactor), resetOffDiagonals_(true),
71  {
74  }
75 
76  virtual ~AbsKalmanFitter() { ; }
77 
78  // virtual void fitTrack(Track* tr, const AbsTrackRep* rep, double& chi2, double& ndf, int direction) = 0;
79 
80  void getChiSquNdf(const Track *tr, const AbsTrackRep *rep, double &bChi2, double &fChi2, double &bNdf, double &fNdf) const;
81  double getChiSqu(const Track *tr, const AbsTrackRep *rep, int direction = -1) const;
82  double getNdf(const Track *tr, const AbsTrackRep *rep, int direction = -1) const;
83  double getRedChiSqu(const Track *tr, const AbsTrackRep *rep, int direction = -1) const;
84  double getPVal(const Track *tr, const AbsTrackRep *rep, int direction = -1) const;
85 
86  unsigned int getMinIterations() const { return minIterations_; }
87  unsigned int getMaxIterations() const { return maxIterations_; }
88  double getDeltaPval() const { return deltaPval_; }
89  double getRelChi2Change() const { return relChi2Change_; }
90  double getBlowUpFactor() const { return blowUpFactor_; }
91  bool getResetOffDiagonals() const { return resetOffDiagonals_; }
92  double getBlowUpMaxVal() const { return blowUpMaxVal_; }
94  int getMaxFailedHits() const { return maxFailedHits_; }
95 
97  virtual void setMinIterations(unsigned int n)
98  {
99  minIterations_ = std::max((unsigned int)1, n);
102  }
104  virtual void setMaxIterations(unsigned int n)
105  {
106  maxIterations_ = n;
109  }
110 
117  void setDeltaPval(double deltaPval) { deltaPval_ = deltaPval; }
118 
128  void setRelChi2Change(double relChi2Change) { relChi2Change_ = relChi2Change; }
129 
130  void setBlowUpFactor(double blowUpFactor) { blowUpFactor_ = blowUpFactor; }
131  void setResetOffDiagonals(bool resetOffDiagonals) { resetOffDiagonals_ = resetOffDiagonals; }
133 
141  void setBlowUpMaxVal(double blowUpMaxVal) { blowUpMaxVal_ = blowUpMaxVal; }
142 
145 
146  virtual void setMaxFailedHits(int val) { maxFailedHits_ = val; }
147 
148  bool isTrackPrepared(const Track *tr, const AbsTrackRep *rep) const;
149  bool isTrackFitted(const Track *tr, const AbsTrackRep *rep) const;
150 
152  bool canIgnoreWeights() const;
153 
154  protected:
156  const std::vector<MeasurementOnPlane *> getMeasurements(const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const;
157 
159  unsigned int minIterations_;
160 
162  unsigned int maxIterations_;
169  double deltaPval_;
180 
187 
190 
194 
195  public:
196  ClassDef(AbsKalmanFitter, 2)
197 };
198 
199 } /* End of namespace genfit */
202 #endif // genfit_AbsKalmanFitter_h
bool resetOffDiagonals_
Reset the off-diagonals to 0 when blowing up the cov.
const std::vector< MeasurementOnPlane * > getMeasurements(const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const
get the measurementsOnPlane taking the multipleMeasurementHandling_ into account
double blowUpFactor_
Blow up the covariance of the forward (backward) fit by this factor before seeding the backward (forw...
double getPVal(const Track *tr, const AbsTrackRep *rep, int direction=-1) const
void setBlowUpMaxVal(double blowUpMaxVal)
Limit the cov entries to this maximum value when blowing up the cov. Set to negative value to disable...
double deltaPval_
Convergence criterion.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:79
Abstract base class for a track representation.
Definition: AbsTrackRep.h:74
virtual void setMaxIterations(unsigned int n)
Set the maximum number of iterations.
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37
void setDeltaPval(double deltaPval)
Set Convergence criterion.
AbsKalmanFitter(unsigned int maxIterations=4, double deltaPval=1e-3, double blowUpFactor=1e3)
eMultipleMeasurementHandling getMultipleMeasurementHandling() const
double getDeltaPval() const
Abstract base class for Kalman fitter and derived fitting algorithms.
virtual void setMinIterations(unsigned int n)
Set the minimum number of iterations.
void setBlowUpFactor(double blowUpFactor)
bool isTrackPrepared(const Track *tr, const AbsTrackRep *rep) const
virtual void setMaxFailedHits(int val)
void setRelChi2Change(double relChi2Change)
bool canIgnoreWeights() const
returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight...
double getBlowUpMaxVal() const
void getChiSquNdf(const Track *tr, const AbsTrackRep *rep, double &bChi2, double &fChi2, double &bNdf, double &fNdf) const
double getRedChiSqu(const Track *tr, const AbsTrackRep *rep, int direction=-1) const
double getNdf(const Track *tr, const AbsTrackRep *rep, int direction=-1) const
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:61
eMultipleMeasurementHandling multipleMeasurementHandling_
How to handle if there are multiple MeasurementsOnPlane.
bool isTrackFitted(const Track *tr, const AbsTrackRep *rep) const
void setResetOffDiagonals(bool resetOffDiagonals)
void setMultipleMeasurementHandling(eMultipleMeasurementHandling mmh)
How should multiple measurements be handled?
double getBlowUpFactor() const
unsigned int minIterations_
Minimum number of iterations to attempt. Forward and backward are counted as one iteration.
unsigned int maxIterations_
Maximum number of iterations to attempt. Forward and backward are counted as one iteration.
double getRelChi2Change() const
double getChiSqu(const Track *tr, const AbsTrackRep *rep, int direction=-1) const
Abstract base class for fitters.
Definition: AbsFitter.h:46
double blowUpMaxVal_
Limit the cov entries to this maxuimum value when blowing up the cov.
bool getResetOffDiagonals() const
unsigned int getMinIterations() const
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
eMultipleMeasurementHandling
Matrix inversion tools.
Definition: AbsBField.h:40
unsigned int getMaxIterations() const