Analysis Software
Documentation for sPHENIX simulation 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 
12 
13 namespace {
21 double computeAnnealingWeight(double chi2, double invTemp) {
22  return Acts::safeExp(-chi2 * invTemp);
23 }
24 } // namespace
25 
27 
29  if (state.currentTemperatureIndex < m_cfg.setOfTemperatures.size() - 1) {
31  } else {
32  state.equilibriumReached = true;
33  }
34 }
35 
37  State& state, double chi2, const std::vector<double>& allChi2) const {
38  unsigned int idx = state.currentTemperatureIndex;
39  // Calculate 1/denominator in exp function already here
40  const double currentInvTemp = 1. / (2. * m_cfg.setOfTemperatures[idx]);
41 
42  double num = computeAnnealingWeight(chi2, currentInvTemp);
43 
44  double denom = m_gaussCutTempVec[idx];
45 
46  for (double val : allChi2) {
47  denom += computeAnnealingWeight(val, currentInvTemp);
48  }
49 
50  return num / denom;
51 }
52 
53 double Acts::AnnealingUtility::getWeight(State& state, double chi2) const {
54  // Calculate 1/denominator in exp function
55  const double currentInvTemp =
56  1. / (2 * m_cfg.setOfTemperatures[state.currentTemperatureIndex]);
57 
58  return 1. /
59  (1. + computeAnnealingWeight(m_cfg.cutOff - chi2, currentInvTemp));
60 }