ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
SCT_ConditionsParameterTestAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
8
9
// Include SCT_ConditionsParameterTestAlg and Tool
10
#include "
SCT_ConditionsParameterTestAlg.h
"
11
#include "
SCT_ConditionsData/SCT_ConditionsParameters.h
"
12
#include "
SCT_ConditionsData/SCT_CondParameterData.h
"
13
14
// Local include
15
#include "
SCT_SimpleHisto.h
"
16
#include "
SCT_ConditionsUtilities.h
"
17
18
// Include Athena stuff
19
#include "
Identifier/IdentifierHash.h
"
20
21
// Include STL stuff
22
#include <string>
23
#include <iostream>
24
#include <fstream>
25
26
using namespace
SCT_ConditionsAlgorithms
;
27
28
SCT_ConditionsParameterTestAlg::SCT_ConditionsParameterTestAlg
(
const
std::string& name, ISvcLocator* pSvcLocator ) :
29
AthReentrantAlgorithm
(name, pSvcLocator)
30
{
//nop
31
}
32
33
//----------------------------------------------------------------------
34
StatusCode
SCT_ConditionsParameterTestAlg::initialize
() {
35
// Get the messaging service, print where you are
36
ATH_MSG_INFO
(
"in initialize()"
);
37
//
38
ATH_CHECK
(
m_conditionsParameterTool
.retrieve());
39
40
return
StatusCode::SUCCESS;
41
}
// SCT_ConditionsParameterTestAlg::execute()
42
43
//----------------------------------------------------------------------
44
StatusCode
SCT_ConditionsParameterTestAlg::execute
(
const
EventContext& ctx)
const
{
45
//This method is only used to test the service, and only used within this package,
46
// so the INFO level messages have no impact on performance of these services when used by clients
47
ATH_MSG_DEBUG
(
"in execute()"
);
48
//
49
StatusCode
sc
{StatusCode::SUCCESS};
50
51
// Get the current event
52
ATH_MSG_DEBUG
(
"Current Run.Event,Time: "
53
<<
"["
<< ctx.eventID().run_number()
54
<<
"."
<< ctx.eventID().event_number()
55
<<
","
<< ctx.eventID().time_stamp()
56
<<
"]"
);
57
58
bool
paramFilled{
false
};
59
ATH_MSG_INFO
(
m_conditionsParameterTool
);
60
61
try
{
62
paramFilled =(
m_conditionsParameterTool
->filled(ctx));
63
}
catch
(...) {
64
ATH_MSG_FATAL
(
"Exception caught while trying to determine whether the data object was filled"
);
65
return
StatusCode::FAILURE;
66
}
67
68
try
{
69
float
maxval{
m_conditionsParameterTool
->max(
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
70
float
minval{
m_conditionsParameterTool
->min(
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
71
float
avg{
m_conditionsParameterTool
->avg(
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
72
float
sd{
m_conditionsParameterTool
->sd(
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
73
unsigned
int
n{
m_conditionsParameterTool
->n(
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
74
float
thresh{
m_conditionsParameterTool
->value(
IdentifierHash
{1760},
SCT_CondParameterData::AVG_THRESHOLD
, ctx)};
75
ATH_MSG_INFO
(
" value element 1760: "
<< thresh);
76
ATH_MSG_INFO
(
" max threshold: "
<< maxval);
77
ATH_MSG_INFO
(
" min threshold: "
<< minval);
78
ATH_MSG_INFO
(
" avg threshold: "
<< avg);
79
ATH_MSG_INFO
(
" standard deviation: "
<< sd);
80
ATH_MSG_INFO
(
" no measured: "
<< n);
81
}
catch
(...) {
82
ATH_MSG_FATAL
(
"Exception caught while trying to access the thresholds"
);
83
return
StatusCode::FAILURE;
84
}
85
//simple histogram
86
SCT_ConditionsAlgorithms::S_t
histo;
87
init
(histo, 0.0, 8.0, 100);
88
std::vector<float> values;
89
m_conditionsParameterTool
->getValues(values,
SCT_CondParameterData::AVG_THRESHOLD
, ctx);
90
for
(
float
i: values) {
91
fill
(histo, i);
92
}
93
std::string histoString =
asXmlString
(histo);
94
95
ATH_MSG_INFO
(histoString);
96
97
if
(not paramFilled)
sc
= StatusCode::FAILURE;
98
99
return
sc
;
100
}
// SCT_ConditionsParameterTestAlg::execute()
101
102
//----------------------------------------------------------------------
103
StatusCode
SCT_ConditionsParameterTestAlg::finalize
() {
104
// Get the messaging service, print where you are
105
ATH_MSG_INFO
(
"in finalize()"
);
106
107
// string xmlPath{CoveritySafe::getenv("XMLPATH")};
108
// size_t found{xmlPath.find(":")};
109
// if (found!=std::string::npos) xmlPath = xmlPath.substr(0, found);
110
std::string stylePath{
"./histo.xsl"
};
111
std::string filename{
"./thresholds.xml"
};
112
ATH_MSG_INFO
(
"Filename: "
<< filename);
113
114
ATH_MSG_INFO
(
"------------"
);
115
116
std::ofstream opFile{filename.c_str(), std::ios::out};
117
opFile <<
xmlHeader
();
118
opFile <<
stylesheet
(stylePath);
119
120
return
StatusCode::SUCCESS;
121
}
// SCT_ConditionsParameterTestAlg::finalize()
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IdentifierHash.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
SCT_CondParameterData.h
header file for data object for SCT_ConditionsParameterTool and SCT_ConditionsParameterCondAlg.
SCT_ConditionsParameterTestAlg.h
Header file for TestConditionsParameter class.
SCT_ConditionsParameters.h
header file containing the number of elements and enumerated type of parameters which may be retrieve...
SCT_ConditionsUtilities.h
header file for SCT conditions utilities
SCT_SimpleHisto.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
SCT_CondParameterData::AVG_THRESHOLD
@ AVG_THRESHOLD
Definition
SCT_CondParameterData.h:35
SCT_ConditionsParameterTestAlg::initialize
virtual StatusCode initialize() override
Gaudi initialiser.
Definition
SCT_ConditionsParameterTestAlg.cxx:34
SCT_ConditionsParameterTestAlg::finalize
virtual StatusCode finalize() override
Gaudi finaliser.
Definition
SCT_ConditionsParameterTestAlg.cxx:103
SCT_ConditionsParameterTestAlg::SCT_ConditionsParameterTestAlg
SCT_ConditionsParameterTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SCT_ConditionsParameterTestAlg.cxx:28
SCT_ConditionsParameterTestAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi executer.
Definition
SCT_ConditionsParameterTestAlg.cxx:44
SCT_ConditionsParameterTestAlg::m_conditionsParameterTool
ToolHandle< ISCT_ConditionsParameterTool > m_conditionsParameterTool
Definition
SCT_ConditionsParameterTestAlg.h:38
SCT_ConditionsAlgorithms
SCT_SimpleHisto.h C++ projects.
Definition
SCT_ConditionsUtilities.cxx:14
SCT_ConditionsAlgorithms::xmlHeader
std::string xmlHeader(const std::string &version="1.0", const std::string &encoding="UTF-8")
Definition
SCT_SimpleHisto.h:64
SCT_ConditionsAlgorithms::init
bool init(S_t &s, const float xlo, const float xhi, const unsigned int nbins)
Initialize a map to be used as a histogram.
Definition
SCT_SimpleHisto.h:26
SCT_ConditionsAlgorithms::S_t
std::map< float, unsigned int > S_t
Definition
SCT_SimpleHisto.h:22
SCT_ConditionsAlgorithms::fill
int fill(S_t &s, const float value)
Definition
SCT_SimpleHisto.h:40
SCT_ConditionsAlgorithms::stylesheet
std::string stylesheet(const std::string &path)
Definition
SCT_SimpleHisto.h:68
SCT_ConditionsAlgorithms::asXmlString
std::string asXmlString(const S_t &s)
Definition
SCT_SimpleHisto.h:53
Generated on
for ATLAS Offline Software by
1.17.0