ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
CondReaderAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
CondReaderAlg.h
"
13
#include "
StoreGate/ReadHandle.h
"
14
#include "
StoreGate/ReadCondHandle.h
"
15
#include "GaudiKernel/Chrono.h"
16
17
18
namespace
DMTest
{
19
20
26
CondReaderAlg::CondReaderAlg
(
const
std::string& name, ISvcLocator *pSvcLocator)
27
:
AthReentrantAlgorithm
(name, pSvcLocator),
28
m_chronoSvc
(
"ChronoStatSvc"
, name),
29
m_attrListKey
(
"/DMTest/TestAttrList"
),
30
m_scondKey
(
"scond"
,
"DMTest"
),
31
m_s2Key
(
"/DMTest/S2"
),
32
m_s3Key
(
""
),
33
m_rltestKey
(
""
),
34
m_tstestKey
(
""
)
35
{
36
declareProperty
(
"ChronoSvc"
,
m_chronoSvc
);
37
declareProperty
(
"AttrListKey"
,
m_attrListKey
);
38
declareProperty
(
"SCondKey"
,
m_scondKey
);
39
declareProperty
(
"S2Key"
,
m_s2Key
);
40
declareProperty
(
"S3Key"
,
m_s3Key
);
41
declareProperty
(
"RLTestKey"
,
m_rltestKey
);
42
declareProperty
(
"TSTestKey"
,
m_tstestKey
);
43
declareProperty
(
"Spins"
,
m_spins
= 0);
44
}
45
46
50
StatusCode
CondReaderAlg::initialize
()
51
{
52
ATH_CHECK
(
m_chronoSvc
.retrieve() );
53
ATH_CHECK
(
m_eventInfoKey
.initialize() );
54
ATH_CHECK
(
m_attrListKey
.initialize() );
55
ATH_CHECK
(
m_scondKey
.initialize() );
56
57
// Allow running without POOL payload
58
if
( !
m_s2Key
.key().empty())
ATH_CHECK
(
m_s2Key
.initialize() );
59
60
if
( !
m_s3Key
.key().empty())
ATH_CHECK
(
m_s3Key
.initialize() );
61
if
( !
m_rltestKey
.key().empty())
ATH_CHECK
(
m_rltestKey
.initialize() );
62
if
( !
m_tstestKey
.key().empty())
ATH_CHECK
(
m_tstestKey
.initialize() );
63
64
return
StatusCode::SUCCESS;
65
}
66
67
71
StatusCode
CondReaderAlg::execute
(
const
EventContext& ctx)
const
72
{
73
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
74
75
ATH_MSG_INFO
(
"Event "
<< eventInfo->eventNumber() <<
76
" LBN "
<< eventInfo->lumiBlock());
77
78
SG::ReadCondHandle<AthenaAttributeList>
attrList (
m_attrListKey
, ctx);
79
ATH_MSG_INFO
(
" xint "
<< (**attrList)[
"xint"
]);
80
81
SG::ReadCondHandle<DMTest::S1>
s1 (
m_scondKey
, ctx);
82
ATH_MSG_INFO
(
" scond "
<< s1->m_x );
83
84
if
(!
m_s2Key
.key().empty()) {
85
SG::ReadCondHandle<DMTest::S1>
s2 (
m_s2Key
, ctx);
86
ATH_MSG_INFO
(
" s2 "
<< s2->m_x );
87
}
88
89
if
(!
m_rltestKey
.key().empty()) {
90
SG::ReadCondHandle<AthenaAttributeList>
rl (
m_rltestKey
, ctx);
91
ATH_MSG_INFO
(
" rl "
<< (**rl)[
"xint"
]);
92
}
93
94
if
(!
m_tstestKey
.key().empty()) {
95
SG::ReadCondHandle<AthenaAttributeList>
ts
(
m_tstestKey
, ctx);
96
ATH_MSG_INFO
(
" ts "
<< (**
ts
)[
"xint"
]);
97
}
98
99
if
(!
m_s3Key
.key().empty()) {
100
SG::ReadCondHandle<DMTest::S3>
s3 (
m_s3Key
, ctx);
101
ATH_MSG_INFO
(
" s3 "
<< s3->m_x );
102
}
103
104
{
105
std::string xint =
"xint"
;
106
Chrono chrono (&*
m_chronoSvc
,
"spin time"
);
107
int
xx [[maybe_unused]] = 0;
108
for
(
size_t
i = 0; i <
m_spins
; i++) {
109
{
110
SG::ReadCondHandle<AthenaAttributeList>
attrList (
m_attrListKey
, ctx);
111
// cppcheck-suppress internalAstError; work around cppcheck 2.0 parse failure
112
xx += (**attrList)[xint].template data<int>();
113
}
114
{
115
SG::ReadCondHandle<DMTest::S1>
s1 (
m_scondKey
, ctx);
116
xx += s1->m_x;
117
}
118
{
119
SG::ReadCondHandle<DMTest::S1>
s2 (
m_s2Key
, ctx);
120
xx += s2->m_x;
121
}
122
}
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
129
}
// namespace DMTest
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CondReaderAlg.h
Testing conditions handling.
ReadCondHandle.h
ReadHandle.h
Handle class for reading from StoreGate.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DMTest::CondReaderAlg::m_tstestKey
SG::ReadCondHandleKey< AthenaAttributeList > m_tstestKey
Definition
CondReaderAlg.h:66
DMTest::CondReaderAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
CondReaderAlg.h:60
DMTest::CondReaderAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
CondReaderAlg.cxx:71
DMTest::CondReaderAlg::m_attrListKey
SG::ReadCondHandleKey< AthenaAttributeList > m_attrListKey
Definition
CondReaderAlg.h:61
DMTest::CondReaderAlg::m_scondKey
SG::ReadCondHandleKey< DMTest::S1 > m_scondKey
Definition
CondReaderAlg.h:62
DMTest::CondReaderAlg::CondReaderAlg
CondReaderAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
CondReaderAlg.cxx:26
DMTest::CondReaderAlg::m_rltestKey
SG::ReadCondHandleKey< AthenaAttributeList > m_rltestKey
Definition
CondReaderAlg.h:65
DMTest::CondReaderAlg::m_spins
size_t m_spins
Definition
CondReaderAlg.h:67
DMTest::CondReaderAlg::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
CondReaderAlg.cxx:50
DMTest::CondReaderAlg::m_chronoSvc
ServiceHandle< IChronoStatSvc > m_chronoSvc
Definition
CondReaderAlg.h:59
DMTest::CondReaderAlg::m_s3Key
SG::ReadCondHandleKey< DMTest::S3 > m_s3Key
Definition
CondReaderAlg.h:64
DMTest::CondReaderAlg::m_s2Key
SG::ReadCondHandleKey< DMTest::S1 > m_s2Key
Definition
CondReaderAlg.h:63
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
ts
int ts
Definition
globals.cxx:24
DMTest
Definition
B.h:23
Generated on
for ATLAS Offline Software by
1.17.0