ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestDecor.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id$
12
13
14
#include "
xAODTestDecor.h
"
15
#include "
DataModelTestDataCommon/C.h
"
16
#include "
DataModelTestDataCommon/CVec.h
"
17
#include "
StoreGate/WriteDecorHandle.h
"
18
#include "
AthenaKernel/errorcheck.h
"
19
20
21
namespace
DMTest
{
22
23
29
xAODTestDecor::xAODTestDecor
(
const
std::string &name,
30
ISvcLocator *pSvcLocator)
31
:
AthReentrantAlgorithm
(name, pSvcLocator)
32
{
33
declareProperty
(
"ReadPrefix"
,
m_readPrefix
);
34
declareProperty
(
"DecorName"
,
m_decorName
=
"dInt1"
);
35
declareProperty
(
"Offset"
,
m_offset
= 0);
36
37
declareProperty
(
"CVecDecorKey"
,
m_cvecDecorKey
);
38
declareProperty
(
"CInfoDecorKey"
,
m_cinfoDecorKey
);
39
declareProperty
(
"ObjDecorKey"
,
m_objDecorKey
);
40
declareProperty
(
"CTrigDecorKey"
,
m_ctrigDecorKey
);
41
42
declareProperty
(
"DoCVec"
,
m_doCVec
=
true
);
43
declareProperty
(
"DoCInfo"
,
m_doCInfo
=
true
);
44
declareProperty
(
"DoCTrig"
,
m_doCTrig
=
true
);
45
}
46
47
51
StatusCode
xAODTestDecor::initialize
()
52
{
53
m_cvecDecorKey
=
m_readPrefix
+
"cvec."
+
m_decorName
;
54
m_cinfoDecorKey
=
m_readPrefix
+
"cinfo."
+
m_decorName
;
55
m_objDecorKey
=
m_readPrefix
+
"cinfo."
+
m_decorName
+
"Base"
;
56
m_ctrigDecorKey
=
m_readPrefix
+
"ctrig."
+
m_decorName
;
57
58
ATH_CHECK
(
m_eventInfoKey
.initialize() );
59
ATH_CHECK
(
m_cvecDecorKey
.initialize (
m_doCVec
) );
60
ATH_CHECK
(
m_cinfoDecorKey
.initialize (
m_doCInfo
) );
61
ATH_CHECK
(
m_objDecorKey
.initialize (
m_doCInfo
) );
62
ATH_CHECK
(
m_ctrigDecorKey
.initialize (
m_doCTrig
) );
63
return
StatusCode::SUCCESS;
64
}
65
66
70
StatusCode
xAODTestDecor::execute
(
const
EventContext& ctx)
const
71
{
72
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
73
unsigned
int
count
= eventInfo->eventNumber() + 1;
74
75
if
(
m_doCInfo
) {
76
SG::WriteDecorHandle<C, int>
cinfoDecor (
m_cinfoDecorKey
, ctx);
77
if
(!cinfoDecor.
isPresent
()) {
78
ATH_MSG_ERROR
(
"cinfoDecor.isPresent check fails"
);
79
return
StatusCode::FAILURE;
80
}
81
cinfoDecor(0) = cinfoDecor->anInt() + (
m_offset
? 400 +
m_offset
:
count
* 2000);
82
83
SG::WriteDecorHandle<SG::AuxElement, int>
objDecor (
m_objDecorKey
, ctx);
84
objDecor(0) = cinfoDecor->anInt() + (
m_offset
? 400 +
m_offset
:
count
* 2000) + 1;
85
}
86
87
if
(
m_doCVec
) {
88
SG::WriteDecorHandle<CVec, int>
cvecDecor (
m_cvecDecorKey
, ctx);
89
if
(!cvecDecor.
isPresent
()) {
90
ATH_MSG_ERROR
(
"cvecDecor.isPresent check fails"
);
91
return
StatusCode::FAILURE;
92
}
93
for
(
const
C
* celt : *cvecDecor) {
94
cvecDecor(*celt) = celt->anInt() + (
m_offset
?
m_offset
:
count
*300);
95
}
96
}
97
98
if
(
m_doCTrig
) {
99
SG::WriteDecorHandle<CVec, int>
ctrigDecor (
m_ctrigDecorKey
, ctx);
100
if
(!ctrigDecor.
isPresent
()) {
101
ATH_MSG_ERROR
(
"ctrigDecor.isPresent check fails"
);
102
return
StatusCode::FAILURE;
103
}
104
for
(
const
C
* celt : *ctrigDecor) {
105
ctrigDecor(*celt) = celt->anInt() + (
m_offset
? 600 +
m_offset
: -
count
*20);
106
}
107
}
108
109
return
StatusCode::SUCCESS;
110
}
111
112
116
StatusCode
xAODTestDecor::finalize
()
117
{
118
return
StatusCode::SUCCESS;
119
}
120
121
122
}
// namespace DMTest
123
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
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.
WriteDecorHandle.h
Handle class for adding a decoration to 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::xAODTestDecor::m_doCInfo
bool m_doCInfo
Definition
xAODTestDecor.h:76
DMTest::xAODTestDecor::m_doCTrig
bool m_doCTrig
Definition
xAODTestDecor.h:77
DMTest::xAODTestDecor::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition
xAODTestDecor.cxx:116
DMTest::xAODTestDecor::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestDecor.cxx:70
DMTest::xAODTestDecor::m_ctrigDecorKey
SG::WriteDecorHandleKey< CVec > m_ctrigDecorKey
Definition
xAODTestDecor.h:84
DMTest::xAODTestDecor::m_doCVec
bool m_doCVec
Flags.
Definition
xAODTestDecor.h:75
DMTest::xAODTestDecor::m_decorName
std::string m_decorName
Parameter: Name of the decoration.
Definition
xAODTestDecor.h:69
DMTest::xAODTestDecor::m_cinfoDecorKey
SG::WriteDecorHandleKey< C > m_cinfoDecorKey
Definition
xAODTestDecor.h:82
DMTest::xAODTestDecor::m_cvecDecorKey
SG::WriteDecorHandleKey< CVec > m_cvecDecorKey
Definition
xAODTestDecor.h:81
DMTest::xAODTestDecor::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestDecor.cxx:51
DMTest::xAODTestDecor::m_readPrefix
std::string m_readPrefix
Parameter: Prefix for names read from SG.
Definition
xAODTestDecor.h:66
DMTest::xAODTestDecor::xAODTestDecor
xAODTestDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
xAODTestDecor.cxx:29
DMTest::xAODTestDecor::m_offset
int m_offset
Parameter: Offset to be applied to decoration.
Definition
xAODTestDecor.h:72
DMTest::xAODTestDecor::m_objDecorKey
SG::WriteDecorHandleKey< SG::AuxElement > m_objDecorKey
Definition
xAODTestDecor.h:83
DMTest::xAODTestDecor::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Handles for writing decorations.
Definition
xAODTestDecor.h:80
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
SG::WriteDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
DMTest
Definition
B.h:23
DMTest::C
C_v1 C
Definition
C.h:26
xAODTestDecor.h
Algorithm to test adding decorations to xAOD types.
Generated on
for ATLAS Offline Software by
1.17.0