Belle II Software  release-08-01-10
DAF Class Reference

Determinstic Annealing Filter (DAF) implementation. More...

#include <DAF.h>

Inheritance diagram for DAF:
Collaboration diagram for DAF:

Public Member Functions

 DAF (std::tuple< double, double, int > annealingScheme, int minIter, int maxIter, int minIterForPval, bool useRefKalman=true, double deltaPval=1e-3, double deltaWeight=1e-3, double probCut=1e-3)
 Create DAF. More...
 
 DAF (bool useRefKalman=true, double deltaPval=1e-3, double deltaWeight=1e-3)
 Create DAF. More...
 
 DAF (AbsKalmanFitter *kalman, double deltaPval=1e-3, double deltaWeight=1e-3)
 Create DAF. More...
 
void processTrackWithRep (Track *tr, const AbsTrackRep *rep, bool resortHits=false) override
 Process a track using the DAF.
 
void setProbCut (const double prob_cut)
 Set the probability cut for the weight calculation for the hits. More...
 
void addProbCut (const double prob_cut, const int measDim)
 Set the probability cut for the weight calculation for the hits for a specific measurement dimensionality.
 
const std::vector< double > & getBetas () const
 
void setAnnealingScheme (double bStart, double bFinal, unsigned int nSteps)
 Configure the annealing scheme. More...
 
void setAnnealingScheme (double bStart, double bFinal, unsigned int nSteps, unsigned int minIter, unsigned int maxIter)
 Configure the annealing scheme with custom values of min and max iterations. More...
 
void setMaxIterations (unsigned int n) override
 Set the maximum number of iterations.
 
void setConvergenceDeltaWeight (double delta)
 If all weights change less than delta between two iterations, the fit is regarded as converged.
 
AbsKalmanFittergetKalman () const
 
virtual void setMaxFailedHits (int val) override
 
virtual void setDebugLvl (unsigned int lvl=1) override
 
void getChiSquNdf (const Track *tr, const AbsTrackRep *rep, double &bChi2, double &fChi2, double &bNdf, double &fNdf) const
 
double getChiSqu (const Track *tr, const AbsTrackRep *rep, int direction=-1) const
 
double getNdf (const Track *tr, const AbsTrackRep *rep, int direction=-1) const
 
double getRedChiSqu (const Track *tr, const AbsTrackRep *rep, int direction=-1) const
 
double getPVal (const Track *tr, const AbsTrackRep *rep, int direction=-1) const
 
unsigned int getMinIterations () const
 
unsigned int getMaxIterations () const
 
double getDeltaPval () const
 
double getRelChi2Change () const
 
double getBlowUpFactor () const
 
bool getResetOffDiagonals () const
 
double getBlowUpMaxVal () const
 
eMultipleMeasurementHandling getMultipleMeasurementHandling () const
 
int getMaxFailedHits () const
 
virtual void setMinIterations (unsigned int n)
 Set the minimum number of iterations.
 
void setDeltaPval (double deltaPval)
 Set Convergence criterion. More...
 
void setRelChi2Change (double relChi2Change)
 @ brief Set Non-convergence criterion More...
 
void setBlowUpFactor (double blowUpFactor)
 
void setResetOffDiagonals (bool resetOffDiagonals)
 
void setBlowUpMaxVal (double blowUpMaxVal)
 Limit the cov entries to this maximum value when blowing up the cov. Set to negative value to disable. Default is 1.E6. More...
 
void setMultipleMeasurementHandling (eMultipleMeasurementHandling mmh)
 How should multiple measurements be handled?
 
bool isTrackPrepared (const Track *tr, const AbsTrackRep *rep) const
 
bool isTrackFitted (const Track *tr, const AbsTrackRep *rep) const
 
bool canIgnoreWeights () const
 returns if the fitter can ignore the weights and handle the MeasurementOnPlanes as if they had weight 1.
 
void processTrack (Track *, bool resortHits=false)
 Process all reps. More...
 

Protected Member Functions

const std::vector< MeasurementOnPlane * > getMeasurements (const KalmanFitterInfo *fi, const TrackPoint *tp, int direction) const
 get the measurementsOnPlane taking the multipleMeasurementHandling_ into account
 

Protected Attributes

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 deltaPval_
 Convergence criterion. More...
 
double relChi2Change_
 @ brief Non-convergence criterion More...
 
double blowUpFactor_
 Blow up the covariance of the forward (backward) fit by this factor before seeding the backward (forward) fit.
 
