Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:20

0001 #include "RecoVertex/VertexTools/interface/GeometricAnnealing.h"
0002 #include "FWCore/Utilities/interface/isFinite.h"
0003 #include <cmath>
0004 #include <iostream>
0005 #include <limits>
0006 
0007 GeometricAnnealing::GeometricAnnealing(const double cutoff, const double T, const double ratio)
0008     : theT0(T), theT(T), theChi2cut(cutoff * cutoff), theRatio(ratio) {}
0009 
0010 void GeometricAnnealing::anneal() { theT = 1 + (theT - 1) * theRatio; }
0011 
0012 double GeometricAnnealing::weight(double chi2) const {
0013   double mphi = phi(chi2);
0014   long double newtmp = mphi / (mphi + phi(theChi2cut));
0015   if (edm::isNotFinite(newtmp)) {
0016     if (chi2 < theChi2cut)
0017       newtmp = 1.;
0018     else
0019       newtmp = 0.;
0020   }
0021   return newtmp;
0022 }
0023 
0024 void GeometricAnnealing::resetAnnealing() { theT = theT0; }
0025 
0026 double GeometricAnnealing::phi(double chi2) const { return exp(-.5 * chi2 / theT); }
0027 
0028 double GeometricAnnealing::cutoff() const {
0029   // std::cout << "[GeometricAnnealing] cutoff called!" << std::endl;
0030   return sqrt(theChi2cut);
0031 }
0032 
0033 double GeometricAnnealing::currentTemp() const { return theT; }
0034 
0035 double GeometricAnnealing::initialTemp() const { return theT0; }
0036 
0037 bool GeometricAnnealing::isAnnealed() const { return (theT < 1.02); }
0038 
0039 void GeometricAnnealing::debug() const {
0040   std::cout << "[GeometricAnnealing] chi2_cut=" << theChi2cut << ", Tini=" << theT0 << ", ratio=" << theRatio
0041             << std::endl;
0042 }