ATLAS Offline Software
Loading...
Searching...
No Matches
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"
25
26
27namespace DMTest {
28
29
34{
35 if (m_cvecReadKey.empty()) {
36 m_cvecWriteKey = "";
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() ) );
43
44 if (m_cvecWDReadKey.empty()) {
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() ) );
52
53 if (m_cinfoReadKey.empty()) {
54 m_cinfoWriteKey = "";
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() ) );
61
62 if (m_cinfoReadKeyBase.empty()) {
64 }
65 ATH_CHECK( m_cinfoReadKeyBase.initialize( !m_cinfoReadKeyBase.empty() ) );
66 ATH_CHECK( m_cinfoWriteKeyBase.initialize( !m_cinfoReadKeyBase.empty() ) );
68
69 if (m_ctrigReadKey.empty()) {
70 m_ctrigWriteKey = "";
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() ) );
77
78 return StatusCode::SUCCESS;
79}
80
81
85StatusCode xAODTestShallowCopy::execute (const EventContext& ctx) const
86{
87 int count = ctx.evt() + 1;
88
89 if (!m_cvecReadKey.empty()) {
91 auto ret = xAOD::shallowCopy (*vec, ctx);
92
94 ATH_CHECK( copy.record (std::move(ret.first), std::move(ret.second)) );
95
96 ATH_CHECK( m_cvecDecorDeps.linkDecors (m_cvecReadKey, ctx) );
97
99 for (C* c : *copy)
100 anInt10(*c) = count * 20000 + c->anInt() * 100;
101 }
102
103 if (!m_cvecWDReadKey.empty()) {
105 auto ret = xAOD::shallowCopy (*vec, ctx);
106 ret.first->meta1 = vec->meta1;
107
109 ATH_CHECK( copy.record (std::move(ret.first), std::move(ret.second)) );
110
111 ATH_CHECK( m_cvecWDDecorDeps.linkDecors (m_cvecWDReadKey, ctx) );
112
114 for (C* c : *copy)
115 anInt10(*c) = count * 20000 + c->anInt() * 100;
116 }
117
118 if (!m_cinfoReadKey.empty()) {
120 auto ret = xAOD::shallowCopy (*cinfo, ctx);
121
123 ATH_CHECK( copy.record (std::move(ret.first), std::move(ret.second)) );
124
125 ATH_CHECK( m_cinfoDecorDeps.linkDecors (m_cinfoReadKey, ctx) );
126
128 anInt10(*copy) = count * 20000 + copy->anInt() * 200;
129 }
130
131 if (!m_cinfoReadKeyBase.empty()) {
133 }
134
135 if (!m_ctrigReadKey.empty()) {
137 auto ret = xAOD::shallowCopy (*ctrig, ctx);
138
140 ATH_CHECK( copy.record (std::move(ret.first), std::move(ret.second)) );
141
142 ATH_CHECK( m_ctrigDecorDeps.linkDecors (m_ctrigReadKey, ctx) );
143
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
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle mappings between names and auxid_t.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Test writing a container with metadata.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
std::vector< size_t > vec
Helpers for checking error return status codes and reporting errors.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
SG::ShallowCopyDecorDeps< DMTest::C > m_cinfoDecorDeps
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
SG::WriteHandleKey< DMTest::C > m_cinfoWriteKey
SG::ReadHandleKey< DMTest::CVecWithData > m_cvecWDReadKey
SG::ReadHandleKey< DMTest::CVec > m_cvecReadKey
SG::WriteHandleKey< DMTest::CVec > m_ctrigWriteKey
SG::WriteHandleKey< DMTest::CVec > m_cvecWriteKey
SG::WriteDecorHandleKey< DMTest::CVecWithData > m_cvecWDAnInt10Key
SG::ReadHandleKey< DMTest::C > m_cinfoReadKey
SG::ShallowCopyDecorDeps< DMTest::CVec > m_ctrigDecorDeps
SG::WriteHandleKey< DMTest::CVecWithData > m_cvecWDWriteKey
SG::WriteDecorHandleKey< DMTest::CVec > m_ctrigAnInt10Key
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
SG::WriteDecorHandleKey< DMTest::C > m_cinfoAnInt10Key
SG::ShallowCopyDecorDeps< DMTest::CVecWithData > m_cvecWDDecorDeps
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecAnInt10Key
SG::ReadHandleKey< SG::AuxElement > m_cinfoReadKeyBase
SG::ShallowCopyDecorDeps< DMTest::CVec > m_cvecDecorDeps
SG::ShallowCopyDecorDeps< SG::AuxElement > m_cinfoDecorDepsBase
SG::WriteHandleKey< SG::AuxElement > m_cinfoWriteKeyBase
SG::ReadHandleKey< DMTest::CVec > m_ctrigReadKey
Handle class for adding a decoration to an object.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
Definition B.h:23
C_v1 C
Definition C.h:26
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
Algorithm to test shallow-copy of xAOD data.