bool resetOffDiagonals_
 Reset the off-diagonals to 0 when blowing up the cov.
 
double blowUpMaxVal_
 Limit the cov entries to this maxuimum value when blowing up the cov.
 
eMultipleMeasurementHandling multipleMeasurementHandling_
 How to handle if there are multiple MeasurementsOnPlane.
 
int maxFailedHits_
 after how many failed hits (exception during construction of plane, extrapolation etc.) should the fit be cancelled. More...
 
unsigned int debugLvl_
 

Private Member Functions

 DAF (const DAF &)
 
DAFoperator= (genfit::DAF const &)
 
bool calcWeights (Track *trk, const AbsTrackRep *rep, double beta)
 Calculate and set the weights for the next fitting pass. More...
 

Private Attributes

int minIterForPval_
 
double deltaWeight_
 
std::vector< double > betas_
 
double chi2Cuts_ [7]
 
std::unique_ptr< AbsKalmanFitterkalman_
 

Detailed Description

Determinstic Annealing Filter (DAF) implementation.

Author
Christian Höppner (Technische Universität München, original author)
Karl Bicker (Technische Universität München)

The DAF is an iterative Kalman filter with annealing. It is capable of fitting tracks which are contaminated with noise hits. The algorithm is taken from the references R. Fruehwirth & A. Strandlie, Computer Physics Communications 120 (1999) 197-214 and CERN thesis: Dissertation by Matthias Winkler.

The weights which were assigned to the hits by the DAF are accessible in the MeasurementOnPlane objects in the KalmanFitterInfo objects.

Definition at line 49 of file DAF.h.

Constructor & Destructor Documentation

◆ DAF() [1/3]

DAF ( std::tuple< double, double, int >  annealingScheme,
int  minIter,
int  maxIter,
int  minIterForPval,
bool  useRefKalman = true,
double  deltaPval = 1e-3,
double  deltaWeight = 1e-3,
double  probCut = 1e-3 
)

Create DAF.

Per default, use KalmanFitterRefTrack as fitter, this constructor should be used for additional configuration of the DAF, allows to provide custom parameters

Parameters
annealingSchemeStart and Final temperatures, and number of steps for the annealing scheme
minIterMinimum number of iterations for the annealing scheme
maxIterMaximum number of iterations for the annealing scheme
minIterForPvalMinimum number of iterations before checking the convergence by pvalue
useRefKalmanIf false, use KalmanFitter as fitter.
deltaPvalThreshold value for pvalue convergence criterion
deltaWeightThreshold value for weight convergence criterion
probCutProbability cut for weight calculation

Definition at line 43 of file DAF.cc.

45  : AbsKalmanFitter(10, deltaPval), deltaWeight_(deltaWeight), minIterForPval_(minIterForPval)
46  {
47  if (useRefKalman) {
48  kalman_.reset(new KalmanFitterRefTrack());
49  static_cast<KalmanFitterRefTrack*>(kalman_.get())->setRefitAll();
50  } else
51  kalman_.reset(new KalmanFitter());
52 
53  kalman_->setMultipleMeasurementHandling(weightedAverage);
54  kalman_->setMaxIterations(1);
55 
56  setAnnealingScheme(std::get<0>(annealingScheme),
57  std::get<1>(annealingScheme),
58  std::get<2>(annealingScheme),
59  minIter, maxIter); // also sets maxIterations_
60  setProbCut(probCut);
61  }
void setProbCut(const double prob_cut)
Set the probability cut for the weight calculation for the hits.
Definition: DAF.cc:194
void setAnnealingScheme(double bStart, double bFinal, unsigned int nSteps)
Configure the annealing scheme.
Definition: DAF.cc:216
@ weightedAverage
weighted average between measurements; used by DAF

◆ DAF() [2/3]

DAF ( bool  useRefKalman = true,
double  deltaPval = 1e-3,
double  deltaWeight = 1e-3 
)

Create DAF.

Per default, use KalmanFitterRefTrack as fitter.

Parameters
useRefKalmanIf false, use KalmanFitter as fitter.

Definition at line 63 of file DAF.cc.

◆ DAF() [3/3]

DAF ( AbsKalmanFitter kalman,
double  deltaPval = 1e-3,
double  deltaWeight = 1e-3 
)

Create DAF.

Use the provided AbsKalmanFitter as fitter.

Definition at line 79 of file DAF.cc.

Member Function Documentation

