ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestReadJVec.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 "
xAODTestReadJVec.h
"
13
#include "
StoreGate/ReadHandle.h
"
14
#include "
StoreGate/ReadDecorHandle.h
"
15
#include "
AthContainers/JaggedVec.h
"
16
#include "AthLinks/ElementLink.h"
17
#include <format>
18
#include <print>
19
#include <sstream>
20
21
22
namespace
{
23
24
28
template
<
class
CONT>
29
std::string formEL (
const
ElementLink<CONT>
& el)
30
{
31
return
std::format (
"({}:{})"
,
32
el
.dataID(),
33
static_cast<
int
>
(
el
.index()) == -1 ?
"inv"
: std::to_string(
el
.index()));
34
}
35
36
40
template
<
class
T>
41
std::string form_vec_elt (
const
T&
x
)
42
{
43
return
std::format (
"{}"
,
x
);
44
}
45
46
47
51
std::string form_vec_elt (
const
std::string&
x
)
52
{
53
return
std::format (
"'{}'"
,
x
);
54
}
55
56
60
template
<
class
CONT>
61
std::string form_vec_elt (
const
ElementLink<CONT>
&
x
)
62
{
63
return
formEL (
x
);
64
}
65
66
70
template
<
class
RANGE>
71
std::string formJVec (
const
RANGE&
r
) {
72
std::ostringstream
ss
;
73
std::print (
ss
,
"["
);
74
std::string
sep
;
75
for
(
const
auto
& elt :
r
) {
76
std::print (
ss
,
"{}"
, sep);
77
sep
=
" "
;
78
std::print (
ss
,
"{}"
, form_vec_elt (elt));
79
}
80
std::print (
ss
,
"]"
);
81
return
ss
.str();
82
}
83
84
85
}
86
87
88
namespace
DMTest
{
89
90
94
StatusCode
xAODTestReadJVec::initialize
()
95
{
96
ATH_CHECK
(
m_jvecContainerKey
.initialize (
SG::AllowEmpty
) );
97
ATH_CHECK
(
m_jvecInfoKey
.initialize (
SG::AllowEmpty
) );
98
ATH_CHECK
(
m_jvecDecorKey
.initialize (
SG::AllowEmpty
) );
99
ATH_CHECK
(
m_jvecInfoDecorKey
.initialize (
SG::AllowEmpty
) );
100
return
StatusCode::SUCCESS;
101
}
102
103
107
StatusCode
xAODTestReadJVec::execute
(
const
EventContext& ctx)
const
108
{
109
if
(!
m_jvecContainerKey
.empty()) {
110
SG::ReadHandle<JVecContainer>
jveccont (
m_jvecContainerKey
, ctx);
111
ATH_MSG_INFO
(
m_jvecContainerKey
.key() );
112
for
(
const
JVec
* jvec : *jveccont) {
113
ATH_CHECK
(
dumpJVec
(*jvec) );
114
ATH_CHECK
(
dumpDecor
(ctx, *jvec) );
115
}
116
}
117
118
if
(!
m_jvecInfoKey
.empty()) {
119
SG::ReadHandle<JVec>
jvecinfo (
m_jvecInfoKey
, ctx);
120
ATH_MSG_INFO
(
m_jvecInfoKey
.key() );
121
ATH_CHECK
(
dumpJVec
(*jvecinfo) );
122
ATH_CHECK
(
dumpInfoDecor
(ctx, *jvecinfo) );
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
132
StatusCode
xAODTestReadJVec::dumpJVec
(
const
JVec
& jvec)
const
133
{
134
ATH_MSG_INFO
(
" ivec: {} fvec: {} svec: {} lvec: {}"
,
135
formJVec (jvec.
ivec
()),
136
formJVec (jvec.
fvec
()),
137
formJVec (jvec.
svec
()),
138
formJVec (jvec.
lvec
()));
139
return
StatusCode::SUCCESS;
140
}
141
142
146
StatusCode
147
xAODTestReadJVec::dumpDecor
(
const
EventContext& ctx,
148
const
JVec
& jvec)
const
149
{
150
std::ostringstream
ss
;
151
if
(!
m_jvecDecorKey
.empty()) {
152
SG::ReadDecorHandle<JVecContainer, SG::JaggedVecElt<double>
> decor (
m_jvecDecorKey
, ctx);
153
std::print (
ss
,
" decorJVec: {}"
, formJVec (decor (jvec)));
154
}
155
156
ATH_MSG_INFO
(
ss
.str() );
157
return
StatusCode::SUCCESS;
158
}
159
160
164
StatusCode
165
xAODTestReadJVec::dumpInfoDecor
(
const
EventContext& ctx,
166
const
JVec
& jvec)
const
167
{
168
std::ostringstream
ss
;
169
if
(!
m_jvecInfoDecorKey
.empty()) {
170
SG::ReadDecorHandle<JVec, SG::JaggedVecElt<double>
> decor (
m_jvecInfoDecorKey
, ctx);
171
std::print (
ss
,
" decorJVec: {}"
, formJVec (decor (jvec)));
172
}
173
174
ATH_MSG_INFO
(
ss
.str() );
175
return
StatusCode::SUCCESS;
176
}
177
178
179
}
// namespace DMTest
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:45
JaggedVec.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ReadHandle.h
Handle class for reading from StoreGate.
x
#define x
DMTest::JVec_v1::ivec
intRange_t ivec() const
DMTest::JVec_v1::lvec
linkRange_t lvec() const
DMTest::JVec_v1::svec
stringRange_t svec() const
DMTest::JVec_v1::fvec
floatRange_t fvec() const
DMTest::xAODTestReadJVec::m_jvecContainerKey
SG::ReadHandleKey< DMTest::JVecContainer > m_jvecContainerKey
Definition
xAODTestReadJVec.h:71
DMTest::xAODTestReadJVec::m_jvecInfoDecorKey
SG::ReadDecorHandleKey< DMTest::JVec > m_jvecInfoDecorKey
Definition
xAODTestReadJVec.h:80
DMTest::xAODTestReadJVec::dumpJVec
StatusCode dumpJVec(const JVec &jvec) const
Dump a JVec object.
Definition
xAODTestReadJVec.cxx:132
DMTest::xAODTestReadJVec::m_jvecInfoKey
SG::ReadHandleKey< DMTest::JVec > m_jvecInfoKey
Definition
xAODTestReadJVec.h:74
DMTest::xAODTestReadJVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestReadJVec.cxx:94
DMTest::xAODTestReadJVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestReadJVec.cxx:107
DMTest::xAODTestReadJVec::dumpInfoDecor
StatusCode dumpInfoDecor(const EventContext &ctx, const JVec &jvec) const
Dump decorations from a standalone JVec object.
Definition
xAODTestReadJVec.cxx:165
DMTest::xAODTestReadJVec::dumpDecor
StatusCode dumpDecor(const EventContext &ctx, const JVec &jvec) const
Dump decorations from a JVec object.
Definition
xAODTestReadJVec.cxx:147
DMTest::xAODTestReadJVec::m_jvecDecorKey
SG::ReadDecorHandleKey< DMTest::JVecContainer > m_jvecDecorKey
Definition
xAODTestReadJVec.h:77
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
r
int r
Definition
globals.cxx:22
DMTest
Definition
B.h:23
DMTest::JVec
JVec_v1 JVec
Definition
JVec.h:23
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
grepfile.sep
sep
Definition
grepfile.py:38
python.getProblemFolderFromLogs.el
dict el
Definition
getProblemFolderFromLogs.py:51
xAODTestReadJVec.h
For testing jagged vectors.
Generated on
for ATLAS Offline Software by
1.17.0