ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestWriteCLinks.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
xAODTestWriteCLinks.h
"
13
#include "
DataModelTestDataCommon/CLinksAuxInfo.h
"
14
#include "
DataModelTestDataCommon/CLinksAuxContainer.h
"
15
#include "
StoreGate/WriteHandle.h
"
16
#include "
StoreGate/ReadHandle.h
"
17
18
19
namespace
DMTest
{
20
21
22
typedef
ElementLink<CVec>
EL
;
23
24
28
StatusCode
xAODTestWriteCLinks::initialize
()
29
{
30
ATH_CHECK
(
m_cvecKey
.initialize() );
31
ATH_CHECK
(
m_clinksKey
.initialize (
SG::AllowEmpty
) );
32
ATH_CHECK
(
m_clinksContainerKey
.initialize (
SG::AllowEmpty
) );
33
ATH_CHECK
(
m_clinksAODKey
.initialize (
SG::AllowEmpty
) );
34
return
StatusCode::SUCCESS;
35
}
36
37
41
StatusCode
xAODTestWriteCLinks::execute
(
const
EventContext& ctx)
const
42
{
43
SG::ReadHandle<CVec>
cvec (
m_cvecKey
, ctx);
44
45
if
(!
m_clinksKey
.empty()) {
46
auto
clinks = std::make_unique<CLinks>();
47
auto
clinksaux = std::make_unique<CLinksAuxInfo>();
48
clinks->setStore (clinksaux.get());
49
ATH_CHECK
(
fillCLinks
(
m_cvecKey
.key(), *cvec, 0, *clinks) );
50
SG::WriteHandle<CLinks>
clinksH (
m_clinksKey
, ctx);
51
ATH_CHECK
( clinksH.
record
(std::move (clinks), std::move (clinksaux)) );
52
}
53
54
if
(!
m_clinksContainerKey
.empty()) {
55
auto
clinkscont = std::make_unique<CLinksContainer>();
56
auto
clinkscontaux = std::make_unique<CLinksAuxContainer>();
57
clinkscont->setStore (clinkscontaux.get());
58
for
(
size_t
i = 0; i < 5; i++) {
59
clinkscont->push_back (std::make_unique<CLinks>());
60
ATH_CHECK
(
fillCLinks
(
m_cvecKey
.key(), *cvec, i, *clinkscont->back()) );
61
}
62
SG::WriteHandle<CLinksContainer>
clinksContH (
m_clinksContainerKey
, ctx);
63
ATH_CHECK
( clinksContH.
record
(std::move (clinkscont),
64
std::move (clinkscontaux)) );
65
}
66
67
if
(!
m_clinksAODKey
.empty()) {
68
auto
clinksaod = std::make_unique<CLinksAOD>();
69
ATH_CHECK
(
fillCLinksAOD
(
m_cvecKey
.key(), *cvec, *clinksaod) );
70
SG::WriteHandle<CLinksAOD>
clinksAODH (
m_clinksAODKey
, ctx);
71
ATH_CHECK
( clinksAODH.
record
(std::move (clinksaod)) );
72
}
73
74
return
StatusCode::SUCCESS;
75
}
76
77
78
StatusCode
xAODTestWriteCLinks::fillCLinks
(
const
std::string& key,
79
const
CVec
& cvec,
80
size_t
ndx,
81
CLinks
& clinks)
const
82
{
83
if
(!cvec.
empty
()) {
84
clinks.
setLink
(
EL
(key, (ndx % cvec.
size
())));
85
86
std::vector<EL>
links
;
87
size_t
pos = ndx;
88
assert (pos < cvec.
size
());
89
do
{
90
links
.emplace_back (key, pos);
91
pos += (ndx+1);
92
pos %= cvec.
size
();
93
}
while
(pos != ndx);
94
clinks.
setLinks
(std::move (
links
));
95
}
96
97
return
StatusCode::SUCCESS;
98
}
99
100
101
StatusCode
xAODTestWriteCLinks::fillCLinksAOD
(
const
std::string& key,
102
const
CVec
& cvec,
103
CLinksAOD
& clinks)
const
104
{
105
std::vector<EL> vel;
106
ElementLinkVector<CVec>
elv;
107
for
(
size_t
i = 0; i < cvec.
size
(); i++) {
108
vel.emplace_back (key, i);
109
elv.
push_back
(
EL
(key, cvec.
size
()-i-1));
110
}
111
clinks.
setVel
(vel);
112
clinks.
setElv
(elv);
113
return
StatusCode::SUCCESS;
114
}
115
116
117
}
// namespace DMTest
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
CLinksAuxContainer.h
For testing thinning of xAOD objects.
CLinksAuxInfo.h
For testing thinning of xAOD objects.
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
DMTest::CLinksAOD
For testing thinning of AOD objects.
Definition
CLinksAOD.h:32
DMTest::CLinksAOD::setVel
void setVel(const std::vector< ElementLink< CVec > > &vel)
Definition
CLinksAOD.cxx:24
DMTest::CLinksAOD::setElv
void setElv(const ElementLinkVector< CVec > &elv)
Definition
CLinksAOD.cxx:48
DMTest::CLinks_v1::setLinks
void setLinks(const std::vector< ElementLink< CVec > > &l)
DMTest::CLinks_v1::setLink
void setLink(const ElementLink< CVec > &l)
DMTest::xAODTestWriteCLinks::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWriteCLinks.cxx:28
DMTest::xAODTestWriteCLinks::m_clinksContainerKey
SG::WriteHandleKey< DMTest::CLinksContainer > m_clinksContainerKey
Definition
xAODTestWriteCLinks.h:67
DMTest::xAODTestWriteCLinks::m_clinksKey
SG::WriteHandleKey< DMTest::CLinks > m_clinksKey
Definition
xAODTestWriteCLinks.h:64
DMTest::xAODTestWriteCLinks::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWriteCLinks.cxx:41
DMTest::xAODTestWriteCLinks::fillCLinksAOD
StatusCode fillCLinksAOD(const std::string &key, const CVec &cvec, CLinksAOD &clinks) const
Definition
xAODTestWriteCLinks.cxx:101
DMTest::xAODTestWriteCLinks::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWriteCLinks.h:61
DMTest::xAODTestWriteCLinks::m_clinksAODKey
SG::WriteHandleKey< DMTest::CLinksAOD > m_clinksAODKey
Definition
xAODTestWriteCLinks.h:70
DMTest::xAODTestWriteCLinks::fillCLinks
StatusCode fillCLinks(const std::string &key, const CVec &cvec, size_t ndx, CLinks &clinks) const
Definition
xAODTestWriteCLinks.cxx:78
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
ElementLinkVector
ElementLinkVector implementation for standalone ROOT.
Definition
AthLinks/ElementLinkVector.h:64
ElementLinkVector::push_back
void push_back(const ElemLink &link)
Definition
AthLinks/ElementLinkVector.h:317
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
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::links
links
Definition
CLinks_v1.cxx:22
DMTest::CVec
CVec_v1 CVec
Definition
CVec.h:26
DMTest::CLinks
CLinks_v1 CLinks
Definition
CLinks.h:23
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
xAODTestWriteCLinks.h
Create CLinks/CLinksAOD objects.
Generated on
for ATLAS Offline Software by
1.17.0