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-2020 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
18
19
namespace
DMTest
{
20
21
27
xAODTestReadDecor::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
46
StatusCode
xAODTestReadDecor::initialize
()
47
{
48
if
(!
m_cvecName
.empty()) {
49
m_cvecDecorKey
=
m_readPrefix
+
m_cvecName
+
"."
+
m_decorName
;
50
ATH_CHECK
(
m_cvecDecorKey
.initialize() );
51
}
52
53
if
(!
m_cinfoName
.empty()) {
54
m_cinfoDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
;
55
m_cinfoBaseDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
+
"Base"
;
56
m_objDecorKey
=
m_readPrefix
+
m_cinfoName
+
"."
+
m_decorName
;
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
68
StatusCode
xAODTestReadDecor::execute
(
const
EventContext& ctx)
const
69
{
70
if
(!
m_cvecDecorKey
.empty()) {
71
std::ostringstream
ss
;
72
SG::ReadDecorHandle<CVec, int>
cvecDecor (
m_cvecDecorKey
, ctx);
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()) {
81
SG::ReadDecorHandle<C, int>
cinfoDecor (
m_cinfoDecorKey
, ctx);
82
if
(!cinfoDecor.
isPresent
())
return
StatusCode::FAILURE;
83
ATH_MSG_INFO
(
m_cinfoDecorKey
.key() <<
": "
<< cinfoDecor(0));
84
}
85
86
if
(!
m_cinfoBaseDecorKey
.empty()) {
87
SG::ReadDecorHandle<C, int>
cinfoBaseDecor (
m_cinfoBaseDecorKey
, ctx);
88
if
(!cinfoBaseDecor.
isPresent
())
return
StatusCode::FAILURE;
89
ATH_MSG_INFO
(
m_cinfoBaseDecorKey
.key() <<
": "
<< cinfoBaseDecor(0));
90
}
91
92
if
(!
m_objDecorKey
.empty()) {
93
SG::ReadDecorHandle<SG::AuxElement, int>
objDecor (
m_objDecorKey
, ctx);
94
if
(!objDecor.
isPresent
())
return
StatusCode::FAILURE;
95
ATH_MSG_INFO
(
m_objDecorKey
.key() <<
": "
<< objDecor(0));
96
}
97
98
if
(!
m_cinfoDecorKey
.empty()) {
99
SG::ReadDecorHandleKey<C>
testKey (
m_cinfoDecorKey
);
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
112
StatusCode
xAODTestReadDecor::finalize
()
113
{
114
return
StatusCode::SUCCESS;
115
}
116
117
118
}
// namespace DMTest
119
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:31
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:27
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:68
DMTest::xAODTestReadDecor::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition
xAODTestReadDecor.cxx:112
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:46
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