◆ calcWeights()

bool calcWeights ( Track trk,
const AbsTrackRep rep,
double  beta 
)
private

Calculate and set the weights for the next fitting pass.

Return if convergence is met. The convergence criterium is the largest absolute change of all weights.

Definition at line 262 of file DAF.cc.

◆ processTrack()

void processTrack ( Track tr,
bool  resortHits = false 
)
inherited

Process all reps.

Start with the cardinalRep and resort the hits if necessary (and supported by the fitter)

Definition at line 25 of file AbsFitter.cc.

◆ setAnnealingScheme() [1/2]

void setAnnealingScheme ( double  bStart,
double  bFinal,
unsigned int  nSteps 
)

Configure the annealing scheme.

Set a start and end temperature and the number of steps. A logarithmic sequence of temperatures will be calculated. Also sets minIterations_, maxIterations_ and #minIterForPval as a function of the number of steps

Definition at line 216 of file DAF.cc.

◆ setAnnealingScheme() [2/2]

void setAnnealingScheme ( double  bStart,
double  bFinal,
unsigned int  nSteps,
unsigned int  minIter,
unsigned int  maxIter 
)

Configure the annealing scheme with custom values of min and max iterations.

Set a start and end temperature and the number of steps. A logarithmic sequence of temperatures will be calculated. Also sets minIterations_ and maxIterations_ to the values provided instead of values depending on nSteps

Definition at line 239 of file DAF.cc.

◆ setBlowUpMaxVal()

void setBlowUpMaxVal ( double  blowUpMaxVal)
inlineinherited

Limit the cov entries to this maximum value when blowing up the cov. Set to negative value to disable. Default is 1.E6.

This is especially useful for fits where the measurements do not constrain one direction, e.g. parallel wire measurements. The fit will not be constrained along the wire direction. This also means that the covariance along the wire direction will not get smaller during the fit. However, it will be blown up before the next iteration, leading to an exponential growth of the covariance element(s) corresponding to the wire direction. This can then lead to numerical problems. To prevent this, the maximum value of the covariance elements after blowing up can be limited.

Definition at line 119 of file AbsKalmanFitter.h.

◆ setDeltaPval()

void setDeltaPval ( double  deltaPval)
inlineinherited

Set Convergence criterion.

if track total P-value changes less than this between consecutive iterations, consider the track converged. chiĀ² from the backwards fit is used.

Definition at line 95 of file AbsKalmanFitter.h.

◆ setProbCut()

void setProbCut ( const double  prob_cut)

Set the probability cut for the weight calculation for the hits.

By default the cut values for measurements of dimensionality from 1 to 5 are calculated. If you what to have cut values for an arbitrary measurement dimensionality use addProbCut(double prob_cut, int maxDim);

Definition at line 194 of file DAF.cc.

◆ setRelChi2Change()

void setRelChi2Change ( double  relChi2Change)
inlineinherited

@ brief Set Non-convergence criterion

if the relative chi^2 between two iterations is larger than relChi2Change_, the fit is NOT converged and further iterations will be done, even if the deltaPval_ convergence criterium is met. This is especially useful for fits which have a p-value of almost 0 (possibly due to bad start values), where the p-value from one iteration to the next might not change much. However, a significant change in chi^2 tells us, that the fit might not yet be converged.

Definition at line 106 of file AbsKalmanFitter.h.

Member Data Documentation

◆ deltaPval_

double deltaPval_
protectedinherited

Convergence criterion.

if track total P-value changes less than this between consecutive iterations, consider the track converged. chiĀ² from the backwards fit is used.

Definition at line 148 of file AbsKalmanFitter.h.

◆ maxFailedHits_

int maxFailedHits_
protectedinherited

after how many failed hits (exception during construction of plane, extrapolation etc.) should the fit be cancelled.

-1 means don't cancel

Definition at line 172 of file AbsKalmanFitter.h.

◆ relChi2Change_

double relChi2Change_
protectedinherited

@ brief Non-convergence criterion

if the relative chi^2 between two iterations is larger than relChi2Change_, the fit is NOT converged and further iterations will be done, even if the deltaPval_ convergence criterium is met. This is especially useful for fits which have a p-value of almost 0 (possibly due to bad start values), where the p-value from one iteration to the next might not change much. However, a significant change in chi^2 tells us, that the fit might not yet be converged.

Definition at line 158 of file AbsKalmanFitter.h.


The documentation for this class was generated from the following files: