ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
CondWriterAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
CondWriterAlg.h
"
13
#include "
DataModelTestDataCommon/S2Cond.h
"
14
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
15
#include "
AthenaKernel/IOVTime.h
"
16
#include "
AthenaKernel/IAthenaOutputStreamTool.h
"
17
18
19
namespace
DMTest
{
20
21
27
CondWriterAlg::CondWriterAlg
(
const
std::string &name, ISvcLocator *pSvcLocator)
28
:
AthAlgorithm
(name, pSvcLocator),
29
m_regSvc
(
"IOVRegistrationSvc"
, name),
30
m_streamer
(
"AthenaOutputStreamTool/CondStream"
, this)
31
{
32
declareProperty
(
"Streamer"
,
m_streamer
);
33
declareProperty
(
"AttrListKey"
,
m_attrListKey
=
"/DMTest/TestAttrList"
);
34
declareProperty
(
"S2Key"
,
m_s2Key
=
"/DMTest/S2"
);
35
declareProperty
(
"RLTestKey"
,
m_rltestKey
=
"/DMTest/RLTest"
);
36
declareProperty
(
"TSTestKey"
,
m_tstestKey
=
"/DMTest/TSTest"
);
37
}
38
39
43
StatusCode
CondWriterAlg::initialize
()
44
{
45
ATH_CHECK
(
m_regSvc
.retrieve() );
46
ATH_CHECK
(
m_streamer
.retrieve() );
47
ATH_CHECK
(
m_eventInfoKey
.initialize() );
48
return
StatusCode::SUCCESS;
49
}
50
51
52
StatusCode
CondWriterAlg::writeSCond
(
unsigned
int
count
)
53
{
54
auto
s2 = std::make_unique<DMTest::S2> (
count
* 50);
55
ATH_CHECK
(
detStore
()->overwrite (std::move (s2),
m_s2Key
,
true
) );
56
57
IAthenaOutputStreamTool::TypeKeyPairs
typeKeys {{
"DMTest::S2"
,
m_s2Key
}};
58
59
ATH_CHECK
(
m_streamer
->connectOutput() );
60
ATH_CHECK
(
m_streamer
->streamObjects (typeKeys) );
61
ATH_CHECK
(
m_streamer
->commitOutput() );
62
63
// Each IOV for this folder is two LBs long.
64
ATH_CHECK
(
m_regSvc
->registerIOV (
"DMTest::S2"
,
65
m_s2Key
,
66
"S2_noTag"
,
67
0, 0,
68
count
,
count
+2) );
69
70
return
StatusCode::SUCCESS;
71
}
72
73
74
StatusCode
CondWriterAlg::writeRLTest
(
unsigned
int
count
)
75
{
76
// Bound in LBN.
77
static
const
unsigned
int
bounds[] = { 0, 1, 3, 4, 7, 8, 9 };
78
79
unsigned
int
lbn =
count
/ 3;
80
const
unsigned
int
* pos = std::find (std::begin(bounds),
81
std::end(bounds),
82
lbn);
83
if
(pos != std::end(bounds)) {
84
unsigned
int
niov = pos - std::begin(bounds) + 1;
85
86
auto
attrList = std::make_unique<AthenaAttributeList>();
87
attrList->extend (
"xint"
,
"int"
);
88
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
(niov));
89
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_rltestKey
,
true
) );
90
91
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
92
m_rltestKey
,
93
"RL_noTag"
,
94
0, 0,
95
lbn,
IOVTime::MAXEVENT
) );
96
}
97
98
return
StatusCode::SUCCESS;
99
}
100
101
102
StatusCode
CondWriterAlg::writeTSTest
(
unsigned
int
count
)
103
{
104
// Bound in count.
105
static
const
unsigned
int
bounds[] = { 0, 3, 6, 7, 10, 17, 19, 22, 26 };
106
107
const
unsigned
int
* pos = std::find (std::begin(bounds),
108
std::end(bounds),
109
count
);
110
if
(pos != std::end(bounds)) {
111
unsigned
int
niov = pos - std::begin(bounds) + 1;
112
113
auto
attrList = std::make_unique<AthenaAttributeList>();
114
attrList->extend (
"xint"
,
"int"
);
115
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
(niov * 100));
116
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_tstestKey
,
true
) );
117
118
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
119
m_tstestKey
,
120
"TS_noTag"
,
121
static_cast<
uint64_t
>
(
count
) * 1000000000,
122
IOVTime::MAXTIMESTAMP
) );
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
132
StatusCode
CondWriterAlg::execute
(
const
EventContext& ctx)
133
{
134
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
135
unsigned
int
count
= eventInfo->eventNumber() - 1;
// events start with 1
136
137
auto
attrList = std::make_unique<AthenaAttributeList>();
138
attrList->extend (
"xint"
,
"int"
);
139
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
((
count
+1)*10));
140
141
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_attrListKey
,
true
) );
142
143
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
144
m_attrListKey
,
145
"AttrList_noTag"
,
146
0,
IOVTime::MAXRUN
,
147
count
,
IOVTime::MAXEVENT
) );
148
149
if
(
count
%2 == 0) {
150
ATH_CHECK
(
writeSCond
(
count
) );
151
}
152
153
ATH_CHECK
(
writeRLTest
(
count
) );
154
ATH_CHECK
(
writeTSTest
(
count
) );
155
156
return
StatusCode::SUCCESS;
157
}
158
159
160
}
// namespace DMTest
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AthenaAttributeList.h
CondWriterAlg.h
IAthenaOutputStreamTool.h
Interface to an output stream tool.
IOVTime.h
Basic time unit for IOVSvc.
S2Cond.h
Conditions declarations for S2.
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
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
DMTest::CondWriterAlg::writeRLTest
StatusCode writeRLTest(unsigned int count)
Definition
CondWriterAlg.cxx:74
DMTest::CondWriterAlg::CondWriterAlg
CondWriterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
CondWriterAlg.cxx:27
DMTest::CondWriterAlg::m_tstestKey
std::string m_tstestKey
Definition
CondWriterAlg.h:67
DMTest::CondWriterAlg::m_s2Key
std::string m_s2Key
Definition
CondWriterAlg.h:65
DMTest::CondWriterAlg::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
CondWriterAlg.cxx:43
DMTest::CondWriterAlg::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
Definition
CondWriterAlg.h:62
DMTest::CondWriterAlg::execute
virtual StatusCode execute(const EventContext &ctx) override
Algorithm event processing.
Definition
CondWriterAlg.cxx:132
DMTest::CondWriterAlg::m_rltestKey
std::string m_rltestKey
Definition
CondWriterAlg.h:66
DMTest::CondWriterAlg::m_attrListKey
std::string m_attrListKey
Definition
CondWriterAlg.h:64
DMTest::CondWriterAlg::writeTSTest
StatusCode writeTSTest(unsigned int count)
Definition
CondWriterAlg.cxx:102
DMTest::CondWriterAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
CondWriterAlg.h:63
DMTest::CondWriterAlg::writeSCond
StatusCode writeSCond(unsigned int count)
Definition
CondWriterAlg.cxx:52
DMTest::CondWriterAlg::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition
CondWriterAlg.h:61
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition
IAthenaOutputStreamTool.h:100
IOVTime::MAXTIMESTAMP
static constexpr uint64_t MAXTIMESTAMP
Definition
IOVTime.h:58
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition
IOVTime.h:48
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition
IOVTime.h:51
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
DMTest
Definition
B.h:23
Generated on
for ATLAS Offline Software by
1.17.0