Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:23

0001 /* Copyright 2013, Ludwig-Maximilians Universität München,
0002    Authors: Tobias Schlüter & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 /** @addtogroup genfit
0020  * @{
0021  */
0022 
0023 #ifndef genfit_DAF_h
0024 #define genfit_DAF_h
0025 
0026 #include "AbsKalmanFitter.h"
0027 
0028 #include <vector>
0029 #include <map>
0030 #include <memory>
0031 
0032 
0033 namespace genfit {
0034 
0035 /** @brief Determinstic Annealing Filter (DAF) implementation.
0036  *
0037  * @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
0038  * @author Karl Bicker (Technische Universit&auml;t M&uuml;nchen)
0039  *
0040  * The DAF is an iterative Kalman filter with annealing. It is capable of
0041  * fitting tracks which are contaminated with noise hits. The algorithm is
0042  * taken from the references R. Fruehwirth & A. Strandlie, Computer Physics
0043  * Communications 120 (1999) 197-214 and CERN thesis: Dissertation by Matthias
0044  * Winkler.
0045  *
0046  * The weights which were assigned to the hits by the DAF are accessible in the MeasurementOnPlane objects
0047  * in the KalmanFitterInfo objects.
0048  */
0049 class DAF : public AbsKalmanFitter {
0050 
0051  private:
0052 
0053   DAF(const DAF&);
0054   DAF& operator=(genfit::DAF const&);
0055 
0056  public:
0057 
0058   /**
0059    * @brief Create DAF. Per default, use KalmanFitterRefTrack as fitter.
0060    *
0061    * @param useRefKalman If false, use KalmanFitter as fitter.
0062    */
0063   DAF(bool useRefKalman = true, double deltaPval = 1e-3, double deltaWeight = 1e-3);
0064   /**
0065    * @brief Create DAF. Use the provided AbsKalmanFitter as fitter.
0066    */
0067   DAF(AbsKalmanFitter* kalman, double deltaPval = 1e-3, double deltaWeight = 1e-3);
0068   ~DAF() {};
0069 
0070   //! Process a track using the DAF.
0071   void processTrackWithRep(Track* tr, const AbsTrackRep* rep, bool resortHits = false) override;
0072 
0073   /** @brief Set the probability cut for the weight calculation for the hits.
0074    *
0075    * By default the cut values for measurements of dimensionality from 1 to 5 are calculated.
0076    * If you what to have cut values for an arbitrary measurement dimensionality use
0077    * addProbCut(double prob_cut, int maxDim);
0078    */
0079   void setProbCut(const double prob_cut);
0080 
0081   //! Set the probability cut for the weight calculation for the hits for a specific measurement dimensionality.
0082   void addProbCut(const double prob_cut, const int measDim);
0083 
0084   const std::vector<double>& getBetas() const {return betas_;}
0085 
0086   /** @brief Configure the annealing scheme.
0087    *
0088    * Set a start and end temperature and the number of steps. A logarithmic sequence of temperatures will be calculated.
0089    * Also sets #minIterations_ and #maxIterations_.
0090    */
0091   void setAnnealingScheme(double bStart, double bFinal, unsigned int nSteps);
0092 
0093   void setMaxIterations(unsigned int n) override {maxIterations_ = n; betas_.resize(maxIterations_,betas_.back());}
0094 
0095   //! If all weights change less than delta between two iterations, the fit is regarded as converged.
0096   void setConvergenceDeltaWeight(double delta) {deltaWeight_ = delta;}
0097 
0098   AbsKalmanFitter* getKalman() const {return kalman_.get();}
0099 
0100   virtual void setMaxFailedHits(int val) override {getKalman()->setMaxFailedHits(val);}
0101 
0102   virtual void setDebugLvl(unsigned int lvl = 1) override {AbsFitter::setDebugLvl(lvl); if (lvl > 1) getKalman()->setDebugLvl(lvl-1);}
0103 
0104  private:
0105 
0106   /** @brief Calculate and set the weights for the next fitting pass.
0107    * Return if convergence is met.
0108    * The convergence criterium is the largest absolute change of all weights.
0109     */
0110   bool calcWeights(Track* trk, const AbsTrackRep* rep, double beta);
0111 
0112 
0113   double deltaWeight_; // convergence criterium
0114   std::vector<double> betas_;   // Temperatures, NOT inverse temperatures.
0115   double chi2Cuts_[7];  // '7' assumes tracks are helices with one
0116             // parameter, i.e. we're living in 3D space,
0117             // where time may be used in the fit.  Zeroth
0118             // entry is not used.
0119 
0120   std::unique_ptr<AbsKalmanFitter> kalman_;
0121 
0122  public:
0123 
0124   ClassDefOverride(DAF,2)
0125 
0126 };
0127 
0128 }  /* End of namespace genfit */
0129 /** @} */
0130 
0131 #endif //genfit_DAF_h