ATLAS Offline Software
CondReaderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "CondReaderAlg.h"
13 #include "StoreGate/ReadHandle.h"
15 #include "GaudiKernel/Chrono.h"
16 
17 
18 namespace DMTest {
19 
20 
26 CondReaderAlg::CondReaderAlg (const std::string& name, ISvcLocator *pSvcLocator)
27  : AthReentrantAlgorithm (name, pSvcLocator),
28  m_chronoSvc ("ChronoStatSvc", name),
29  m_attrListKey ("/DMTest/TestAttrList"),
30  m_scondKey ("scond", "DMTest"),
31  m_s2Key ("/DMTest/S2"),
32  m_s3Key(""),
33  m_rltestKey (""),
34  m_tstestKey ("")
35 {
36  declareProperty ("ChronoSvc", m_chronoSvc);
37  declareProperty ("AttrListKey", m_attrListKey);
38  declareProperty ("SCondKey", m_scondKey);
39  declareProperty ("S2Key", m_s2Key);
40  declareProperty ("S3Key", m_s3Key);
41  declareProperty ("RLTestKey", m_rltestKey);
42  declareProperty ("TSTestKey", m_tstestKey);
43  declareProperty ("Spins", m_spins = 0);
44 }
45 
46 
51 {
52  ATH_CHECK( m_chronoSvc.retrieve() );
56 
57  // Allow running without POOL payload
58  if ( !m_s2Key.key().empty()) ATH_CHECK( m_s2Key.initialize() );
59 
60  if ( !m_s3Key.key().empty()) ATH_CHECK( m_s3Key.initialize() );
61  if ( !m_rltestKey.key().empty()) ATH_CHECK( m_rltestKey.initialize() );
62  if ( !m_tstestKey.key().empty()) ATH_CHECK( m_tstestKey.initialize() );
63 
64  return StatusCode::SUCCESS;
65 }
66 
67 
71 StatusCode CondReaderAlg::execute (const EventContext& ctx) const
72 {
74 
75  ATH_MSG_INFO ("Event " << eventInfo->eventNumber() <<
76  " LBN " << eventInfo->lumiBlock());
77 
79  ATH_MSG_INFO (" xint " << (**attrList)["xint"]);
80 
82  ATH_MSG_INFO (" scond " << s1->m_x );
83 
84  if (!m_s2Key.key().empty()) {
86  ATH_MSG_INFO (" s2 " << s2->m_x );
87  }
88 
89  if (!m_rltestKey.key().empty()) {
91  ATH_MSG_INFO (" rl " << (**rl)["xint"]);
92  }
93 
94  if (!m_tstestKey.key().empty()) {
96  ATH_MSG_INFO (" ts " << (**ts)["xint"]);
97  }
98 
99  if (!m_s3Key.key().empty()) {
101  ATH_MSG_INFO (" s3 " << s3->m_x );
102  }
103 
104  {
105  std::string xint = "xint";
106  Chrono chrono (&*m_chronoSvc, "spin time");
107  int xx [[maybe_unused]] = 0;
108  for (size_t i = 0; i < m_spins; i++) {
109  {
111  // cppcheck-suppress internalAstError; work around cppcheck 2.0 parse failure
112  xx += (**attrList)[xint].template data<int>();
113  }
114  {
116  xx += s1->m_x;
117  }
118  {
120  xx += s2->m_x;
121  }
122  }
123  }
124 
125  return StatusCode::SUCCESS;
126 }
127 
128 
129 } // namespace DMTest
DMTest::CondReaderAlg::m_scondKey
SG::ReadCondHandleKey< DMTest::S1 > m_scondKey
Definition: CondReaderAlg.h:62
DMTest::CondReaderAlg::m_rltestKey
SG::ReadCondHandleKey< AthenaAttributeList > m_rltestKey
Definition: CondReaderAlg.h:65
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DMTest::CondReaderAlg::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: CondReaderAlg.cxx:50
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CondReaderAlg.h
Testing conditions handling.
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::CondReaderAlg::m_spins
size_t m_spins
Definition: CondReaderAlg.h:67
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DMTest::CondReaderAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: CondReaderAlg.cxx:71
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
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
DMTest::CondReaderAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: CondReaderAlg.h:60
ReadCellNoiseFromCoolCompare.s3
s3
Definition: ReadCellNoiseFromCoolCompare.py:380
DMTest::CondReaderAlg::m_s2Key
SG::ReadCondHandleKey< DMTest::S1 > m_s2Key
Definition: CondReaderAlg.h:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PlotCalibFromCool.rl
rl
Definition: PlotCalibFromCool.py:529
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
DMTest::CondReaderAlg::CondReaderAlg
CondReaderAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CondReaderAlg.cxx:26
DMTest::CondReaderAlg::m_s3Key
SG::ReadCondHandleKey< DMTest::S3 > m_s3Key
Definition: CondReaderAlg.h:64
ReadHandle.h
Handle class for reading from StoreGate.
DMTest::CondReaderAlg::m_chronoSvc
ServiceHandle< IChronoStatSvc > m_chronoSvc
Definition: CondReaderAlg.h:59
python.CaloScaleNoiseConfig.ts
ts
Definition: CaloScaleNoiseConfig.py:86
DMTest::CondReaderAlg::m_tstestKey
SG::ReadCondHandleKey< AthenaAttributeList > m_tstestKey
Definition: CondReaderAlg.h:66
DMTest
Definition: B.h:23
DMTest::CondReaderAlg::m_attrListKey
SG::ReadCondHandleKey< AthenaAttributeList > m_attrListKey
Definition: CondReaderAlg.h:61