ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestReadDecor.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
12#include "xAODTestReadDecor.h"
17#include <print>
18
19
20namespace DMTest {
21
22
28xAODTestReadDecor::xAODTestReadDecor (const std::string &name,
29 ISvcLocator *pSvcLocator)
30 : AthReentrantAlgorithm (name, pSvcLocator)
31{
32 declareProperty ("ReadPrefix", m_readPrefix);
33 declareProperty ("DecorName", m_decorName = "dInt1");
34 declareProperty ("CVecName", m_cvecName = "cvec");
35 declareProperty ("CInfoName", m_cinfoName = "cinfo");
36
37 declareProperty ("CVecDecorKey", m_cvecDecorKey);
38 declareProperty ("CInfoDecorKey", m_cinfoDecorKey);
39 declareProperty ("CInfoBaseDecorKey", m_cinfoBaseDecorKey);
40 declareProperty ("ObjDecorKey", m_objDecorKey);
41}
42
43
48{
49 if (!m_cvecName.empty()) {
51 ATH_CHECK( m_cvecDecorKey.initialize() );
52 }
53
54 if (!m_cinfoName.empty()) {
58 ATH_CHECK( m_cinfoDecorKey.initialize() );
59 ATH_CHECK( m_cinfoBaseDecorKey.initialize() );
60 ATH_CHECK( m_objDecorKey.initialize() );
61 }
62 return StatusCode::SUCCESS;
63}
64
65
69StatusCode xAODTestReadDecor::execute (const EventContext& ctx) const
70{
71 if (!m_cvecDecorKey.empty()) {
72 std::ostringstream ss;
74 if (!cvecDecor.isPresent()) return StatusCode::FAILURE;
75 for (const C* celt : *cvecDecor) {
76 std::print (ss, " {}", cvecDecor(*celt));
77 }
78 ATH_MSG_INFO ("{}:{}", m_cvecDecorKey.key(), ss.str());
79 }
80
81 if (!m_cinfoDecorKey.empty()) {
83 if (!cinfoDecor.isPresent()) return StatusCode::FAILURE;
84 ATH_MSG_INFO ("{}: {}", m_cinfoDecorKey.key(), cinfoDecor(0));
85 }
86
87 if (!m_cinfoBaseDecorKey.empty()) {
89 if (!cinfoBaseDecor.isPresent()) return StatusCode::FAILURE;
90 ATH_MSG_INFO ("{}: {}", m_cinfoBaseDecorKey.key(), cinfoBaseDecor(0));
91 }
92
93 if (!m_objDecorKey.empty()) {
95 if (!objDecor.isPresent()) return StatusCode::FAILURE;
96 ATH_MSG_INFO ("{}: {}", m_objDecorKey.key(), objDecor(0));
97 }
98
99 if (!m_cinfoDecorKey.empty()) {
101 testKey = testKey.key() + "_test";
102 SG::ReadDecorHandle<C, int> cinfoDecorTest (testKey, ctx);
103 if (!cinfoDecorTest.isPresent()) return StatusCode::FAILURE;
104 }
105
106 return StatusCode::SUCCESS;
107}
108
109
114{
115 return StatusCode::SUCCESS;
116}
117
118
119} // namespace DMTest
120
#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.