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-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
/*
5
*/
6
// $Id$
13
14
15
#include "
CondWriterAlg.h
"
16
#include "
DataModelTestDataCommon/S2Cond.h
"
17
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
18
#include "
AthenaKernel/IOVTime.h
"
19
#include "
AthenaKernel/IAthenaOutputStreamTool.h
"
20
21
22
namespace
DMTest
{
23
24
30
CondWriterAlg::CondWriterAlg
(
const
std::string &name, ISvcLocator *pSvcLocator)
31
:
AthAlgorithm
(name, pSvcLocator),
32
m_regSvc
(
"IOVRegistrationSvc"
, name),
33
m_streamer
(
"AthenaOutputStreamTool/CondStream"
, this)
34
{
35
declareProperty
(
"Streamer"
,
m_streamer
);
36
declareProperty
(
"AttrListKey"
,
m_attrListKey
=
"/DMTest/TestAttrList"
);
37
declareProperty
(
"S2Key"
,
m_s2Key
=
"/DMTest/S2"
);
38
declareProperty
(
"RLTestKey"
,
m_rltestKey
=
"/DMTest/RLTest"
);
39
declareProperty
(
"TSTestKey"
,
m_tstestKey
=
"/DMTest/TSTest"
);
40
}
41
42
46
StatusCode
CondWriterAlg::initialize
()
47
{
48
ATH_CHECK
(
m_regSvc
.retrieve() );
49
ATH_CHECK
(
m_streamer
.retrieve() );
50
ATH_CHECK
(
m_eventInfoKey
.initialize() );
51
return
StatusCode::SUCCESS;
52
}
53
54
55
StatusCode
CondWriterAlg::writeSCond
(
unsigned
int
count
)
56
{
57
auto
s2 = std::make_unique<DMTest::S2> (
count
* 50);
58
ATH_CHECK
(
detStore
()->overwrite (std::move (s2),
m_s2Key
) );
59
60
IAthenaOutputStreamTool::TypeKeyPairs
typeKeys {{
"DMTest::S2"
,
m_s2Key
}};
61
62
ATH_CHECK
(
m_streamer
->connectOutput() );
63
ATH_CHECK
(
m_streamer
->streamObjects (typeKeys) );
64
ATH_CHECK
(
m_streamer
->commitOutput() );
65
66
// Each IOV for this folder is two LBs long.
67
ATH_CHECK
(
m_regSvc
->registerIOV (
"DMTest::S2"
,
68
m_s2Key
,
69
"S2_noTag"
,
70
0, 0,
71
count
,
count
+2) );
72
73
return
StatusCode::SUCCESS;
74
}
75
76
77
StatusCode
CondWriterAlg::writeRLTest
(
unsigned
int
count
)
78
{
79
// Bound in LBN.
80
static
const
unsigned
int
bounds[] = { 0, 1, 3, 4, 7, 8, 9 };
81
82
unsigned
int
lbn =
count
/ 3;
83
const
unsigned
int
* pos = std::find (std::begin(bounds),
84
std::end(bounds),
85
lbn);
86
if
(pos != std::end(bounds)) {
87
unsigned
int
niov = pos - std::begin(bounds) + 1;
88
89
auto
attrList = std::make_unique<AthenaAttributeList>();
90
attrList->extend (
"xint"
,
"int"
);
91
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
(niov));
92
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_rltestKey
) );
93
94
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
95
m_rltestKey
,
96
"RL_noTag"
,
97
0, 0,
98
lbn,
IOVTime::MAXEVENT
) );
99
}
100
101
return
StatusCode::SUCCESS;
102
}
103
104
105
StatusCode
CondWriterAlg::writeTSTest
(
unsigned
int
count
)
106
{
107
// Bound in count.
108
static
const
unsigned
int
bounds[] = { 0, 3, 6, 7, 10, 17, 19, 22, 26 };
109
110
const
unsigned
int
* pos = std::find (std::begin(bounds),
111
std::end(bounds),
112
count
);
113
if
(pos != std::end(bounds)) {
114
unsigned
int
niov = pos - std::begin(bounds) + 1;
115
116
auto
attrList = std::make_unique<AthenaAttributeList>();
117
attrList->extend (
"xint"
,
"int"
);
118
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
(niov * 100));
119
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_tstestKey
) );
120
121
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
122
m_tstestKey
,
123
"TS_noTag"
,
124
static_cast<
uint64_t
>
(
count
) * 1000000000,
125
IOVTime::MAXTIMESTAMP
) );
126
}
127
128
return
StatusCode::SUCCESS;
129
}
130
131
135
StatusCode
CondWriterAlg::execute
(
const
EventContext& ctx)
136
{
137
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
138
unsigned
int
count
= eventInfo->eventNumber() - 1;
// events start with 1
139
140
auto
attrList = std::make_unique<AthenaAttributeList>();
141
attrList->extend (
"xint"
,
"int"
);
142
(*attrList)[
"xint"
].setValue(
static_cast<
int
>
((
count
+1)*10));
143
144
ATH_CHECK
(
detStore
()->overwrite (std::move (attrList),
m_attrListKey
) );
145
146
ATH_CHECK
(
m_regSvc
->registerIOV (
"AthenaAttributeList"
,
147
m_attrListKey
,
148
"AttrList_noTag"
,
149
0,
IOVTime::MAXRUN
,
150
count
,
IOVTime::MAXEVENT
) );
151
152
if
(
count
%2 == 0) {
153
ATH_CHECK
(
writeSCond
(
count
) );
154
}
155
156
ATH_CHECK
(
writeRLTest
(
count
) );
157
ATH_CHECK
(
writeTSTest
(
count
) );
158
159
return
StatusCode::SUCCESS;
160
}
161
162
163
}
// 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:77
DMTest::CondWriterAlg::CondWriterAlg
CondWriterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
CondWriterAlg.cxx:30
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:46
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:135
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:105
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:55
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