ATLAS Offline Software
xAODTestReadJVec.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 "xAODTestReadJVec.h"
13 #include "StoreGate/ReadHandle.h"
16 #include "AthLinks/ElementLink.h"
17 #include <sstream>
18 
19 
20 namespace {
21 
22 
26 template <class CONT>
27 std::string formEL (const ElementLink<CONT>& el)
28 {
29  std::ostringstream ss;
30  ss << "(" << el.dataID() << ":";
31  if (static_cast<int>(el.index()) == -1) {
32  ss << "inv";
33  }
34  else {
35  ss << el.index();
36  }
37  ss << ")";
38  return ss.str();
39 }
40 
41 
45 template <class T>
46 std::string form_vec_elt (const T& x)
47 {
48  std::ostringstream ss;
49  ss << x;
50  return ss.str();
51 }
52 
53 
54 
58 std::string form_vec_elt (const std::string& x)
59 {
60  return "'" + x + "'";
61 }
62 
63 
67 template <class CONT>
68 std::string form_vec_elt (const ElementLink<CONT>& x)
69 {
70  return formEL (x);
71 }
72 
73 
77 template <class RANGE>
78 std::string formJVec (const RANGE& r) {
79  std::ostringstream ss;
80  ss << "[";
81  std::string sep;
82  for (auto elt : r) {
83  ss << sep;
84  sep = " ";
85  ss << form_vec_elt (elt);
86  }
87  ss << "]";
88  return ss.str();
89 }
90 
91 
92 }
93 
94 
95 namespace DMTest {
96 
97 
102 {
104  ATH_CHECK( m_jvecInfoKey.initialize (SG::AllowEmpty) );
105  ATH_CHECK( m_jvecDecorKey.initialize (SG::AllowEmpty) );
107  return StatusCode::SUCCESS;
108 }
109 
110 
114 StatusCode xAODTestReadJVec::execute (const EventContext& ctx) const
115 {
116  if (!m_jvecContainerKey.empty()) {
119  for (const JVec* jvec : *jveccont) {
120  ATH_CHECK( dumpJVec (*jvec) );
121  ATH_CHECK( dumpDecor (ctx, *jvec) );
122  }
123  }
124 
125  if (!m_jvecInfoKey.empty()) {
126  SG::ReadHandle<JVec> jvecinfo (m_jvecInfoKey, ctx);
127  ATH_MSG_INFO( m_jvecInfoKey.key() );
128  ATH_CHECK( dumpJVec (*jvecinfo) );
129  ATH_CHECK( dumpInfoDecor (ctx, *jvecinfo) );
130  }
131 
132  return StatusCode::SUCCESS;
133 }
134 
135 
140 {
141  std::ostringstream ss;
142  ss << " ivec: " << formJVec (jvec.ivec());
143  ss << " fvec: " << formJVec (jvec.fvec());
144  ss << " svec: " << formJVec (jvec.svec());
145  ss << " lvec: " << formJVec (jvec.lvec());
146  ATH_MSG_INFO( ss.str() );
147  return StatusCode::SUCCESS;
148 }
149 
150 
155 xAODTestReadJVec::dumpDecor (const EventContext& ctx,
156  const JVec& jvec) const
157 {
158  std::ostringstream ss;
159  if (!m_jvecDecorKey.empty()) {
161  ss << " decorJVec: " << formJVec (decor (jvec));
162  }
163 
164  ATH_MSG_INFO( ss.str() );
165  return StatusCode::SUCCESS;
166 }
167 
168 
173 xAODTestReadJVec::dumpInfoDecor (const EventContext& ctx,
174  const JVec& jvec) const
175 {
176  std::ostringstream ss;
177  if (!m_jvecInfoDecorKey.empty()) {
179  ss << " decorJVec: " << formJVec (decor (jvec));
180  }
181 
182  ATH_MSG_INFO( ss.str() );
183  return StatusCode::SUCCESS;
184 }
185 
186 
187 } // namespace DMTest
DMTest::xAODTestReadJVec::dumpInfoDecor
StatusCode dumpInfoDecor(const EventContext &ctx, const JVec &jvec) const
Dump decorations from a standalone JVec object.
Definition: xAODTestReadJVec.cxx:173
beamspotman.r
def r
Definition: beamspotman.py:676
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DMTest::xAODTestReadJVec::m_jvecInfoDecorKey
SG::ReadDecorHandleKey< DMTest::JVec > m_jvecInfoDecorKey
Definition: xAODTestReadJVec.h:80
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DMTest::JVec_v1::ivec
intRange_t ivec() const
Definition: JVec_v1.cxx:19
DMTest::xAODTestReadJVec::dumpDecor
StatusCode dumpDecor(const EventContext &ctx, const JVec &jvec) const
Dump decorations from a JVec object.
Definition: xAODTestReadJVec.cxx:155
DMTest::xAODTestReadJVec::m_jvecContainerKey
SG::ReadHandleKey< DMTest::JVecContainer > m_jvecContainerKey
Definition: xAODTestReadJVec.h:71
x
#define x
DMTest::JVec_v1
For testing jagged vectors.
Definition: JVec_v1.h:36
DMTest::xAODTestReadJVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestReadJVec.cxx:114
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAODTestReadJVec.h
For testing jagged vectors.
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
grepfile.sep
sep
Definition: grepfile.py:38
DMTest::xAODTestReadJVec::m_jvecDecorKey
SG::ReadDecorHandleKey< DMTest::JVecContainer > m_jvecDecorKey
Definition: xAODTestReadJVec.h:77
JaggedVec.h
Auxiliary variable type allowing storage as a jagged vector. That is, the payloads for all the DataVe...
DMTest::JVec_v1::fvec
floatRange_t fvec() const
Definition: JVec_v1.cxx:31
DMTest::JVec_v1::lvec
linkRange_t lvec() const
Definition: JVec_v1.cxx:55
DMTest::xAODTestReadJVec::dumpJVec
StatusCode dumpJVec(const JVec &jvec) const
Dump a JVec object.
Definition: xAODTestReadJVec.cxx:139
DMTest::xAODTestReadJVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestReadJVec.cxx:101
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
DMTest::xAODTestReadJVec::m_jvecInfoKey
SG::ReadHandleKey< DMTest::JVec > m_jvecInfoKey
Definition: xAODTestReadJVec.h:74
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
DMTest::JVec_v1::svec
stringRange_t svec() const
Definition: JVec_v1.cxx:43
DMTest
Definition: B.h:23