Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:08

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 
0013 #include <cmath>
0014 #include <vector>
0015 
0016 namespace Acts {
0017 /// @brief Implements a deterministic thermodynamic annealing scheme
0018 /// Ref. (1): CERN-THESIS-2010-027
0019 class AnnealingUtility {
0020  public:
0021   /// @brief The annealing state
0022   /// Resetting the state is done by just creating a new instance
0023   struct State {
0024     // Points to current temperature value in m_cfg.setOfTemperatures
0025     unsigned int currentTemperatureIndex{0};
0026 
0027     // Checks if equilibrium is reached
0028     bool equilibriumReached{false};
0029   };
0030 
0031   /// @brief The configuration struct
0032   struct Config {
0033     Config();
0034 
0035     Config(double cutOff_, std::vector<double> setOfTemperatures_)
0036         : cutOff(cutOff_), setOfTemperatures(std::move(setOfTemperatures_)) {}
0037 
0038     // Insensitivity of calculated weight at cutoff
0039     double cutOff{9.};
0040 
0041     // Set of temperatures, annealing starts at setOfTemperatures[0]
0042     // and anneals towards setOfTemperatures[last]
0043     std::vector<double> setOfTemperatures{64., 16., 4., 2., 1.5, 1.};
0044   };
0045 
0046   /// Constructor
0047   AnnealingUtility(const Config& cfg = Config()) : m_cfg(cfg) {
0048     // Set Gaussian cut-off terms for each temperature
0049     for (double temp : cfg.setOfTemperatures) {
0050       m_gaussCutTempVec.push_back(std::exp(-cfg.cutOff / (2. * temp)));
0051     }
0052   }
0053 
0054   /// Does the actual annealing step
0055   void anneal(State& state) const;
0056 
0057   /// @brief Weight access
0058   ///
0059   /// @param state The state object
0060   /// @param chi2 Chi^2 for e.g. current track, i.e. compatibility
0061   /// of track to current vertex candidate
0062   /// @param allChi2 Vector of all chi^2 values, i.e. e.g. compatibilities
0063   /// of current track to all vertices it is currently attached to
0064   ///
0065   /// @return Calculated weight according to Eq.(5.46) in Ref.(1)
0066   double getWeight(State& state, double chi2,
0067                    const std::vector<double>& allChi2) const;
0068 
0069   /// @brief Weight access
0070   ///
0071   /// @param state The state object
0072   /// @param chi2 Chi^2
0073   ///
0074   /// @return Calculated weight
0075   double getWeight(State& state, double chi2) const;
0076 
0077  private:
0078   /// Configuration object
0079   Config m_cfg;
0080 
0081   // For each temperature, a Gaussian term with the chi2 cut-off value
0082   // is calculated and stored here
0083   std::vector<double> m_gaussCutTempVec;
0084 };
0085 }  // namespace Acts