ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestReadDecor.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
12#include "xAODTestReadDecor.h"
17
18
19namespace DMTest {
20
21
27xAODTestReadDecor::xAODTestReadDecor (const std::string &name,
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()) {
57 ATH_CHECK( m_cinfoDecorKey.initialize() );
58 ATH_CHECK( m_cinfoBaseDecorKey.initialize() );
59 ATH_CHECK( m_objDecorKey.initialize() );
60 }
61 return StatusCode::SUCCESS;
62}
63
64
68StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Helpers for checking error return status codes and reporting errors.
static Double_t ss
Handle class for reading a decoration on an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
xAODTestReadDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
std::string m_readPrefix
Parameter: Prefix for names read from SG.
SG::ReadDecorHandleKey< C > m_cinfoDecorKey
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
std::string m_decorName
Parameter: Name of the decoration.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
SG::ReadDecorHandleKey< SG::AuxElement > m_objDecorKey
SG::ReadDecorHandleKey< CVec > m_cvecDecorKey
Handles for reading decorations.
std::string m_cvecName
Parameter: Root names of the objects.
SG::ReadDecorHandleKey< C > m_cinfoBaseDecorKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
bool isPresent() const
Is the referenced container present in SG?
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition B.h:23
C_v1 C
Definition C.h:26
Algorithm to test reading decorations using handles.