ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestWriteHVec.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
10
11
12#include "xAODTestWriteHVec.h"
13#include "xAODTestWriteHelper.h"
18
19
20namespace 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
37StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
Test for xAOD schema evolution.
Test for xAOD schema evolution.
SG::WriteHandleKey< DMTest::HVec > m_hvecKey
SG::WriteHandleKey< DMTest::HView > m_hviewKey
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Definition B.h:23
StatusCode recordView2(SG::WriteHandle< ViewVector< DMTest::HVec > > &h, std::unique_ptr< ViewVector< DMTest::HVec > > view)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Algorithm to test writing xAOD classes for schema evolution (hvec/hview).
Test recording ViewVector w/o having CLASS_DEF visible in compilation unit.