ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
AtlasTest
DatabaseTest
IOVDbTestAlg
src
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
9
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
10
#include "
AthenaPoolUtilities/CondAttrListCollection.h
"
11
#include "
IOVDbTestCoolDCS.h
"
12
13
IOVDbTestCoolDCS::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
21
IOVDbTestCoolDCS::~IOVDbTestCoolDCS
()
22
{}
23
24
StatusCode
IOVDbTestCoolDCS::initialize
() {
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
36
StatusCode
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
89
StatusCode
IOVDbTestCoolDCS::finalize
()
90
{
91
return
StatusCode::SUCCESS;
92
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
AthenaAttributeList.h
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
IOVDbTestCoolDCS.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
AthenaAttributeList::print
void print(std::ostream &os) const
print to simulate function provided by old POOL AttributeList
Definition
AthenaAttributeList.cxx:16
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::end
const_iterator end() const
Definition
CondAttrListCollection.h:314
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition
CondAttrListCollection.h:308
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
IOVDbTestCoolDCS::finalize
virtual StatusCode finalize() override
Definition
IOVDbTestCoolDCS.cxx:89
IOVDbTestCoolDCS::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
IOVDbTestCoolDCS.cxx:36
IOVDbTestCoolDCS::m_par_atrcollist
std::vector< std::string > m_par_atrcollist
Definition
IOVDbTestCoolDCS.h:30
IOVDbTestCoolDCS::~IOVDbTestCoolDCS
virtual ~IOVDbTestCoolDCS()
Definition
IOVDbTestCoolDCS.cxx:21
IOVDbTestCoolDCS::IOVDbTestCoolDCS
IOVDbTestCoolDCS(const std::string &name, ISvcLocator *pSvcLocator)
Definition
IOVDbTestCoolDCS.cxx:13
IOVDbTestCoolDCS::initialize
virtual StatusCode initialize() override
Definition
IOVDbTestCoolDCS.cxx:24
IOVDbTestCoolDCS::m_par_atrlist
std::vector< std::string > m_par_atrlist
Definition
IOVDbTestCoolDCS.h:28
Generated on
for ATLAS Offline Software by
1.17.0