ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
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
"
13
#include "
DataModelTestDataCommon/C.h
"
14
#include "
DataModelTestDataCommon/CVec.h
"
15
#include "
StoreGate/ReadDecorHandle.h
"
16
#include "
AthenaKernel/errorcheck.h
"
17
#include <print>
18
19
20
namespace
DMTest
{
21
22
28
xAODTestReadDecor::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
47
StatusCode
xAODTestReadDecor::initialize
()
48
{
49
if
(!
m_cvecName
.empty()) {
50
m_cvecDecorKey
=
m_readPrefix
+
m_cvecName
+
"."
+
m_decorName
;
51
ATH_CHECK
(
m_cvecDecorKey
.initialize() );
52
}
53
54
if
(!
m_cinfoName
.empty()) {
55
m_cinfoDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
;
56
m_cinfoBaseDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
+
"Base"
;
57
m_objDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
;
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
69
StatusCode
xAODTestReadDecor::execute
(
const
EventContext& ctx)
const
70
{
71
if
(!
m_cvecDecorKey
.empty()) {
72
std::ostringstream
ss
;
73
SG::ReadDecorHandle<CVec, int>
cvecDecor (
m_cvecDecorKey
, ctx);
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()) {
82
SG::ReadDecorHandle<C, int>
cinfoDecor (
m_cinfoDecorKey
, ctx);
83
if
(!cinfoDecor.
isPresent
())
return
StatusCode::FAILURE;
84
ATH_MSG_INFO
(
"{}: {}"
,
m_cinfoDecorKey
.key(), cinfoDecor(0));
85
}
86
87
if
(!
m_cinfoBaseDecorKey
.empty()) {
88
SG::ReadDecorHandle<C, int>
cinfoBaseDecor (
m_cinfoBaseDecorKey
, ctx);
89
if
(!cinfoBaseDecor.
isPresent
())
return
StatusCode::FAILURE;
90
ATH_MSG_INFO
(
"{}: {}"
,
m_cinfoBaseDecorKey
.key(), cinfoBaseDecor(0));
91
}
92
93
if
(!
m_objDecorKey
.empty()) {
94
SG::ReadDecorHandle<SG::AuxElement, int>
objDecor (
m_objDecorKey
, ctx);
95
if
(!objDecor.
isPresent
())
return
StatusCode::FAILURE;
96
ATH_MSG_INFO
(
"{}: {}"
,
m_objDecorKey
.key(), objDecor(0));
97
}
98
99
if
(!
m_cinfoDecorKey
.empty()) {
100
SG::ReadDecorHandleKey<C>
testKey (
m_cinfoDecorKey
);
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
113
StatusCode
xAODTestReadDecor::finalize
()
114
{
115
return
StatusCode::SUCCESS;
116
}
117
118
119
}
// namespace DMTest
120
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CVec.h
Class used for testing xAOD data reading/writing.
C.h
Class used for testing xAOD data reading/writing.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
ReadDecorHandle.h
Handle class for reading a decoration on an object.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DMTest::xAODTestReadDecor::m_cinfoName
std::string m_cinfoName
Definition
xAODTestReadDecor.h:69
DMTest::xAODTestReadDecor::xAODTestReadDecor
xAODTestReadDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
xAODTestReadDecor.cxx:28
DMTest::xAODTestReadDecor::m_readPrefix
std::string m_readPrefix
Parameter: Prefix for names read from SG.
Definition
xAODTestReadDecor.h:62
DMTest::xAODTestReadDecor::m_cinfoDecorKey
SG::ReadDecorHandleKey< C > m_cinfoDecorKey
Definition
xAODTestReadDecor.h:73
DMTest::xAODTestReadDecor::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestReadDecor.cxx:69
DMTest::xAODTestReadDecor::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition
xAODTestReadDecor.cxx:113
DMTest::xAODTestReadDecor::m_decorName
std::string m_decorName
Parameter: Name of the decoration.
Definition
xAODTestReadDecor.h:65
DMTest::xAODTestReadDecor::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestReadDecor.cxx:47
DMTest::xAODTestReadDecor::m_objDecorKey
SG::ReadDecorHandleKey< SG::AuxElement > m_objDecorKey
Definition
xAODTestReadDecor.h:75
DMTest::xAODTestReadDecor::m_cvecDecorKey
SG::ReadDecorHandleKey< CVec > m_cvecDecorKey
Handles for reading decorations.
Definition
xAODTestReadDecor.h:72
DMTest::xAODTestReadDecor::m_cvecName
std::string m_cvecName
Parameter: Root names of the objects.
Definition
xAODTestReadDecor.h:68
DMTest::xAODTestReadDecor::m_cinfoBaseDecorKey
SG::ReadDecorHandleKey< C > m_cinfoBaseDecorKey
Definition
xAODTestReadDecor.h:74
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition
StoreGate/StoreGate/ReadDecorHandleKey.h:86
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DMTest
Definition
B.h:23
DMTest::C
C_v1 C
Definition
C.h:26
xAODTestReadDecor.h
Algorithm to test reading decorations using handles.
Generated on
for ATLAS Offline Software by
1.17.0