ATLAS Offline Software
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 
9 // Include SCT_ConditionsParameterTestAlg and Tool
13 
14 // Local include
15 #include "SCT_SimpleHisto.h"
17 
18 // Include Athena stuff
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 //----------------------------------------------------------------------
35  // Get the messaging service, print where you are
36  ATH_MSG_INFO("in initialize()");
37  //
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};
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 {
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
87  init(histo, 0.0, 8.0, 100);
88  std::vector<float> values;
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 //----------------------------------------------------------------------
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()
SCT_ConditionsAlgorithms::stylesheet
std::string stylesheet(const std::string &path)
Definition: SCT_SimpleHisto.h:68
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:36
SCT_ConditionsParameterTestAlg::finalize
virtual StatusCode finalize() override
Gaudi finaliser.
Definition: SCT_ConditionsParameterTestAlg.cxx:103
SCT_ConditionsParameterTestAlg.h
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SCT_ConditionsParameters.h
header file containing the number of elements and enumerated type of parameters which may be retrieve...
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
SCT_ConditionsParameterTestAlg::SCT_ConditionsParameterTestAlg
SCT_ConditionsParameterTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ConditionsParameterTestAlg.cxx:28
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
python.selector.AtlRunQuerySelectorLhcOlc.sd
sd
Definition: AtlRunQuerySelectorLhcOlc.py:612
SCT_ConditionsAlgorithms::xmlHeader
std::string xmlHeader(const std::string &version="1.0", const std::string &encoding="UTF-8")
Definition: SCT_SimpleHisto.h:64
SCT_SimpleHisto.h
SCT_CondParameterData.h
header file for data object for SCT_ConditionsParameterTool and SCT_ConditionsParameterCondAlg.
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Recovery.avg
def avg(a, b)
Definition: Recovery.py:79
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
SCT_ConditionsParameterTestAlg::initialize
virtual StatusCode initialize() override
Gaudi initialiser.
Definition: SCT_ConditionsParameterTestAlg.cxx:34
SCT_ConditionsAlgorithms::S_t
std::map< float, unsigned int > S_t
Definition: SCT_SimpleHisto.h:22
SCT_ConditionsAlgorithms::asXmlString
std::string asXmlString(const S_t &s)
Definition: SCT_SimpleHisto.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IdentifierHash.h
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
SCT_ConditionsAlgorithms
SCT_SimpleHisto.h C++ projects.
Definition: SCT_ConditionsUtilities.cxx:14
SCT_CondParameterData::AVG_THRESHOLD
@ AVG_THRESHOLD
Definition: SCT_CondParameterData.h:35
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
SCT_ConditionsParameterTestAlg::m_conditionsParameterTool
ToolHandle< ISCT_ConditionsParameterTool > m_conditionsParameterTool
Definition: SCT_ConditionsParameterTestAlg.h:38
SCT_ConditionsUtilities.h
SCT_ConditionsParameterTestAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi executer.
Definition: SCT_ConditionsParameterTestAlg.cxx:44
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415