ATLAS Offline Software
Loading...
Searching...
No Matches
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"
18
19
20namespace DMTest {
21
22
27{
28 ATH_CHECK( m_cvecKey.initialize() );
29 ATH_CHECK( m_ctrigKey.initialize() );
36 return StatusCode::SUCCESS;
37}
38
39
43StatusCode xAODTestWritePLinks::execute (const EventContext& ctx) const
44{
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
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
75 ATH_CHECK( plinksInfoH.record (std::move (plinksinfo),
76 std::move (plinksauxinfo)) );
77 }
78
80 m_cvecKey.key(), *cvec,
81 m_ctrigKey.key(), *ctrig) );
82
83 return StatusCode::SUCCESS;
84}
85
86
87auto 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
104StatusCode 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
121StatusCode 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()) {
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()) {
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()) {
151 size_t ndx = ctx.evt() + 4;
152 decor (*decor) = makeLink (key1, cvec1, key2, cvec2, ndx);
153 }
154
155 if (!m_plinksInfoDecorVLinksKey.empty()) {
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
#define ATH_CHECK
Evaluate an expression and check for errors.
For testing packed links.
For testing packed links.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Definition B.h:23
CVec_v1 CVec
Definition CVec.h:26
PLinks_v1 PLinks
Definition PLinks.h:23
ElementLink< CVec > EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.