EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnnealingUtility.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AnnealingUtility.cpp
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 
10 
17 static double gaussFunc(double chi2, double temp) {
18  return std::exp(-chi2 / (2. * temp));
19 }
20 
22  if (state.currentTemperatureIndex < m_cfg.setOfTemperatures.size() - 1) {
24  } else {
25  state.equilibriumReached = true;
26  }
27 }
28 
30  State& state, double chi2, const std::vector<double>& allChi2) const {
31  const double currentTemp =
32  m_cfg.setOfTemperatures[state.currentTemperatureIndex];
33 
34  double base = gaussFunc(1., currentTemp);
35 
36  double denom = std::pow(base, m_cfg.cutOff - chi2);
37 
38  for (double val : allChi2) {
39  denom += std::pow(base, val - chi2);
40  }
41 
42  return 1. / denom;
43 }
44 
45 double Acts::AnnealingUtility::getWeight(State& state, double chi2) const {
46  const double currentTemp =
47  m_cfg.setOfTemperatures[state.currentTemperatureIndex];
48 
49  return 1. / (1. + gaussFunc(m_cfg.cutOff - chi2, currentTemp));
50 }