ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataRead
src
xAODTestReadHVec.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 "
xAODTestReadHVec.h
"
13
#include "
DataModelTestDataRead/HVec.h
"
14
#include "
DataModelTestDataRead/HView.h
"
15
#include "
DataModelTestDataRead/H.h
"
16
#include "
DataModelTestDataRead/HAuxContainer.h
"
17
#include "
StoreGate/ReadHandle.h
"
18
#include "
StoreGate/WriteHandle.h
"
19
#include <memory>
20
#include <print>
21
#include <sstream>
22
23
24
namespace
DMTest
{
25
26
30
StatusCode
xAODTestReadHVec::initialize
()
31
{
32
ATH_CHECK
(
m_hvecKey
.initialize() );
33
ATH_CHECK
(
m_hviewKey
.initialize(
SG::AllowEmpty
) );
34
ATH_CHECK
(
m_vecWriteKey
.initialize(
SG::AllowEmpty
) );
35
ATH_CHECK
(
m_viewWriteKey
.initialize(
SG::AllowEmpty
) );
36
return
StatusCode::SUCCESS;
37
}
38
39
43
StatusCode
xAODTestReadHVec::execute
(
const
EventContext& ctx)
const
44
{
45
const
DMTest::HVec
* hvec =
SG::get
(
m_hvecKey
, ctx);
46
std::ostringstream ost1;
47
std::print (ost1,
"{}:"
,
m_hvecKey
.key());
48
for
(
const
H
*
h
: *hvec)
49
std::print (ost1,
" {}"
,
h
->aFloat());
50
ATH_MSG_INFO
(ost1.str());
51
52
if
(!
m_hviewKey
.empty()) {
53
const
DMTest::HVec
* hview =
SG::get
(
m_hviewKey
, ctx);
54
std::ostringstream ost2;
55
std::print (ost2,
"{}:"
,
m_hviewKey
.key());
56
for
(
const
H
*
h
: *hview)
57
std::print (ost2,
" {}"
,
h
->aFloat());
58
ATH_MSG_INFO
(ost2.str());
59
60
61
if
(!
m_vecWriteKey
.key().empty()) {
62
auto
vecnew = std::make_unique<HVec>();
63
auto
store = std::make_unique<HAuxContainer>();
64
vecnew->setStore (store.get());
65
for
(
size_t
i = 0; i < hview->
size
(); i++) {
66
vecnew->push_back (
new
H
);
67
*vecnew->back() = *(*hview)[i];
68
}
69
70
auto
viewnew = std::make_unique<HView>();
71
for
(
size_t
i = 0; i < vecnew->size(); i++)
72
viewnew->push_back (vecnew->at(vecnew->size()-1-i));
73
74
SG::WriteHandle<DMTest::HVec>
writevec (
m_vecWriteKey
, ctx);
75
SG::WriteHandle<DMTest::HView>
writeview (
m_viewWriteKey
, ctx);
76
ATH_CHECK
( writevec.
record
(std::move(vecnew), std::move(store)) );
77
ATH_CHECK
( writeview.
record
(std::move(viewnew)) );
78
}
79
}
80
81
return
StatusCode::SUCCESS;
82
}
83
84
85
}
// namespace DMTest
86
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
HAuxContainer.h
Test for xAOD schema evolution.
HVec.h
HView.h
H.h
Test for xAOD schema evolution.
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
h
Header file for AthHistogramAlgorithm.
DMTest::xAODTestReadHVec::m_hviewKey
SG::ReadHandleKey< DMTest::HVec > m_hviewKey
Definition
xAODTestReadHVec.h:53
DMTest::xAODTestReadHVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestReadHVec.cxx:30
DMTest::xAODTestReadHVec::m_hvecKey
SG::ReadHandleKey< DMTest::HVec > m_hvecKey
Definition
xAODTestReadHVec.h:51
DMTest::xAODTestReadHVec::m_viewWriteKey
SG::WriteHandleKey< DMTest::HView > m_viewWriteKey
Definition
xAODTestReadHVec.h:57
DMTest::xAODTestReadHVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestReadHVec.cxx:43
DMTest::xAODTestReadHVec::m_vecWriteKey
SG::WriteHandleKey< DMTest::HVec > m_vecWriteKey
Definition
xAODTestReadHVec.h:55
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DMTest
Definition
B.h:23
DMTest::HVec
HVec_v2 HVec
Definition
DataModelTestDataRead/DataModelTestDataRead/HVec.h:26
DMTest::H
H_v2 H
Definition
DataModelTestDataRead/DataModelTestDataRead/H.h:26
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:281
xAODTestReadHVec.h
Algorithm to test reading xAOD data with schema evolution (HVec/HView).
Generated on
for ATLAS Offline Software by
1.17.0