ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestWritePLinks.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
xAODTestWritePLinks.h
"
13
#include "
DataModelTestDataCommon/PLinksAuxContainer.h
"
14
#include "
DataModelTestDataCommon/PLinksAuxInfo.h
"
15
#include "
StoreGate/WriteHandle.h
"
16
#include "
StoreGate/WriteDecorHandle.h
"
17
#include "
StoreGate/ReadHandle.h
"
18
19
20
namespace
DMTest
{
21
22
26
StatusCode
xAODTestWritePLinks::initialize
()
27
{
28
ATH_CHECK
(
m_cvecKey
.initialize() );
29
ATH_CHECK
(
m_ctrigKey
.initialize() );
30
ATH_CHECK
(
m_plinksContainerKey
.initialize (
SG::AllowEmpty
) );
31
ATH_CHECK
(
m_plinksInfoKey
.initialize (
SG::AllowEmpty
) );
32
ATH_CHECK
(
m_plinksDecorLinkKey
.initialize (
SG::AllowEmpty
) );
33
ATH_CHECK
(
m_plinksDecorVLinksKey
.initialize (
SG::AllowEmpty
) );
34
ATH_CHECK
(
m_plinksInfoDecorLinkKey
.initialize (
SG::AllowEmpty
) );
35
ATH_CHECK
(
m_plinksInfoDecorVLinksKey
.initialize (
SG::AllowEmpty
) );
36
return
StatusCode::SUCCESS;
37
}
38
39
43
StatusCode
xAODTestWritePLinks::execute
(
const
EventContext& ctx)
const
44
{
45
SG::ReadHandle<CVec>
cvec (
m_cvecKey
, ctx);
46
SG::ReadHandle<CVec>
ctrig (
m_ctrigKey
, ctx);
47
48
if
(!
m_plinksContainerKey
.empty()) {
49
auto
plinkscont = std::make_unique<PLinksContainer>();
50
auto
plinksauxcont = std::make_unique<PLinksAuxContainer>();
51
plinkscont->setStore (plinksauxcont.get());
52
for
(
size_t
i = 0; i < 5; i++) {
53
plinkscont->push_back (std::make_unique<PLinks>());
54
ATH_CHECK
(
fillPLinks
(
m_cvecKey
.key(), *cvec,
55
m_ctrigKey
.key(), *ctrig,
56
i + ctx.evt(),
57
*plinkscont->back()) );
58
}
59
60
SG::WriteHandle<PLinksContainer>
plinksContH (
m_plinksContainerKey
, ctx);
61
ATH_CHECK
( plinksContH.
record
(std::move (plinkscont),
62
std::move (plinksauxcont)) );
63
}
64
65
if
(!
m_plinksInfoKey
.empty()) {
66
auto
plinksinfo = std::make_unique<PLinks>();
67
auto
plinksauxinfo = std::make_unique<PLinksAuxInfo>();
68
plinksinfo->setStore (plinksauxinfo.get());
69
ATH_CHECK
(
fillPLinks
(
m_cvecKey
.key(), *cvec,
70
m_ctrigKey
.key(), *ctrig,
71
ctx.evt() + 3,
72
*plinksinfo) );
73
74
SG::WriteHandle<PLinks>
plinksInfoH (
m_plinksInfoKey
, ctx);
75
ATH_CHECK
( plinksInfoH.
record
(std::move (plinksinfo),
76
std::move (plinksauxinfo)) );
77
}
78
79
ATH_CHECK
(
decorPLinks
(ctx,
80
m_cvecKey
.key(), *cvec,
81
m_ctrigKey
.key(), *ctrig) );
82
83
return
StatusCode::SUCCESS;
84
}
85
86
87
auto
xAODTestWritePLinks::makeLink
(
const
std::string& key1,
88
const
CVec
& cvec1,
89
const
std::string& key2,
90
const
CVec
& cvec2,
91
size_t
ndx)
const
->
EL
92
{
93
if
((ndx%3) == 0 && !cvec1.empty()) {
94
return
EL
(key1, (ndx % cvec1.size()));
95
}
96
else
if
((ndx%3) == 1 && !cvec2.empty()) {
97
return
EL
(key2, (ndx % cvec2.size()));
98
}
99
// else leave it null
100
return
EL
();
101
}
102
103
104
StatusCode
xAODTestWritePLinks::fillPLinks
(
const
std::string& key1,
105
const
CVec
& cvec1,
106
const
std::string& key2,
107
const
CVec
& cvec2,
108
size_t
ndx,
109
PLinks
& plinks)
const
110
{
111
plinks.
setPLink
(
makeLink
(key1, cvec1, key2, cvec2, ndx));
112
std::vector<EL> v;
113
for
(
size_t
i = 0; i < ndx%5; ++i) {
114
v.emplace_back (
makeLink
(key1, cvec1, key2, cvec2, ndx+i+1));
115
}
116
plinks.
setVLinks
(v);
117
return
StatusCode::SUCCESS;
118
}
119
120
121
StatusCode
xAODTestWritePLinks::decorPLinks
(
const
EventContext& ctx,
122
const
std::string& key1,
123
const
CVec
& cvec1,
124
const
std::string& key2,
125
const
CVec
& cvec2)
const
126
{
127
if
(!
m_plinksDecorLinkKey
.empty()) {
128
SG::WriteDecorHandle<PLinksContainer, SG::PackedLink<CVec>
> decor (
m_plinksDecorLinkKey
, ctx);
129
size_t
ndx = ctx.evt();
130
for
(
const
PLinks
* plinks : *decor) {
131
decor (*plinks) =
makeLink
(key1, cvec1, key2, cvec2, ndx);
132
++ndx;
133
}
134
}
135
136
if
(!
m_plinksDecorVLinksKey
.empty()) {
137
SG::WriteDecorHandle<PLinksContainer, std::vector<SG::PackedLink<CVec>
> > decor (
m_plinksDecorVLinksKey
, ctx);
138
size_t
ndx = ctx.evt() + 3;
139
for
(
const
PLinks
* plinks : *decor) {
140
std::vector<EL> v;
141
for
(
size_t
i = 0; i < ndx%5; ++i) {
142
v.emplace_back (
makeLink
(key1, cvec1, key2, cvec2, ndx+i+1));
143
}
144
decor (*plinks) = v;
145
++ndx;
146
}
147
}
148
149
if
(!
m_plinksInfoDecorLinkKey
.empty()) {
150
SG::WriteDecorHandle<PLinks, SG::PackedLink<CVec>
> decor (
m_plinksInfoDecorLinkKey
, ctx);
151
size_t
ndx = ctx.evt() + 4;
152
decor (*decor) =
makeLink
(key1, cvec1, key2, cvec2, ndx);
153
}
154
155
if
(!
m_plinksInfoDecorVLinksKey
.empty()) {
156
SG::WriteDecorHandle<PLinks, std::vector<SG::PackedLink<CVec>
> > decor (
m_plinksInfoDecorVLinksKey
, ctx);
157
size_t
ndx = ctx.evt() + 7;
158
std::vector<EL> v;
159
for
(
size_t
i = 0; i < ndx%5; ++i) {
160
v.emplace_back (
makeLink
(key1, cvec1, key2, cvec2, ndx+i+1));
161
}
162
decor (*decor) = v;
163
}
164
165
return
StatusCode::SUCCESS;
166
}
167
168
169
}
// namespace DMTest
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
PLinksAuxContainer.h
For testing packed links.
PLinksAuxInfo.h
For testing packed links.
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
WriteHandle.h
Handle class for recording to StoreGate.
DMTest::PLinks_v1::setPLink
void setPLink(const ElementLink< CVec > &l)
DMTest::PLinks_v1::setVLinks
void setVLinks(const std::vector< ElementLink< CVec > > &v)
Set the vector of links.
Definition
PLinks_v1.cxx:55
DMTest::xAODTestWritePLinks::m_plinksInfoDecorVLinksKey
SG::WriteDecorHandleKey< DMTest::PLinks > m_plinksInfoDecorVLinksKey
Definition
xAODTestWritePLinks.h:96
DMTest::xAODTestWritePLinks::m_plinksInfoKey
SG::WriteHandleKey< DMTest::PLinks > m_plinksInfoKey
Definition
xAODTestWritePLinks.h:84
DMTest::xAODTestWritePLinks::decorPLinks
StatusCode decorPLinks(const EventContext &ctx, const std::string &key1, const CVec &cvec1, const std::string &key2, const CVec &cvec2) const
Definition
xAODTestWritePLinks.cxx:121
DMTest::xAODTestWritePLinks::fillPLinks
StatusCode fillPLinks(const std::string &key1, const CVec &cvec1, const std::string &key2, const CVec &cvec2, size_t ndx, PLinks &plinks) const
Definition
xAODTestWritePLinks.cxx:104
DMTest::xAODTestWritePLinks::m_plinksInfoDecorLinkKey
SG::WriteDecorHandleKey< DMTest::PLinks > m_plinksInfoDecorLinkKey
Definition
xAODTestWritePLinks.h:93
DMTest::xAODTestWritePLinks::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWritePLinks.h:76
DMTest::xAODTestWritePLinks::m_plinksDecorLinkKey
SG::WriteDecorHandleKey< DMTest::PLinksContainer > m_plinksDecorLinkKey
Definition
xAODTestWritePLinks.h:87
DMTest::xAODTestWritePLinks::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWritePLinks.cxx:43
DMTest::xAODTestWritePLinks::m_plinksContainerKey
SG::WriteHandleKey< DMTest::PLinksContainer > m_plinksContainerKey
Definition
xAODTestWritePLinks.h:81
DMTest::xAODTestWritePLinks::makeLink
EL makeLink(const std::string &key1, const CVec &cvec1, const std::string &key2, const CVec &cvec2, size_t ndx) const
Definition
xAODTestWritePLinks.cxx:87
DMTest::xAODTestWritePLinks::m_plinksDecorVLinksKey
SG::WriteDecorHandleKey< DMTest::PLinksContainer > m_plinksDecorVLinksKey
Definition
xAODTestWritePLinks.h:90
DMTest::xAODTestWritePLinks::m_ctrigKey
SG::ReadHandleKey< DMTest::CVec > m_ctrigKey
Definition
xAODTestWritePLinks.h:78
DMTest::xAODTestWritePLinks::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWritePLinks.cxx:26
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DMTest
Definition
B.h:23
DMTest::CVec
CVec_v1 CVec
Definition
CVec.h:26
DMTest::PLinks
PLinks_v1 PLinks
Definition
PLinks.h:23
DMTest::EL
ElementLink< CVec > EL
Definition
xAODTestWriteCLinks.cxx:22
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAODTestWritePLinks.h
Test writing packed links.
Generated on
for ATLAS Offline Software by
1.17.0