ATLAS Offline Software
xAODTestWriteHVec.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
14 #include "xAODTestWriteHVec.h"
15 #include "xAODTestWriteHelper.h"
20 
21 
22 namespace DMTest {
23 
24 
31  ISvcLocator *pSvcLocator)
32  : AthReentrantAlgorithm (name, pSvcLocator),
33  m_hvecKey ("hvec"),
34  m_hviewKey ("hview")
35 {
36  declareProperty ("HVecKey", m_hvecKey);
37  declareProperty ("HViewKey", m_hviewKey);
38 }
39 
40 
45 {
46  ATH_CHECK( m_hvecKey.initialize() );
47  ATH_CHECK( m_hviewKey.initialize() );
48  return StatusCode::SUCCESS;
49 }
50 
51 
55 StatusCode xAODTestWriteHVec::execute (const EventContext& ctx) const
56 {
57  unsigned int count = ctx.eventID().event_number() + 1;
58 
59  auto hvec = std::make_unique<DMTest::HVec>();
60  auto store = std::make_unique<DMTest::HAuxContainer>();
61  hvec->setStore (store.get());
62  auto hview = std::make_unique<DMTest::HView>();
63 
64  for (int i = 0; i < 20; i++) {
65  hvec->push_back (new DMTest::H);
66  hvec->back()->setAnInt (i+1 + count * 400);
67  }
68 
69  for (int i = 0; i < 20; i++) {
70  hview->push_back (hvec->at (19-i));
71  }
72 
73  ATH_CHECK( SG::makeHandle(m_hvecKey, ctx).record (std::move(hvec),
74  std::move(store)) );
75 
77  ATH_CHECK( DMTest::recordView2 (hviewH, std::move(hview)) );
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
87 {
88  return StatusCode::SUCCESS;
89 }
90 
91 
92 } // namespace DMTest
93 
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
H.h
Test for xAOD schema evolution.
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:65
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
HVec.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
DMTest::xAODTestWriteHVec::xAODTestWriteHVec
xAODTestWriteHVec(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestWriteHVec.cxx:30
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HView.h
DMTest::xAODTestWriteHVec::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition: xAODTestWriteHVec.cxx:86
DMTest::xAODTestWriteHVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestWriteHVec.cxx:55
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:44
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:64
DMTest::H_v2
Definition: H_v2.h:30