ATLAS Offline Software
xAODTestShallowCopy.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "xAODTestShallowCopy.h"
19 #include "xAODCore/ShallowCopy.h"
20 #include "StoreGate/ReadHandle.h"
21 #include "StoreGate/WriteHandle.h"
25 
26 
27 namespace DMTest {
28 
29 
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() ) );
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() ) );
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() ) );
61 
62  if (m_ctrigReadKey.empty()) {
63  m_ctrigWriteKey = "";
64  m_ctrigAnInt10Key = "";
65  }
66  ATH_CHECK( m_ctrigReadKey.initialize( !m_ctrigReadKey.empty() ) );
67  ATH_CHECK( m_ctrigWriteKey.initialize( !m_ctrigReadKey.empty() ) );
68  ATH_CHECK( m_ctrigAnInt10Key.initialize( !m_ctrigReadKey.empty() ) );
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 
78 StatusCode xAODTestShallowCopy::execute (const EventContext& ctx) const
79 {
80  int count = ctx.evt() + 1;
81 
82  if (!m_cvecReadKey.empty()) {
85 
87  ATH_CHECK( copy.record (std::unique_ptr<DMTest::CVec>(ret.first),
88  std::unique_ptr<xAOD::ShallowAuxContainer>(ret.second)) );
89 
90  ATH_CHECK( m_cvecDecorDeps.linkDecors (m_cvecReadKey, ctx) );
91 
93  for (C* c : *ret.first)
94  anInt10(*c) = count * 20000 + c->anInt() * 100;
95  }
96 
97  if (!m_cvecWDReadKey.empty()) {
100  ret.first->meta1 = vec->meta1;
101 
103  ATH_CHECK( copy.record (std::unique_ptr<DMTest::CVecWithData>(ret.first),
104  std::unique_ptr<xAOD::ShallowAuxContainer>(ret.second)) );
105 
106  ATH_CHECK( m_cvecWDDecorDeps.linkDecors (m_cvecWDReadKey, ctx) );
107 
109  for (C* c : *ret.first)
110  anInt10(*c) = count * 20000 + c->anInt() * 100;
111  }
112 
113  if (!m_cinfoReadKey.empty()) {
114  SG::ReadHandle<C> cinfo (m_cinfoReadKey, ctx);
115  auto ret = xAOD::shallowCopyObject (*cinfo);
116 
118  ATH_CHECK( copy.record (std::unique_ptr<DMTest::C>(ret.first),
119  std::unique_ptr<xAOD::ShallowAuxInfo>(ret.second)) );
120 
121  ATH_CHECK( m_cinfoDecorDeps.linkDecors (m_cinfoReadKey, ctx) );
122 
124  anInt10(*ret.first) = count * 20000 + ret.first->anInt() * 200;
125  }
126 
127  if (!m_ctrigReadKey.empty()) {
129  auto ret = xAOD::shallowCopyContainer (*ctrig);
130 
132  ATH_CHECK( copy.record (std::unique_ptr<DMTest::CVec>(ret.first),
133  std::unique_ptr<xAOD::ShallowAuxContainer>(ret.second)) );
134 
135  ATH_CHECK( m_ctrigDecorDeps.linkDecors (m_ctrigReadKey, ctx) );
136 
138  for (C* c : *ret.first)
139  anInt10(*c) = count * 20000 + c->anInt() * 300;
140  }
141 
142  return StatusCode::SUCCESS;
143 }
144 
145 
146 } // namespace DMTest
147 
ShallowCopy.h
DMTest::xAODTestShallowCopy::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestShallowCopy.cxx:78
xAODTestShallowCopy.h
Algorithm to test shallow-copy of xAOD data.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DMTest::xAODTestShallowCopy::m_cvecDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVec > m_cvecDecorDeps
Definition: xAODTestShallowCopy.h:60
DMTest::xAODTestShallowCopy::m_ctrigDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVec > m_ctrigDecorDeps
Definition: xAODTestShallowCopy.h:87
CAuxContainer.h
Class used for testing xAOD data reading/writing.
DMTest::C_v1
Definition: C_v1.h:29
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
DMTest::xAODTestShallowCopy::m_cvecReadKey
SG::ReadHandleKey< DMTest::CVec > m_cvecReadKey
Definition: xAODTestShallowCopy.h:54
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
WriteHandle.h
Handle class for recording to StoreGate.
DMTest::xAODTestShallowCopy::m_cvecWDAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVecWithData > m_cvecWDAnInt10Key
Definition: xAODTestShallowCopy.h:67
CVec.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestShallowCopy::m_cvecWriteKey
SG::WriteHandleKey< DMTest::CVec > m_cvecWriteKey
Definition: xAODTestShallowCopy.h:56
ret
T ret(T t)
Definition: rootspy.cxx:260
xAOD::shallowCopyObject
std::pair< T *, ShallowAuxInfo * > shallowCopyObject(const T &obj)
Function making a shallow copy of a constant standalone object.
Definition: ShallowCopy.h:163
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
C.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestShallowCopy::m_ctrigReadKey
SG::ReadHandleKey< DMTest::CVec > m_ctrigReadKey
Definition: xAODTestShallowCopy.h:81
DMTest::xAODTestShallowCopy::m_ctrigAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVec > m_ctrigAnInt10Key
Definition: xAODTestShallowCopy.h:85
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DMTest::xAODTestShallowCopy::m_cinfoDecorDeps
SG::ShallowCopyDecorDeps< DMTest::C > m_cinfoDecorDeps
Definition: xAODTestShallowCopy.h:78
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DMTest::xAODTestShallowCopy::m_cvecAnInt10Key
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecAnInt10Key
Definition: xAODTestShallowCopy.h:58
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CVecWithData.h
Test writing a container with metadata.
xAOD::shallowCopyContainer
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Definition: ShallowCopy.h:110
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DMTest::xAODTestShallowCopy::m_ctrigWriteKey
SG::WriteHandleKey< DMTest::CVec > m_ctrigWriteKey
Definition: xAODTestShallowCopy.h:83
DMTest::xAODTestShallowCopy::m_cinfoWriteKey
SG::WriteHandleKey< DMTest::C > m_cinfoWriteKey
Definition: xAODTestShallowCopy.h:74
DMTest::xAODTestShallowCopy::m_cinfoAnInt10Key
SG::WriteDecorHandleKey< DMTest::C > m_cinfoAnInt10Key
Definition: xAODTestShallowCopy.h:76
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
DMTest::xAODTestShallowCopy::m_cvecWDWriteKey
SG::WriteHandleKey< DMTest::CVecWithData > m_cvecWDWriteKey
Definition: xAODTestShallowCopy.h:65
CTrigAuxContainer.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestShallowCopy::m_cvecWDReadKey
SG::ReadHandleKey< DMTest::CVecWithData > m_cvecWDReadKey
Definition: xAODTestShallowCopy.h:63
calibdata.copy
bool copy
Definition: calibdata.py:27
DMTest::xAODTestShallowCopy::m_cvecWDDecorDeps
SG::ShallowCopyDecorDeps< DMTest::CVecWithData > m_cvecWDDecorDeps
Definition: xAODTestShallowCopy.h:69
ReadHandle.h
Handle class for reading from StoreGate.
python.compressB64.c
def c
Definition: compressB64.py:93
DMTest::xAODTestShallowCopy::m_cinfoReadKey
SG::ReadHandleKey< DMTest::C > m_cinfoReadKey
Definition: xAODTestShallowCopy.h:72
DMTest
Definition: B.h:23
DMTest::xAODTestShallowCopy::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestShallowCopy.cxx:33