Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnnealingUtility.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AnnealingUtility.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
13 #include <cmath>
14 #include <vector>
15 
16 namespace Acts {
20  public:
23  struct State {
24  // Points to current temperature value in m_cfg.setOfTemperatures
25  unsigned int currentTemperatureIndex{0};
26 
27  // Checks if equilibrium is reached
28  bool equilibriumReached{false};
29  };
30 
32  struct Config {
33  Config();
34 
35  // Insensitivity of calculated weight at cutoff
36  double cutOff{9.};
37 
38  // Set of temperatures, annealing starts at setOfTemperatures[0]
39  // and anneals towards setOfTemperatures[last]
40  std::vector<double> setOfTemperatures{64., 16., 4., 2., 1.5, 1.};
41  };
42 
45  // Set Gaussian cut-off terms for each temperature
46  for (double temp : cfg.setOfTemperatures) {
47  m_gaussCutTempVec.push_back(std::exp(-cfg.cutOff / (2. * temp)));
48  }
49  }
50 
52  void anneal(State& state) const;
53 
63  double getWeight(State& state, double chi2,
64  const std::vector<double>& allChi2) const;
65 
72  double getWeight(State& state, double chi2) const;
73 
74  private:
77 
78  // For each temperature, a Gaussian term with the chi2 cut-off value
79  // is calculated and stored here
80  std::vector<double> m_gaussCutTempVec;
81 };
82 } // namespace Acts