ATLAS Offline Software
Loading...
Searching...
No Matches
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"
20
21
22namespace DMTest {
23
24
30CondWriterAlg::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
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
55StatusCode 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
77StatusCode 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",
96 "RL_noTag",
97 0, 0,
98 lbn, IOVTime::MAXEVENT) );
99 }
100
101 return StatusCode::SUCCESS;
102}
103
104
105StatusCode 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",
123 "TS_noTag",
124 static_cast<uint64_t>(count) * 1000000000,
126 }
127
128 return StatusCode::SUCCESS;
129}
130
131
136{
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",
148 "AttrList_noTag",
151
152 if (count%2 == 0) {
154 }
155
158
159 return StatusCode::SUCCESS;
160}
161
162
163} // 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 with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode execute() override
Algorithm event processing.
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
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:146
Definition B.h:23