Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
RecoVertex
VertexTools
src
DeterministicAnnealing.cc
Go to the documentation of this file.
1
#include "
RecoVertex/VertexTools/interface/DeterministicAnnealing.h
"
2
#include "
FWCore/Utilities/interface/isFinite.h
"
3
#include <cmath>
4
#include <vector>
5
#include <iostream>
6
#include <limits>
7
8
using namespace
std;
9
10
DeterministicAnnealing::DeterministicAnnealing
(
float
cutoff ) :
11
theTemperatures({256,64,16,4,2,1}),
12
theIndex
(0),
theChi2cut
( cutoff*cutoff ),
theIsAnnealed
(
false
)
13
{
14
}
15
16
DeterministicAnnealing::DeterministicAnnealing
(
const
vector < float > & sched,
float
cutoff ) :
17
theTemperatures(sched),
theIndex
(0),
theChi2cut
( cutoff*cutoff ),
theIsAnnealed
(
false
)
18
{
19
}
20
21
void
DeterministicAnnealing::anneal
()
22
{
23
if
(
theIndex
< (
theTemperatures
.size() - 1 ) )
24
{
25
theIndex
++;
26
}
else
{
27
theIsAnnealed
=
true
;
28
};
29
}
30
31
double
DeterministicAnnealing::weight
(
double
chi2
)
const
32
{
33
long
double
mphi =
phi
( chi2 );
34
/*
35
if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
36
return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
37
*/
38
// return mphi / ( mphi + phi ( theChi2cut ) );
39
long
double
newtmp = mphi / ( mphi +
phi
(
theChi2cut
) );
40
if
(
edm::isNotFinite
(newtmp ) )
41
{
42
if
( chi2 <
theChi2cut
) newtmp=1.;
43
else
newtmp=0.;
44
}
45
return
newtmp;
46
}
47
48
void
DeterministicAnnealing::resetAnnealing
()
49
{
50
theIndex
=0;
51
theIsAnnealed
=
false
;
52
}
53
54
inline
double
DeterministicAnnealing::phi
(
double
chi2
)
const
55
{
56
return
exp
( -.5 * chi2 /
theTemperatures
[
theIndex
] );
57
}
58
59
double
DeterministicAnnealing::cutoff
()
const
60
{
61
return
sqrt
(
theChi2cut
);
62
}
63
64
double
DeterministicAnnealing::currentTemp
()
const
65
{
66
return
theTemperatures
[
theIndex
];
67
}
68
69
double
DeterministicAnnealing::initialTemp
()
const
70
{
71
return
theTemperatures
[0];
72
}
73
74
bool
DeterministicAnnealing::isAnnealed
()
const
75
{
76
return
theIsAnnealed
;
77
}
78
79
void
DeterministicAnnealing::debug
()
const
80
{
81
cout
<<
"[DeterministicAnnealing] schedule="
;
82
for
( vector< float >::const_iterator
i
=
theTemperatures
.begin();
83
i
!=
theTemperatures
.end() ; ++
i
)
84
{
85
cout
<< *
i
<<
" "
;
86
};
87
cout
<< endl;
88
}
isFinite.h
i
int i
Definition:
DBlmapReader.cc:9
create_public_lumi_plots.exp
tuple exp
Definition:
create_public_lumi_plots.py:1088
DeterministicAnnealing::weight
double weight(double chi2) const
Definition:
DeterministicAnnealing.cc:31
DeterministicAnnealing::theIndex
unsigned int theIndex
Definition:
DeterministicAnnealing.h:58
theIndex
theIndex(0)
DeterministicAnnealing::currentTemp
double currentTemp() const
Definition:
DeterministicAnnealing.cc:64
DeterministicAnnealing::resetAnnealing
void resetAnnealing()
Definition:
DeterministicAnnealing.cc:48
edm::isNotFinite
bool isNotFinite(T x)
Definition:
isFinite.h:10
DeterministicAnnealing.h
DeterministicAnnealing::theChi2cut
double theChi2cut
Definition:
DeterministicAnnealing.h:59
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:18
DeterministicAnnealing::isAnnealed
bool isAnnealed() const
Definition:
DeterministicAnnealing.cc:74
theIsAnnealed
theIsAnnealed(false)
Definition:
DeterministicAnnealing.cc:12
DeterministicAnnealing::initialTemp
double initialTemp() const
Definition:
DeterministicAnnealing.cc:69
DeterministicAnnealing::cutoff
double cutoff() const
Definition:
DeterministicAnnealing.cc:59
DeterministicAnnealing::debug
void debug() const
Definition:
DeterministicAnnealing.cc:79
DeterministicAnnealing::theIsAnnealed
bool theIsAnnealed
Definition:
DeterministicAnnealing.h:60
theChi2cut
theChi2cut(cutoff *cutoff)
DeterministicAnnealing::anneal
void anneal()
Definition:
DeterministicAnnealing.cc:21
DeterministicAnnealing::DeterministicAnnealing
DeterministicAnnealing(float cutoff=3.0)
Definition:
DeterministicAnnealing.cc:10
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:145
DeterministicAnnealing::theTemperatures
std::vector< float > theTemperatures
Definition:
DeterministicAnnealing.h:54
edm::false
volatile std::atomic< bool > shutdown_flag false
Definition:
UnixSignalHandlers.cc:22
beam_dqm_sourceclient-live_cfg.chi2
tuple chi2
Definition:
beam_dqm_sourceclient-live_cfg.py:337
DeterministicAnnealing::phi
double phi(double chi2) const
Definition:
DeterministicAnnealing.cc:54
Generated for CMSSW Reference Manual by
1.8.5