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-2024 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 <format>
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
ost <<
" pInt: "
<< p->pInt()
52
<<
" pFloat: "
<< std::format (
"{:.2f}"
, p->pFloat());
53
if
(dpInt1.
isAvailable
(*p))
54
ost <<
" dpInt1: "
<< dpInt1(*p);
55
ost <<
"\n"
;
56
57
{
58
const
std::vector<int>& pvi = p->pvInt();
59
ost <<
" pvInt: ["
;
60
for
(
auto
ii : pvi)
61
ost << ii <<
" "
;
62
ost <<
"]\n"
;
63
}
64
65
{
66
const
std::vector<float>& pvf = p->pvFloat();
67
ost <<
" pvFloat: ["
;
68
for
(
auto
f : pvf)
69
ost << std::format (
"{:.3f}"
, f) <<
" "
;
70
ost <<
"]\n"
;
71
}
72
73
if
(dpvFloat.
isAvailable
(*p))
74
{
75
const
std::vector<float>& pvf = dpvFloat(*p);
76
ost <<
" dpvFloat: ["
;
77
for
(
auto
f : pvf)
78
ost << std::format (
"{:.3f}"
, f) <<
" "
;
79
ost <<
"]\n"
;
80
}
81
82
ATH_MSG_INFO
(ost.str());
83
}
84
85
if
(!
m_writeKey
.key().empty()) {
86
auto
vecnew = std::make_unique<PVec>();
87
auto
store = std::make_unique<PAuxContainer>();
88
vecnew->setStore (store.get());
89
for
(
size_t
i = 0; i <
pvec
->size(); i++) {
90
vecnew->push_back (
new
P
);
91
*vecnew->back() = *(*pvec)[i];
92
}
93
SG::WriteHandle<DMTest::PVec>
writevec (
m_writeKey
, ctx);
94
ATH_CHECK
( writevec.
record
(std::move(vecnew), std::move(store)) );
95
}
96
97
return
StatusCode::SUCCESS;
98
}
99
100
101
}
// namespace DMTest
102
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:31
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:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
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