ATLAS Offline Software
xAODTestDecor.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 // $Id$
14 #include "xAODTestDecor.h"
19 
20 
21 namespace DMTest {
22 
23 
29 xAODTestDecor::xAODTestDecor (const std::string &name,
30  ISvcLocator *pSvcLocator)
31  : AthReentrantAlgorithm (name, pSvcLocator)
32 {
33  declareProperty ("ReadPrefix", m_readPrefix);
34  declareProperty ("DecorName", m_decorName = "dInt1");
35  declareProperty ("Offset", m_offset = 0);
36 
37  declareProperty ("CVecDecorKey", m_cvecDecorKey);
38  declareProperty ("CInfoDecorKey", m_cinfoDecorKey);
39  declareProperty ("ObjDecorKey", m_objDecorKey);
40  declareProperty ("CTrigDecorKey", m_ctrigDecorKey);
41 
42  declareProperty ("DoCVec", m_doCVec = true);
43  declareProperty ("DoCInfo", m_doCInfo = true);
44  declareProperty ("DoCTrig", m_doCTrig = true);
45 }
46 
47 
52 {
55  m_objDecorKey = m_readPrefix + "cinfo." + m_decorName + "Base";
57 
59  ATH_CHECK( m_cvecDecorKey.initialize (m_doCVec) );
62  ATH_CHECK( m_ctrigDecorKey.initialize (m_doCTrig) );
63  return StatusCode::SUCCESS;
64 }
65 
66 
70 StatusCode xAODTestDecor::execute (const EventContext& ctx) const
71 {
73  unsigned int count = eventInfo->eventNumber() + 1;
74 
75  if (m_doCInfo) {
77  if (!cinfoDecor.isPresent()) {
78  ATH_MSG_ERROR( "cinfoDecor.isPresent check fails" );
79  return StatusCode::FAILURE;
80  }
81  cinfoDecor(0) = cinfoDecor->anInt() + (m_offset ? 400 + m_offset : count * 2000);
82 
84  objDecor(0) = cinfoDecor->anInt() + (m_offset ? 400 + m_offset : count * 2000) + 1;
85  }
86 
87  if (m_doCVec) {
89  if (!cvecDecor.isPresent()) {
90  ATH_MSG_ERROR( "cvecDecor.isPresent check fails" );
91  return StatusCode::FAILURE;
92  }
93  for (const C* celt : *cvecDecor) {
94  cvecDecor(*celt) = celt->anInt() + (m_offset ? m_offset : count*300);
95  }
96  }
97 
98  if (m_doCTrig) {
100  if (!ctrigDecor.isPresent()) {
101  ATH_MSG_ERROR( "ctrigDecor.isPresent check fails" );
102  return StatusCode::FAILURE;
103  }
104  for (const C* celt : *ctrigDecor) {
105  ctrigDecor(*celt) = celt->anInt() + (m_offset ? 600 + m_offset : -count*20);
106  }
107  }
108 
109  return StatusCode::SUCCESS;
110 }
111 
112 
117 {
118  return StatusCode::SUCCESS;
119 }
120 
121 
122 } // namespace DMTest
123 
DMTest::xAODTestDecor::xAODTestDecor
xAODTestDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestDecor.cxx:29
DMTest::xAODTestDecor::m_objDecorKey
SG::WriteDecorHandleKey< SG::AuxElement > m_objDecorKey
Definition: xAODTestDecor.h:83
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::xAODTestDecor::m_cvecDecorKey
SG::WriteDecorHandleKey< CVec > m_cvecDecorKey
Definition: xAODTestDecor.h:81
DMTest::C_v1
Definition: C_v1.h:29
DMTest::xAODTestDecor::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Handles for writing decorations.
Definition: xAODTestDecor.h:80
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
DMTest::xAODTestDecor::m_offset
int m_offset
Parameter: Offset to be applied to decoration.
Definition: xAODTestDecor.h:72
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
DMTest::xAODTestDecor::m_cinfoDecorKey
SG::WriteDecorHandleKey< C > m_cinfoDecorKey
Definition: xAODTestDecor.h:82
CVec.h
Class used for testing xAOD data reading/writing.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
C.h
Class used for testing xAOD data reading/writing.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
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
xAODTestDecor.h
Algorithm to test adding decorations to xAOD types.
DMTest::xAODTestDecor::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition: xAODTestDecor.cxx:116
DMTest::xAODTestDecor::m_doCVec
bool m_doCVec
Flags.
Definition: xAODTestDecor.h:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DMTest::xAODTestDecor::m_decorName
std::string m_decorName
Parameter: Name of the decoration.
Definition: xAODTestDecor.h:69
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DMTest::xAODTestDecor::m_ctrigDecorKey
SG::WriteDecorHandleKey< CVec > m_ctrigDecorKey
Definition: xAODTestDecor.h:84
DMTest::xAODTestDecor::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestDecor.cxx:70
DMTest::xAODTestDecor::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestDecor.cxx:51
SG::WriteDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
DMTest::xAODTestDecor::m_doCInfo
bool m_doCInfo
Definition: xAODTestDecor.h:76
DMTest::xAODTestDecor::m_readPrefix
std::string m_readPrefix
Parameter: Prefix for names read from SG.
Definition: xAODTestDecor.h:66
DMTest
Definition: B.h:23
DMTest::xAODTestDecor::m_doCTrig
bool m_doCTrig
Definition: xAODTestDecor.h:77