ATLAS Offline Software
Loading...
Searching...
No Matches
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"
17
18
19namespace DMTest {
20
21
23
24
29{
30 ATH_CHECK( m_cvecKey.initialize() );
31 ATH_CHECK( m_clinksKey.initialize (SG::AllowEmpty) );
34 return StatusCode::SUCCESS;
35}
36
37
41StatusCode xAODTestWriteCLinks::execute (const EventContext& ctx) const
42{
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) );
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 }
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) );
71 ATH_CHECK( clinksAODH.record (std::move (clinksaod)) );
72 }
73
74 return StatusCode::SUCCESS;
75}
76
77
78StatusCode 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
101StatusCode xAODTestWriteCLinks::fillCLinksAOD (const std::string& key,
102 const CVec& cvec,
103 CLinksAOD& clinks) const
104{
105 std::vector<EL> vel;
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
#define ATH_CHECK
Evaluate an expression and check for errors.
For testing thinning of xAOD objects.
For testing thinning of xAOD objects.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
For testing thinning of AOD objects.
Definition CLinksAOD.h:32
void setVel(const std::vector< ElementLink< CVec > > &vel)
Definition CLinksAOD.cxx:24
void setElv(const ElementLinkVector< CVec > &elv)
Definition CLinksAOD.cxx:48
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
ElementLinkVector implementation for standalone ROOT.
void push_back(const ElemLink &link)
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
CLinks_v1 CLinks
Definition CLinks.h:23
This module defines the arguments passed from the BATCH driver to the BATCH worker.