ATLAS Offline Software
xAODTestReadDecor.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "xAODTestReadDecor.h"
17 
18 
19 namespace DMTest {
20 
21 
28  ISvcLocator *pSvcLocator)
29  : AthReentrantAlgorithm (name, pSvcLocator)
30 {
31  declareProperty ("ReadPrefix", m_readPrefix);
32  declareProperty ("DecorName", m_decorName = "dInt1");
33  declareProperty ("CVecName", m_cvecName = "cvec");
34  declareProperty ("CInfoName", m_cinfoName = "cinfo");
35 
36  declareProperty ("CVecDecorKey", m_cvecDecorKey);
37  declareProperty ("CInfoDecorKey", m_cinfoDecorKey);
38  declareProperty ("CInfoBaseDecorKey", m_cinfoBaseDecorKey);
39  declareProperty ("ObjDecorKey", m_objDecorKey);
40 }
41 
42 
47 {
48  if (!m_cvecName.empty()) {
50  ATH_CHECK( m_cvecDecorKey.initialize() );
51  }
52 
53  if (!m_cinfoName.empty()) {
60  }
61  return StatusCode::SUCCESS;
62 }
63 
64 
68 StatusCode xAODTestReadDecor::execute (const EventContext& ctx) const
69 {
70  if (!m_cvecDecorKey.empty()) {
71  std::ostringstream ss;
73  if (!cvecDecor.isPresent()) return StatusCode::FAILURE;
74  for (const C* celt : *cvecDecor) {
75  ss << " " << cvecDecor(*celt);
76  }
77  ATH_MSG_INFO (m_cvecDecorKey.key() << ":" << ss.str());
78  }
79 
80  if (!m_cinfoDecorKey.empty()) {
82  if (!cinfoDecor.isPresent()) return StatusCode::FAILURE;
83  ATH_MSG_INFO (m_cinfoDecorKey.key() << ": " << cinfoDecor(0));
84  }
85 
86  if (!m_cinfoBaseDecorKey.empty()) {
88  if (!cinfoBaseDecor.isPresent()) return StatusCode::FAILURE;
89  ATH_MSG_INFO (m_cinfoBaseDecorKey.key() << ": " << cinfoBaseDecor(0));
90  }
91 
92  if (!m_objDecorKey.empty()) {
94  if (!objDecor.isPresent()) return StatusCode::FAILURE;
95  ATH_MSG_INFO (m_objDecorKey.key() << ": " << objDecor(0));
96  }
97 
98  if (!m_cinfoDecorKey.empty()) {
100  testKey = testKey.key() + "_test";
101  SG::ReadDecorHandle<C, int> cinfoDecorTest (testKey, ctx);
102  if (!cinfoDecorTest.isPresent()) return StatusCode::FAILURE;
103  }
104 
105  return StatusCode::SUCCESS;
106 }
107 
108 
113 {
114  return StatusCode::SUCCESS;
115 }
116 
117 
118 } // namespace DMTest
119 
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DMTest::xAODTestReadDecor::m_cinfoDecorKey
SG::ReadDecorHandleKey< C > m_cinfoDecorKey
Definition: xAODTestReadDecor.h:73
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DMTest::xAODTestReadDecor::xAODTestReadDecor
xAODTestReadDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestReadDecor.cxx:27
DMTest::xAODTestReadDecor::m_objDecorKey
SG::ReadDecorHandleKey< SG::AuxElement > m_objDecorKey
Definition: xAODTestReadDecor.h:75
DMTest::xAODTestReadDecor::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestReadDecor.cxx:46
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
DMTest::C_v1
Definition: C_v1.h:27
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CVec.h
Class used for testing xAOD data reading/writing.
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
DMTest::xAODTestReadDecor::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition: xAODTestReadDecor.cxx:112
SG::ReadDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
C.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestReadDecor::m_cvecDecorKey
SG::ReadDecorHandleKey< CVec > m_cvecDecorKey
Handles for reading decorations.
Definition: xAODTestReadDecor.h:72
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DMTest::xAODTestReadDecor::m_decorName
std::string m_decorName
Parameter: Name of the decoration.
Definition: xAODTestReadDecor.h:65
DMTest::xAODTestReadDecor::m_cvecName
std::string m_cvecName
Parameter: Root names of the objects.
Definition: xAODTestReadDecor.h:68
DMTest::xAODTestReadDecor::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestReadDecor.cxx:68
DMTest::xAODTestReadDecor::m_readPrefix
std::string m_readPrefix
Parameter: Prefix for names read from SG.
Definition: xAODTestReadDecor.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DMTest::xAODTestReadDecor::m_cinfoName
std::string m_cinfoName
Definition: xAODTestReadDecor.h:69
DMTest::xAODTestReadDecor::m_cinfoBaseDecorKey
SG::ReadDecorHandleKey< C > m_cinfoBaseDecorKey
Definition: xAODTestReadDecor.h:74
ReadDecorHandle.h
Handle class for reading a decoration on an object.
SG::ReadDecorHandleKey< C >
xAODTestReadDecor.h
Algorithm to test reading decorations using handles.
DMTest
Definition: B.h:23