ATLAS Offline Software
xAODTestReadPVec.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "xAODTestReadPVec.h"
16 #include "StoreGate/ReadHandle.h"
17 #include "StoreGate/WriteHandle.h"
19 #include <memory>
20 #include <sstream>
21 #include <format>
22 
23 
24 namespace 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 
42 StatusCode 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  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  }
94  ATH_CHECK( writevec.record(std::move(vecnew), std::move(store)) );
95  }
96 
97  return StatusCode::SUCCESS;
98 }
99 
100 
101 } // namespace DMTest
102 
SGTest::store
TestStore store
Definition: TestStore.cxx:23
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DMTest::P_v1
Class used for testing xAOD data reading/writing with packed containers.
Definition: P_v1.h:29
PVec.h
Class used for testing xAOD data reading/writing with packed containers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DMTest::xAODTestReadPVec::m_writeKey
SG::WriteHandleKey< DMTest::PVec > m_writeKey
Definition: xAODTestReadPVec.h:53
SG::ConstAccessor< unsigned int >
PAuxContainer.h
Class used for testing xAOD data reading/writing with packed containers.
DMTest::xAODTestReadPVec::m_pvecKey
SG::ReadHandleKey< DMTest::PVec > m_pvecKey
Definition: xAODTestReadPVec.h:50
P.h
Class used for testing xAOD data reading/writing with packed containers.
WriteHandle.h
Handle class for recording to StoreGate.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::xAODTestReadPVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestReadPVec.cxx:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
DMTest::xAODTestReadPVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestReadPVec.cxx:42
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
pvec
std::array< fp_t, 2 > pvec
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
ReadHandle.h
Handle class for reading from StoreGate.
xAODTestReadPVec.h
DMTest
Definition: B.h:23