CMS 3D CMS Logo

GeometricAnnealing.cc
Go to the documentation of this file.
3 #include <cmath>
4 #include <iostream>
5 #include <limits>
6 
7 GeometricAnnealing::GeometricAnnealing(const double cutoff, const double T, const double ratio)
8  : theT0(T), theT(T), theChi2cut(cutoff * cutoff), theRatio(ratio) {}
9 
10 void GeometricAnnealing::anneal() { theT = 1 + (theT - 1) * theRatio; }
11 
12 double GeometricAnnealing::weight(double chi2) const {
13  double mphi = phi(chi2);
14  long double newtmp = mphi / (mphi + phi(theChi2cut));
15  if (edm::isNotFinite(newtmp)) {
16  if (chi2 < theChi2cut)
17  newtmp = 1.;
18  else
19  newtmp = 0.;
20  }
21  return newtmp;
22 }
23 
25 
26 double GeometricAnnealing::phi(double chi2) const { return exp(-.5 * chi2 / theT); }
27 
29  // std::cout << "[GeometricAnnealing] cutoff called!" << std::endl;
30  return sqrt(theChi2cut);
31 }
32 
33 double GeometricAnnealing::currentTemp() const { return theT; }
34 
35 double GeometricAnnealing::initialTemp() const { return theT0; }
36 
37 bool GeometricAnnealing::isAnnealed() const { return (theT < 1.02); }
38 
40  std::cout << "[GeometricAnnealing] chi2_cut=" << theChi2cut << ", Tini=" << theT0 << ", ratio=" << theRatio
41  << std::endl;
42 }
double currentTemp() const override
double phi(double chi2) const override
double initialTemp() const override
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void resetAnnealing() override
double weight(double chi2) const override
double cutoff() const override
T sqrt(T t)
Definition: SSEVec.h:19
GeometricAnnealing(const double cutoff=3.0, const double T=256.0, const double annealing_ratio=0.25)
void anneal() override
bool isAnnealed() const override
long double T
void debug() const override