ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestShallowCopy.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 "
xAODTestShallowCopy.h
"
13
#include "
DataModelTestDataCommon/CVec.h
"
14
#include "
DataModelTestDataCommon/CVecWithData.h
"
15
#include "
DataModelTestDataCommon/C.h
"
16
#include "
DataModelTestDataCommon/CAuxContainer.h
"
17
#include "
DataModelTestDataCommon/CTrigAuxContainer.h
"
18
#include "
DataModelTestDataCommon/CInfoAuxContainer.h
"
19
#include "
xAODCore/ShallowCopy.h
"
20
#include "
StoreGate/ReadHandle.h
"
21
#include "
StoreGate/WriteHandle.h
"
22
#include "
StoreGate/WriteDecorHandle.h
"
23
#include "
AthContainers/AuxTypeRegistry.h
"
24
#include "
AthenaKernel/errorcheck.h
"
25
26
27
namespace
DMTest
{
28
29
33
StatusCode
xAODTestShallowCopy::initialize
()
34
{
35
if
(
m_cvecReadKey
.empty()) {
36
m_cvecWriteKey
=
""
;
37
m_cvecAnInt10Key
=
""
;
38
}
39
ATH_CHECK
(
m_cvecReadKey
.initialize( !
m_cvecReadKey
.empty() ) );
40
ATH_CHECK
(
m_cvecWriteKey
.initialize( !
m_cvecReadKey
.empty() ) );
41
ATH_CHECK
(
m_cvecAnInt10Key
.initialize( !
m_cvecReadKey
.empty() ) );
42
ATH_CHECK
(
m_cvecDecorDeps
.initialize(
m_cvecReadKey
,
m_cvecWriteKey
, !
m_cvecReadKey
.empty() ) );
43
44
if
(
m_cvecWDReadKey
.empty()) {
45
m_cvecWDWriteKey
=
""
;
46
m_cvecWDAnInt10Key
=
""
;
47
}
48
ATH_CHECK
(
m_cvecWDReadKey
.initialize( !
m_cvecWDReadKey
.empty() ) );
49
ATH_CHECK
(
m_cvecWDWriteKey
.initialize( !
m_cvecWDReadKey
.empty() ) );
50
ATH_CHECK
(
m_cvecWDAnInt10Key
.initialize( !
m_cvecWDReadKey
.empty() ) );
51
ATH_CHECK
(
m_cvecWDDecorDeps
.initialize(
m_cvecWDReadKey
,
m_cvecWDWriteKey
, !
m_cvecWDReadKey
.empty() ) );
52
53
if
(
m_cinfoReadKey
.empty()) {
54
m_cinfoWriteKey
=
""
;
55
m_cinfoAnInt10Key
=
""
;
56
}
57
ATH_CHECK
(
m_cinfoReadKey
.initialize( !
m_cinfoReadKey
.empty() ) );
58
ATH_CHECK
(
m_cinfoWriteKey
.initialize( !
m_cinfoReadKey
.empty() ) );
59
ATH_CHECK
(
m_cinfoAnInt10Key
.initialize( !
m_cinfoReadKey
.empty() ) );
60
ATH_CHECK
(
m_cinfoDecorDeps
.initialize(
m_cinfoReadKey
,
m_cinfoWriteKey
, !
m_cinfoReadKey
.empty() ) );
61
62
if
(
m_cinfoReadKeyBase
.empty()) {
63
m_cinfoWriteKeyBase
=
""
;
64
}
65
ATH_CHECK
(
m_cinfoReadKeyBase
.initialize( !
m_cinfoReadKeyBase
.empty() ) );
66
ATH_CHECK
(
m_cinfoWriteKeyBase
.initialize( !
m_cinfoReadKeyBase
.empty() ) );
67
ATH_CHECK
(
m_cinfoDecorDepsBase
.initialize(
m_cinfoReadKeyBase
,
m_cinfoWriteKeyBase
, !
m_cinfoReadKeyBase
.empty() ) );
68
69
if
(
m_ctrigReadKey
.empty()) {
70
m_ctrigWriteKey
=
""
;
71
m_ctrigAnInt10Key
=
""
;
72
}
73
ATH_CHECK
(
m_ctrigReadKey
.initialize( !
m_ctrigReadKey
.empty() ) );
74
ATH_CHECK
(
m_ctrigWriteKey
.initialize( !
m_ctrigReadKey
.empty() ) );
75
ATH_CHECK
(
m_ctrigAnInt10Key
.initialize( !
m_ctrigReadKey
.empty() ) );
76
ATH_CHECK
(
m_ctrigDecorDeps
.initialize(
m_ctrigReadKey
,
m_ctrigWriteKey
, !
m_ctrigReadKey
.empty() ) );
77
78
return
StatusCode::SUCCESS;
79
}
80
81
85
StatusCode
xAODTestShallowCopy::execute
(
const
EventContext& ctx)
const
86
{
87
int
count
= ctx.evt() + 1;
88
89
if
(!
m_cvecReadKey
.empty()) {
90
SG::ReadHandle<CVec>
vec
(
m_cvecReadKey
, ctx);
91
auto
ret =
xAOD::shallowCopy
(*
vec
, ctx);
92
93
SG::WriteHandle<DMTest::CVec>
copy (
m_cvecWriteKey
, ctx);
94
ATH_CHECK
( copy.record (std::move(ret.first), std::move(ret.second)) );
95
96
ATH_CHECK
(
m_cvecDecorDeps
.linkDecors (
m_cvecReadKey
, ctx) );
97
98
SG::WriteDecorHandle<DMTest::CVec, int>
anInt10 (
m_cvecAnInt10Key
, ctx);
99
for
(
C
* c : *copy)
100
anInt10(*c) =
count
* 20000 + c->anInt() * 100;
101
}
102
103
if
(!
m_cvecWDReadKey
.empty()) {
104
SG::ReadHandle<CVecWithData>
vec
(
m_cvecWDReadKey
, ctx);
105
auto
ret =
xAOD::shallowCopy
(*
vec
, ctx);
106
ret.first->meta1 =
vec
->meta1;
107
108
SG::WriteHandle<DMTest::CVecWithData>
copy (
m_cvecWDWriteKey
, ctx);
109
ATH_CHECK
( copy.record (std::move(ret.first), std::move(ret.second)) );
110
111
ATH_CHECK
(
m_cvecWDDecorDeps
.linkDecors (
m_cvecWDReadKey
, ctx) );
112
113
SG::WriteDecorHandle<DMTest::CVecWithData, int>
anInt10 (
m_cvecWDAnInt10Key
, ctx);
114
for
(
C
* c : *copy)
115
anInt10(*c) =
count
* 20000 + c->anInt() * 100;
116
}
117
118
if
(!
m_cinfoReadKey
.empty()) {
119
SG::ReadHandle<DMTest::C>
cinfo (
m_cinfoReadKey
, ctx);
120
auto
ret =
xAOD::shallowCopy
(*cinfo, ctx);
121
122
SG::WriteHandle<DMTest::C>
copy (
m_cinfoWriteKey
, ctx);
123
ATH_CHECK
( copy.record (std::move(ret.first), std::move(ret.second)) );
124
125
ATH_CHECK
(
m_cinfoDecorDeps
.linkDecors (
m_cinfoReadKey
, ctx) );
126
127
SG::WriteDecorHandle<DMTest::C, int>
anInt10 (
m_cinfoAnInt10Key
, ctx);
128
anInt10(*copy) =
count
* 20000 + copy->anInt() * 200;
129
}
130
131
if
(!
m_cinfoReadKeyBase
.empty()) {
132
ATH_CHECK
(
m_cinfoDecorDepsBase
.linkDecors (
m_cinfoReadKeyBase
, ctx) );
133
}
134
135
if
(!
m_ctrigReadKey
.empty()) {
136
SG::ReadHandle<CVec>
ctrig (
m_ctrigReadKey
, ctx);
137
auto
ret =
xAOD::shallowCopy
(*ctrig, ctx);
138
139
SG::WriteHandle<DMTest::CVec>
copy (
m_ctrigWriteKey
, ctx);
140
ATH_CHECK
( copy.record (std::move(ret.first), std::move(ret.second)) );
141
142
ATH_CHECK
(
m_ctrigDecorDeps
.linkDecors (
m_ctrigReadKey
, ctx) );
143
144
SG::WriteDecorHandle<DMTest::CVec, int>
anInt10 (
m_ctrigAnInt10Key
, ctx);
145
for
(
C
* c : *copy)
146
anInt10(*c) =
count
* 20000 + c->anInt() * 300;
147
}
148
149
return
StatusCode::SUCCESS;
150
}
151
152
153
}
// namespace DMTest
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
CAuxContainer.h
Class used for testing xAOD data reading/writing.
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
CTrigAuxContainer.h
Class used for testing xAOD data reading/writing.
CVecWithData.h
Test writing a container with metadata.
CVec.h
Class used for testing xAOD data reading/writing.
C.h
Class used for testing xAOD data reading/writing.
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
errorcheck.h
Helpers for checking error return status codes and reporting errors.
ShallowCopy.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
WriteHandle.h
Handle class for recording to StoreGate.
DMTest::xAODTestShallowCopy::m_cinfoDecorDeps
SG::ShallowCopyDecorDeps< DMTest::C > m_cinfoDecorDeps
Definition
xAODTestShallowCopy.h:78
DMTest::xAODTestShallowCopy::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestShallowCopy.cxx:85
DMTest::xAODTestShallowCopy::m_cinfoWriteKey
SG::WriteHandleKey< DMTest::C > m_cinfoWriteKey
Definition
xAODTestShallowCopy.h:74
DMTest::xAODTestShallowCopy::m_cvecWDReadKey
SG::ReadHandleKey< DMTest::CVecWithData > m_cvecWDReadKey
Definition
xAODTestShallowCopy.h:63
DMTest::xAODTestShallowCopy::m_cvecReadKey
SG::ReadHandleKey< DMTest::CVec > m_cvecReadKey
Definition
xAODTestShallowCopy.h:54
DMTest::xAODTestShallowCopy::m_ctrigWriteKey
SG::WriteHandleKey< DMTest::CVec > m_ctrigWriteKey
Definition
xAODTestShallowCopy.h:92
DMTest::xAODTestShallowCopy::m_cvecWriteKey
SG::WriteHandleKey< DMTest::CVec > m_cvecWriteKey
Definition
xAODTestShallowCopy.h:56
DMTest::xAODTestShallowCopy::m_cvecWDAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVecWithData > m_cvecWDAnInt10Key
Definition
xAODTestShallowCopy.h:67
DMTest::xAODTestShallowCopy::m_cinfoReadKey
SG::ReadHandleKey< DMTest::C > m_cinfoReadKey
Definition
xAODTestShallowCopy.h:72
DMTest::xAODTestShallowCopy::m_ctrigDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVec > m_ctrigDecorDeps
Definition
xAODTestShallowCopy.h:96
DMTest::xAODTestShallowCopy::m_cvecWDWriteKey
SG::WriteHandleKey< DMTest::CVecWithData > m_cvecWDWriteKey
Definition
xAODTestShallowCopy.h:65
DMTest::xAODTestShallowCopy::m_ctrigAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVec > m_ctrigAnInt10Key
Definition
xAODTestShallowCopy.h:94
DMTest::xAODTestShallowCopy::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestShallowCopy.cxx:33
DMTest::xAODTestShallowCopy::m_cinfoAnInt10Key
SG::WriteDecorHandleKey< DMTest::C > m_cinfoAnInt10Key
Definition
xAODTestShallowCopy.h:76
DMTest::xAODTestShallowCopy::m_cvecWDDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVecWithData > m_cvecWDDecorDeps
Definition
xAODTestShallowCopy.h:69
DMTest::xAODTestShallowCopy::m_cvecAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecAnInt10Key
Definition
xAODTestShallowCopy.h:58
DMTest::xAODTestShallowCopy::m_cinfoReadKeyBase
SG::ReadHandleKey< SG::AuxElement > m_cinfoReadKeyBase
Definition
xAODTestShallowCopy.h:83
DMTest::xAODTestShallowCopy::m_cvecDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVec > m_cvecDecorDeps
Definition
xAODTestShallowCopy.h:60
DMTest::xAODTestShallowCopy::m_cinfoDecorDepsBase
SG::ShallowCopyDecorDeps< SG::AuxElement > m_cinfoDecorDepsBase
Definition
xAODTestShallowCopy.h:87
DMTest::xAODTestShallowCopy::m_cinfoWriteKeyBase
SG::WriteHandleKey< SG::AuxElement > m_cinfoWriteKeyBase
Definition
xAODTestShallowCopy.h:85
DMTest::xAODTestShallowCopy::m_ctrigReadKey
SG::ReadHandleKey< DMTest::CVec > m_ctrigReadKey
Definition
xAODTestShallowCopy.h:90
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::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
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
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAODTestShallowCopy.h
Algorithm to test shallow-copy of xAOD data.
Generated on
for ATLAS Offline Software by
1.17.0