ATLAS Offline Software
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$
15 #include "CondWriterAlg.h"
18 #include "AthenaKernel/IOVTime.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 
47 {
48  ATH_CHECK( m_regSvc.retrieve() );
49  ATH_CHECK( m_streamer.retrieve() );
51  return StatusCode::SUCCESS;
52 }
53 
54 
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 
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,
99  }
100 
101  return StatusCode::SUCCESS;
102 }
103 
104 
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,
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",
149  0, IOVTime::MAXRUN,
151 
152  if (count%2 == 0) {
154  }
155 
158 
159  return StatusCode::SUCCESS;
160 }
161 
162 
163 } // namespace DMTest
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:99
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
DMTest::CondWriterAlg::m_rltestKey
std::string m_rltestKey
Definition: CondWriterAlg.h:66
DMTest::CondWriterAlg::writeTSTest
StatusCode writeTSTest(unsigned int count)
Definition: CondWriterAlg.cxx:105
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CondWriterAlg.h
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
DMTest::CondWriterAlg::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition: CondWriterAlg.h:61
AthenaAttributeList.h
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
IOVTime.h
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
IAthenaOutputStreamTool.h
Interface to an output stream tool.
DMTest::CondWriterAlg::m_attrListKey
std::string m_attrListKey
Definition: CondWriterAlg.h:64
DMTest::CondWriterAlg::CondWriterAlg
CondWriterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CondWriterAlg.cxx:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
S2Cond.h
Conditions declarations for S2.
IOVTime::MAXTIMESTAMP
static constexpr uint64_t MAXTIMESTAMP
Definition: IOVTime.h:58
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DMTest::CondWriterAlg::writeSCond
StatusCode writeSCond(unsigned int count)
Definition: CondWriterAlg.cxx:55
AthAlgorithm
Definition: AthAlgorithm.h:47
DMTest::CondWriterAlg::m_s2Key
std::string m_s2Key
Definition: CondWriterAlg.h:65
DMTest::CondWriterAlg::execute
virtual StatusCode execute() override
Algorithm event processing.
Definition: CondWriterAlg.cxx:135
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DMTest::CondWriterAlg::writeRLTest
StatusCode writeRLTest(unsigned int count)
Definition: CondWriterAlg.cxx:77
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DMTest::CondWriterAlg::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: CondWriterAlg.cxx:46
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
DMTest::CondWriterAlg::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
Definition: CondWriterAlg.h:62
DMTest::CondWriterAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: CondWriterAlg.h:63
DMTest::CondWriterAlg::m_tstestKey
std::string m_tstestKey
Definition: CondWriterAlg.h:67
DMTest
Definition: B.h:23
LB_AnalMapSplitter.lbn
lbn
Definition: LB_AnalMapSplitter.py:28