ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbTestCoolDCS.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// IOVDbTestCoolDCS.cxx
6// Algorithm to demonstrate simple reading of COOL DCS data into Athena
7// Richard Hawkings started 9/9/05
8
11#include "IOVDbTestCoolDCS.h"
12
13IOVDbTestCoolDCS::IOVDbTestCoolDCS(const std::string& name,
14 ISvcLocator* pSvcLocator) :
15 AthReentrantAlgorithm(name, pSvcLocator)
16{
17 declareProperty("AttrListFolders",m_par_atrlist);
18 declareProperty("AttrListCollFolders",m_par_atrcollist);
19}
20
23
25
26 ATH_MSG_INFO("DCS conditions data folders to be read as AthenaAttributeList (single channel)");
27 for (std::vector<std::string>::const_iterator itr=m_par_atrlist.begin();
28 itr!=m_par_atrlist.end();++itr) ATH_MSG_INFO(*itr);
29 ATH_MSG_INFO("DCS conditions data folders to be read as CondAttrListCollection (multichannel)");
30 for (std::vector<std::string>::const_iterator itr=m_par_atrcollist.begin();
31 itr!=m_par_atrcollist.end();++itr) ATH_MSG_INFO(*itr);
32
33 return StatusCode::SUCCESS;
34}
35
36StatusCode IOVDbTestCoolDCS::execute (const EventContext& ctx) const {
37 // first print event number and time details
38 int time=ctx.eventID().time_stamp();
39 ATH_MSG_INFO("In run/event [" << ctx.eventID().run_number() <<
40 "," << ctx.eventID().event_number() << "] timestamp " << time);
41 // print the timestamp in UTC
42 time_t ttime=static_cast<time_t>(time);
43 struct tm tm;
44 char tmbuf[32];
45 ATH_MSG_INFO("Timestamp UTC: " << asctime_r(gmtime_r(&ttime, &tm), tmbuf));
46
47 // print all the AthenaAttributeList
48 const AthenaAttributeList* atrlist = nullptr;;
49 for (std::vector<std::string>::const_iterator itr=m_par_atrlist.begin();
50 itr!=m_par_atrlist.end();++itr) {
51 if (StatusCode::SUCCESS==detStore()->retrieve(atrlist,*itr)) {
52 // the following code dumps the attribute list into a string for printing
53 // to access individual elements by name, use e.g.
54 // float var1=(*atrlist)["T04"].data<float>();
55 // to get the value of a float column called T04 into var1
56 std::ostringstream atrstring;
57 atrlist->print(atrstring);
58 ATH_MSG_INFO("Values for folder " << *itr << ":");
59 ATH_MSG_INFO(atrstring.str());
60 } else {
61 ATH_MSG_ERROR("Could not retrieve AthenaAttributeList ");
62 }
63 }
64
65 // print all CondAttrListCollection
66 const CondAttrListCollection* atrlistcol;
67 for (std::vector<std::string>::const_iterator itr=m_par_atrcollist.begin();
68 itr!=m_par_atrcollist.end();++itr) {
69 if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,*itr)) {
70 // loop over collection
71 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin();
72 citr!=atrlistcol->end();++citr) {
73 // the following code dumps the attribute list into a string for printing
74 // to access individual elements by name, use e.g.
75 // float var1=(((*citr).second)["T04"]).data<float>();
76 // to get the value of a float column called T04 into var1
77 std::ostringstream atrstring;
78 (*citr).second.toOutputStream(atrstring);
79 ATH_MSG_INFO("Channel " << (*citr).first << " "
80 << atrstring.str());
81 }
82 } else {
83 ATH_MSG_INFO("Could not retrieve CondAttrListCollection " << *itr);
84 }
85 }
86 return StatusCode::SUCCESS;
87}
88
90{
91 return StatusCode::SUCCESS;
92}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
An AttributeList represents a logical row of attributes in a metadata table.
void print(std::ostream &os) const
print to simulate function provided by old POOL AttributeList
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
virtual StatusCode finalize() override
virtual StatusCode execute(const EventContext &ctx) const override
std::vector< std::string > m_par_atrcollist
IOVDbTestCoolDCS(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
std::vector< std::string > m_par_atrlist