ATLAS Offline Software
Loading...
Searching...
No Matches
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"
19#include <memory>
20#include <sstream>
21#include <print>
22
23
24namespace DMTest {
25
26
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
42StatusCode xAODTestReadPVec::execute (const EventContext& ctx) const
43{
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 }
76 ATH_CHECK( writevec.record(std::move(vecnew), std::move(store)) );
77 }
78
79 return StatusCode::SUCCESS;
80}
81
82
83} // namespace DMTest
84
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
Helper class to provide constant type-safe access to aux data.
std::array< fp_t, 2 > pvec
Class used for testing xAOD data reading/writing with packed containers.
Class used for testing xAOD data reading/writing with packed containers.
Class used for testing xAOD data reading/writing with packed containers.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
SG::WriteHandleKey< DMTest::PVec > m_writeKey
SG::ReadHandleKey< DMTest::PVec > m_pvecKey
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Definition B.h:23
P_v1 P
Definition P.h:23