ATLAS Offline Software
Loading...
Searching...
No Matches
DetAnnealingMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*********************************************************************
6 DetAnnealingMaker.cxx - Description in header file
7*********************************************************************/
8
10#include <cmath>
11
12namespace {
13 double gauss(const double value2, const double error2) {
14 return exp(-1./2.*value2/error2);
15 }
16}
17
18
19namespace Trk
20{
21
22 DetAnnealingMaker::DetAnnealingMaker(const std::string& t, const std::string& n, const IInterface* p) :
23 base_class(t,n,p),
25 m_cutoff(9.)
26 {
27 declareProperty("SetOfTemperatures", m_SetOfTemperatures);
28 declareProperty("Cutoff", m_cutoff);
29 }
30
32 {
33 ATH_MSG_DEBUG( "Initialize successful" );
34 return StatusCode::SUCCESS;
35 }
36
38 {
39 ATH_MSG_DEBUG( "Finalize successful" );
40 return StatusCode::SUCCESS;
41 }
42
43 void DetAnnealingMaker::reset(AnnealingState& state) const
44 {
45 state = 0;
46 ATH_MSG_DEBUG( "Annealing reset" );
47 }
48
49 void DetAnnealingMaker::anneal(AnnealingState& state) const {
50
51//check if there are some temperatures
52 if (m_SetOfTemperatures.empty())
53 {
54 ATH_MSG_ERROR( "The vector SetOfTemperatures for the annealing is empty" );
55 }
56 //go one step further
57 ++state;
58 }
59
60 double DetAnnealingMaker::getWeight(const AnnealingState& state,
61 double chisq,
62 const std::vector<double>& allchisq) const
63 {
64 double temp = actualTemp (state);
65 double allweight(0.);
66 for (double ch : allchisq) {
67 allweight+=gauss(ch,temp);
68 }
69 double actualweight(gauss(chisq,temp));
70 return actualweight/(gauss(m_cutoff,temp)+allweight);
71 }
72
73 double DetAnnealingMaker::getWeight(const AnnealingState& state,
74 double chisq) const
75 {
76 double temp = actualTemp (state);
77 return gauss(chisq,temp)/(gauss(m_cutoff,temp)+gauss(chisq,temp));
78 }
79
80}
81
82
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
virtual StatusCode finalize() override
virtual double getWeight(const AnnealingState &state, double chisq, const std::vector< double > &allchisq) const override
Weight access method.
std::vector< double > m_SetOfTemperatures
A vector of temperatures, you will start from SetOfTemperature[0] and Anneal towards SetOfTemperature...
DetAnnealingMaker(const std::string &t, const std::string &n, const IInterface *p)
Default constructor due to Athena interface.
double m_cutoff
Weight will be insensitive to chi2 at order of magnitude of the cutoff...
virtual void anneal(AnnealingState &state) const override
One more annealing step.
virtual void reset(AnnealingState &state) const override
Resets the annealing process to its beginning.
virtual double actualTemp(const AnnealingState &state) const override
Access to the actual temperature value.
virtual StatusCode initialize() override
Ensure that the ATLAS eigen extensions are properly loaded.