src
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}), theIndex(0), theChi2cut(
cutoff
*
cutoff
), theIsAnnealed(
false
) {}
12
13
DeterministicAnnealing::DeterministicAnnealing
(
const
vector<float>& sched,
float
cutoff
)
14
: theTemperatures(sched), theIndex(0), theChi2cut(
cutoff
*
cutoff
), theIsAnnealed(
false
) {}
15
16
void
DeterministicAnnealing::anneal
() {
17
if
(
theIndex
< (
theTemperatures
.size() - 1)) {
18
theIndex
++;
19
}
else
{
20
theIsAnnealed
=
true
;
21
};
22
}
23
24
double
DeterministicAnnealing::weight
(
double
chi2
)
const
{
25
long
double
mphi =
phi
(
chi2
);
26
/*
27
if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
28
return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
29
*/
30
// return mphi / ( mphi + phi ( theChi2cut ) );
31
long
double
newtmp = mphi / (mphi +
phi
(
theChi2cut
));
32
if
(
edm::isNotFinite
(newtmp)) {
33
if
(
chi2
<
theChi2cut
)
34
newtmp = 1.;
35
else
36
newtmp = 0.;
37
}
38
return
newtmp;
39
}
40
41
void
DeterministicAnnealing::resetAnnealing
() {
42
theIndex
= 0;
43
theIsAnnealed
=
false
;
44
}
45
46
inline
double
DeterministicAnnealing::phi
(
double
chi2
)
const
{
return
exp
(-.5 *
chi2
/
theTemperatures
[
theIndex
]); }
47
48
double
DeterministicAnnealing::cutoff
()
const
{
return
sqrt
(
theChi2cut
); }
49
50
double
DeterministicAnnealing::currentTemp
()
const
{
return
theTemperatures
[
theIndex
]; }
51
52
double
DeterministicAnnealing::initialTemp
()
const
{
return
theTemperatures
[0]; }
53
54
bool
DeterministicAnnealing::isAnnealed
()
const
{
return
theIsAnnealed
; }
55
56
void
DeterministicAnnealing::debug
()
const
{
57
cout
<<
"[DeterministicAnnealing] schedule="
;
58
for
(vector<float>::const_iterator
i
=
theTemperatures
.begin();
i
!=
theTemperatures
.end(); ++
i
) {
59
cout
<< *
i
<<
" "
;
60
};
61
cout
<< endl;
62
}
isFinite.h
isoTrack_cff.chi2
chi2
Definition:
isoTrack_cff.py:46
mps_fire.i
i
Definition:
mps_fire.py:429
EcalSCDynamicDPhiParametersESProducer_cfi.cutoff
cutoff
Definition:
EcalSCDynamicDPhiParametersESProducer_cfi.py:15
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition:
isFinite.h:9
funct::false
false
Definition:
Factorize.h:29
DeterministicAnnealing::theIndex
unsigned int theIndex
Definition:
DeterministicAnnealing.h:52
std
Definition:
JetResolutionObject.h:76
DeterministicAnnealing::currentTemp
double currentTemp() const override
Definition:
DeterministicAnnealing.cc:50
DeterministicAnnealing::phi
double phi(double chi2) const override
Definition:
DeterministicAnnealing.cc:46
DeterministicAnnealing.h
DeterministicAnnealing::theChi2cut
double theChi2cut
Definition:
DeterministicAnnealing.h:53
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:23
DeterministicAnnealing::resetAnnealing
void resetAnnealing() override
Definition:
DeterministicAnnealing.cc:41
DeterministicAnnealing::weight
double weight(double chi2) const override
Definition:
DeterministicAnnealing.cc:24
DeterministicAnnealing::cutoff
double cutoff() const override
Definition:
DeterministicAnnealing.cc:48
DeterministicAnnealing::theIsAnnealed
bool theIsAnnealed
Definition:
DeterministicAnnealing.h:54
DeterministicAnnealing::anneal
void anneal() override
Definition:
DeterministicAnnealing.cc:16
DeterministicAnnealing::initialTemp
double initialTemp() const override
Definition:
DeterministicAnnealing.cc:52
DeterministicAnnealing::DeterministicAnnealing
DeterministicAnnealing(float cutoff=3.0)
Definition:
DeterministicAnnealing.cc:10
DeterministicAnnealing::isAnnealed
bool isAnnealed() const override
Definition:
DeterministicAnnealing.cc:54
DeterministicAnnealing::theTemperatures
std::vector< float > theTemperatures
Definition:
DeterministicAnnealing.h:48
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
JetChargeProducer_cfi.exp
exp
Definition:
JetChargeProducer_cfi.py:6
DeterministicAnnealing::debug
void debug() const override
Definition:
DeterministicAnnealing.cc:56
Generated for CMSSW Reference Manual by
1.8.14