Main Page
Namespaces
Classes
Package Documentation
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
mps_fire.i
i
Definition:
mps_fire.py:338
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition:
isFinite.h:9
funct::false
false
Definition:
Factorize.h:36
DeterministicAnnealing::initialTemp
double initialTemp() const override
Definition:
DeterministicAnnealing.cc:69
DeterministicAnnealing::theIndex
unsigned int theIndex
Definition:
DeterministicAnnealing.h:58
std
Definition:
JetResolutionObject.h:80
DeterministicAnnealing::currentTemp
double currentTemp() const override
Definition:
DeterministicAnnealing.cc:64
DeterministicAnnealing::phi
double phi(double chi2) const override
Definition:
DeterministicAnnealing.cc:54
DeterministicAnnealing.h
DeterministicAnnealing::theChi2cut
double theChi2cut
Definition:
DeterministicAnnealing.h:59
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:18
DeterministicAnnealing::resetAnnealing
void resetAnnealing() override
Definition:
DeterministicAnnealing.cc:48
DeterministicAnnealing::cutoff
double cutoff() const override
Definition:
DeterministicAnnealing.cc:59
qjetsadder_cfi.cutoff
cutoff
Definition:
qjetsadder_cfi.py:11
DeterministicAnnealing::isAnnealed
bool isAnnealed() const override
Definition:
DeterministicAnnealing.cc:74
DeterministicAnnealing::theIsAnnealed
bool theIsAnnealed
Definition:
DeterministicAnnealing.h:60
DeterministicAnnealing::anneal
void anneal() override
Definition:
DeterministicAnnealing.cc:21
DeterministicAnnealing::debug
void debug() const override
Definition:
DeterministicAnnealing.cc:79
DeterministicAnnealing::DeterministicAnnealing
DeterministicAnnealing(float cutoff=3.0)
Definition:
DeterministicAnnealing.cc:10
DeterministicAnnealing::theTemperatures
std::vector< float > theTemperatures
Definition:
DeterministicAnnealing.h:54
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
JetChargeProducer_cfi.exp
exp
Definition:
JetChargeProducer_cfi.py:6
vertices_cff.chi2
chi2
Definition:
vertices_cff.py:34
DeterministicAnnealing::weight
double weight(double chi2) const override
Definition:
DeterministicAnnealing.cc:31
Generated for CMSSW Reference Manual by
1.8.11