CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoVertex/VertexTools/src/GeometricAnnealing.cc

Go to the documentation of this file.
00001 #include "RecoVertex/VertexTools/interface/GeometricAnnealing.h"
00002 #include <cmath>
00003 #include <iostream>
00004 #include <limits>
00005 
00006 GeometricAnnealing::GeometricAnnealing (
00007      const double cutoff, const double T, const double ratio ) :
00008   theT0(T), theT(T), theChi2cut(cutoff*cutoff), theRatio( ratio )
00009 {}
00010 
00011 void GeometricAnnealing::anneal()
00012 {
00013   theT=1+(theT-1)*theRatio;
00014 }
00015 
00016 double GeometricAnnealing::weight ( double chi2 ) const
00017 {
00018   double mphi = phi ( chi2 );
00019   long double newtmp = mphi / ( mphi + phi ( theChi2cut ) );
00020   if ( std::isinf(newtmp) )
00021   {
00022     if ( chi2 < theChi2cut ) newtmp=1.;
00023     else newtmp=0.;
00024   }
00025   return newtmp;
00026 }
00027 
00028 void GeometricAnnealing::resetAnnealing()
00029 {
00030   theT=theT0;
00031 }
00032 
00033 double GeometricAnnealing::phi( double chi2 ) const
00034 {
00035   return exp ( -.5 * chi2 / theT );
00036 }
00037 
00038 double GeometricAnnealing::cutoff() const
00039 {
00040   // std::cout << "[GeometricAnnealing] cutoff called!" << std::endl;
00041   return sqrt(theChi2cut);
00042 }
00043 
00044 double GeometricAnnealing::currentTemp() const
00045 {
00046   return theT;
00047 }
00048 
00049 double GeometricAnnealing::initialTemp() const
00050 {
00051   return theT0;
00052 }
00053 
00054 bool GeometricAnnealing::isAnnealed() const
00055 {
00056   return ( theT < 1.02 );
00057 }
00058 
00059 void GeometricAnnealing::debug() const
00060 {
00061   std::cout << "[GeometricAnnealing] chi2_cut=" << theChi2cut << ", Tini="
00062        << theT0 << ", ratio=" << theRatio << std::endl;
00063 }