ATLAS Offline Software
xAODTestWriteHVec.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "xAODTestWriteHVec.h"
13 #include "xAODTestWriteHelper.h"
18 
19 
20 namespace DMTest {
21 
22 
27 {
28  ATH_CHECK( m_hvecKey.initialize() );
29  ATH_CHECK( m_hviewKey.initialize( SG::AllowEmpty ) );
30  return StatusCode::SUCCESS;
31 }
32 
33 
37 StatusCode xAODTestWriteHVec::execute (const EventContext& ctx) const
38 {
39  unsigned int count = ctx.eventID().event_number() + 1;
40 
41  auto hvec = std::make_unique<DMTest::HVec>();
42  auto store = std::make_unique<DMTest::HAuxContainer>();
43  hvec->setStore (store.get());
44 
45  for (int i = 0; i < 20; i++) {
46  hvec->push_back (new DMTest::H);
47  hvec->back()->setAnInt (i+1 + count * 400);
48  }
49 
50  std::unique_ptr<DMTest::HView> hview;
51  if (!m_hviewKey.empty()) {
52  hview = std::make_unique<DMTest::HView>();
53  for (int i = 0; i < 20; i++) {
54  hview->push_back (hvec->at (19-i));
55  }
56  }
57 
58  ATH_CHECK( SG::makeHandle(m_hvecKey, ctx).record (std::move(hvec),
59  std::move(store)) );
60 
61  if (!m_hviewKey.empty()) {
63  ATH_CHECK( DMTest::recordView2 (hviewH, std::move(hview)) );
64  }
65 
66  return StatusCode::SUCCESS;
67 }
68 
69 
70 } // namespace DMTest
71 
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
H.h
Test for xAOD schema evolution.
xAODTestWriteHVec.h
Algorithm to test writing xAOD classes for schema evolution (hvec/hview).
DMTest::xAODTestWriteHVec::m_hviewKey
SG::WriteHandleKey< DMTest::HView > m_hviewKey
Definition: xAODTestWriteHVec.h:54
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
HVec.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HView.h
DMTest::xAODTestWriteHVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestWriteHVec.cxx:37
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DMTest::recordView2
StatusCode recordView2(SG::WriteHandle< ViewVector< DMTest::HVec > > &h, std::unique_ptr< ViewVector< DMTest::HVec > > view)
Definition: xAODTestWriteHelper.cxx:28
xAODTestWriteHelper.h
Test recording ViewVector w/o having CLASS_DEF visible in compilation unit.
DMTest::xAODTestWriteHVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestWriteHVec.cxx:26
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
HAuxContainer.h
Test for xAOD schema evolution.
DMTest
Definition: B.h:23
DMTest::xAODTestWriteHVec::m_hvecKey
SG::WriteHandleKey< DMTest::HVec > m_hvecKey
Definition: xAODTestWriteHVec.h:52
DMTest::H_v2
Definition: H_v2.h:30