ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestReadPVec.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 "
xAODTestReadPVec.h
"
13
#include "
DataModelTestDataCommon/PVec.h
"
14
#include "
DataModelTestDataCommon/P.h
"
15
#include "
DataModelTestDataCommon/PAuxContainer.h
"
16
#include "
StoreGate/ReadHandle.h
"
17
#include "
StoreGate/WriteHandle.h
"
18
#include "
AthContainers/ConstAccessor.h
"
19
#include <memory>
20
#include <sstream>
21
#include <print>
22
23
24
namespace
DMTest
{
25
26
30
StatusCode
xAODTestReadPVec::initialize
()
31
{
32
ATH_CHECK
(
m_pvecKey
.initialize() );
33
if
(!
m_writeKey
.key().empty())
34
ATH_CHECK
(
m_writeKey
.initialize() );
35
return
StatusCode::SUCCESS;
36
}
37
38
42
StatusCode
xAODTestReadPVec::execute
(
const
EventContext& ctx)
const
43
{
44
SG::ReadHandle<DMTest::PVec>
pvec
(
m_pvecKey
, ctx);
45
46
const
static
SG::ConstAccessor<unsigned int>
dpInt1 (
"dpInt1"
);
47
const
static
SG::ConstAccessor<std::vector<float>
> dpvFloat (
"dpvFloat"
);
48
49
for
(
const
P
* p : *
pvec
) {
50
std::ostringstream ost;
51
std::print (ost,
" pInt: {} pFloat: {:.2f}"
, p->pInt(), p->pFloat());
52
if
(dpInt1.
isAvailable
(*p))
53
std::print (ost,
" dpInt1: {}"
, dpInt1(*p));
54
std::println(ost);
55
56
std::println (ost,
" pvInt: {}"
, p->pvInt());
57
std::println (ost,
" pvFloat: {::.3f}"
, p->pvFloat());
58
59
if
(dpvFloat.
isAvailable
(*p))
60
{
61
std::println (ost,
" dpvFloat: {::.3f}"
, dpvFloat(*p));
62
}
63
64
ATH_MSG_INFO
(ost.str());
65
}
66
67
if
(!
m_writeKey
.key().empty()) {
68
auto
vecnew = std::make_unique<PVec>();
69
auto
store = std::make_unique<PAuxContainer>();
70
vecnew->setStore (store.get());
71
for
(
size_t
i = 0; i <
pvec
->size(); i++) {
72
vecnew->push_back (
new
P
);
73
*vecnew->back() = *(*pvec)[i];
74
}
75
SG::WriteHandle<DMTest::PVec>
writevec (
m_writeKey
, ctx);
76
ATH_CHECK
( writevec.
record
(std::move(vecnew), std::move(store)) );
77
}
78
79
return
StatusCode::SUCCESS;
80
}
81
82
83
}
// namespace DMTest
84
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
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
pvec
std::array< fp_t, 2 > pvec
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
PAuxContainer.h
Class used for testing xAOD data reading/writing with packed containers.
PVec.h
Class used for testing xAOD data reading/writing with packed containers.
P.h
Class used for testing xAOD data reading/writing with packed containers.
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
DMTest::xAODTestReadPVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestReadPVec.cxx:30
DMTest::xAODTestReadPVec::m_writeKey
SG::WriteHandleKey< DMTest::PVec > m_writeKey
Definition
xAODTestReadPVec.h:53
DMTest::xAODTestReadPVec::m_pvecKey
SG::ReadHandleKey< DMTest::PVec > m_pvecKey
Definition
xAODTestReadPVec.h:50
DMTest::xAODTestReadPVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestReadPVec.cxx:42
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
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::P
P_v1 P
Definition
P.h:23
xAODTestReadPVec.h
Generated on
for ATLAS Offline Software by
1.17.0