ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
26using namespace SCT_ConditionsAlgorithms;
27
28SCT_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//----------------------------------------------------------------------
44StatusCode 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 {
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()
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
header file for data object for SCT_ConditionsParameterTool and SCT_ConditionsParameterCondAlg.
Header file for TestConditionsParameter class.
header file containing the number of elements and enumerated type of parameters which may be retrieve...
header file for SCT conditions utilities
An algorithm that can be simultaneously executed in multiple threads.
This is a "hash" representation of an Identifier.
virtual StatusCode initialize() override
Gaudi initialiser.
virtual StatusCode finalize() override
Gaudi finaliser.
SCT_ConditionsParameterTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi executer.
ToolHandle< ISCT_ConditionsParameterTool > m_conditionsParameterTool
SCT_SimpleHisto.h C++ projects.
std::string xmlHeader(const std::string &version="1.0", const std::string &encoding="UTF-8")
bool init(S_t &s, const float xlo, const float xhi, const unsigned int nbins)
Initialize a map to be used as a histogram.
std::map< float, unsigned int > S_t
int fill(S_t &s, const float value)
std::string stylesheet(const std::string &path)
std::string asXmlString(const S_t &s)