ATLAS Offline Software
Loading...
Searching...
No Matches
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"
17
18
19namespace DMTest {
20
21
27CondWriterAlg::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
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
52StatusCode 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
74StatusCode 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",
93 "RL_noTag",
94 0, 0,
95 lbn, IOVTime::MAXEVENT) );
96 }
97
98 return StatusCode::SUCCESS;
99}
100
101
102StatusCode 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",
120 "TS_noTag",
121 static_cast<uint64_t>(count) * 1000000000,
123 }
124
125 return StatusCode::SUCCESS;
126}
127
128
132StatusCode CondWriterAlg::execute(const EventContext& ctx)
133{
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",
145 "AttrList_noTag",
148
149 if (count%2 == 0) {
151 }
152
155
156 return StatusCode::SUCCESS;
157}
158
159
160} // namespace DMTest
#define ATH_CHECK
Evaluate an expression and check for errors.
Interface to an output stream tool.
Basic time unit for IOVSvc.
Conditions declarations for S2.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode writeRLTest(unsigned int count)
CondWriterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
ToolHandle< IAthenaOutputStreamTool > m_streamer
virtual StatusCode execute(const EventContext &ctx) override
Algorithm event processing.
std::string m_attrListKey
StatusCode writeTSTest(unsigned int count)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
StatusCode writeSCond(unsigned int count)
ServiceHandle< IIOVRegistrationSvc > m_regSvc
std::vector< TypeKeyPair > TypeKeyPairs
static constexpr uint64_t MAXTIMESTAMP
Definition IOVTime.h:58
static constexpr uint32_t MAXRUN
Definition IOVTime.h:48
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
Definition B.h:23