ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestReadCInfo.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 "xAODTestReadCInfo.h"
17#include "AthLinks/ElementLink.h"
19#include <print>
20#include <sstream>
21
22
23namespace DMTest {
24
25
31xAODTestReadCInfo::xAODTestReadCInfo (const std::string &name,
32 ISvcLocator *pSvcLocator)
33 : AthReentrantAlgorithm (name, pSvcLocator)
34{
35 declareProperty ("CInfoKey", m_cinfoKey = "cinfo");
36 declareProperty ("WriteKey", m_writeKey);
37}
38
39
44{
45 ATH_CHECK( m_cinfoKey.initialize() );
46 if (!m_writeKey.key().empty())
47 ATH_CHECK( m_writeKey.initialize() );
48 return StatusCode::SUCCESS;
49}
50
51
55StatusCode xAODTestReadCInfo::execute (const EventContext& ctx) const
56{
57 static const C::Accessor<int> anInt2 ("anInt2");
58 static const C::Accessor<int> anInt10 ("anInt10");
59 static const C::Accessor<int> dInt1 ("dInt1");
60 static const C::Accessor<unsigned int> dpInt1 ("dpInt1");
61 static const C::Accessor<std::vector<float> > dpvFloat ("dpvFloat");
62 static const C::Accessor<int> dInt100 ("dInt100");
63 static const C::Accessor<int> dInt150 ("dInt150");
64 static const C::Accessor<int> dInt200 ("dInt200");
65 static const C::Accessor<int> dInt250 ("dInt250");
66 static const C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
67
68 // Ordering of auxid is not reliable. Sort by name.
70 std::vector<std::string> names;
71
73
74 names.clear();
75 for (SG::auxid_t auxid : cinfo->getAuxIDs())
76 names.push_back (r.getName(auxid));
77 std::sort (names.begin(), names.end());
78 std::ostringstream ost1;
79 ATH_MSG_INFO ("cinfo aux items: {:n:s}", names);
80
81 std::ostringstream ost2;
82 std::print (ost2,
83 "cinfo anInt1 {} aFloat: {} anInt2: {} dInt1: {} cEL: {}[{}]",
84 cinfo->anInt(),
85 cinfo->aFloat(),
86 anInt2(*cinfo),
87 dInt1(*cinfo),
88 cEL(*cinfo).dataID(),
89 cEL(*cinfo).index());
90 if (dInt100.isAvailable(*cinfo))
91 std::print (ost2, " dInt100: {}", dInt100(*cinfo));
92 if (dInt150.isAvailable(*cinfo))
93 std::print (ost2, " dInt150: {}", dInt150(*cinfo));
94 if (dInt200.isAvailable(*cinfo))
95 std::print (ost2, " dInt200: {}", dInt200(*cinfo));
96 if (dInt250.isAvailable(*cinfo))
97 std::print (ost2, " dInt250: {}", dInt250(*cinfo));
98 if (anInt10.isAvailable(*cinfo))
99 std::print (ost2, " anInt10: {}", anInt10(*cinfo));
100 ATH_MSG_INFO (ost2.str());
101
102 if (!m_writeKey.key().empty()) {
103 auto cnew = std::make_unique<DMTest::C>();
104 auto info_store = std::make_unique<DMTest::CInfoAuxContainer>();
105 cnew->setStore (info_store.get());
106 *cnew = *cinfo;
107
109 ATH_CHECK( writevec.record(std::move(cnew), std::move(info_store)) );
110 }
111
112 return StatusCode::SUCCESS;
113}
114
115
116} // namespace DMTest
117
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
Handle mappings between names and auxid_t.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Helpers for checking error return status codes and reporting errors.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< DMTest::C > m_writeKey
virtual StatusCode execute(const EventContext &ctx) const
Algorithm event processing.
SG::ReadHandleKey< DMTest::C > m_cinfoKey
virtual StatusCode initialize()
Algorithm initialization; called at the beginning of the job.
xAODTestReadCInfo(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
int r
Definition globals.cxx:22
Definition B.h:23
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Algorithm to test reading xAOD cinfo data.