ATLAS Offline Software
xAODTestWriteCLinks.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3  */
12 #include "xAODTestWriteCLinks.h"
15 #include "StoreGate/WriteHandle.h"
16 #include "StoreGate/ReadHandle.h"
17 
18 
19 namespace 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 
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  }
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 
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 
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
DMTest::EL
ElementLink< CVec > EL
Definition: xAODTestWriteCLinks.cxx:22
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DMTest::CLinksAOD::setElv
void setElv(const ElementLinkVector< CVec > &elv)
Definition: CLinksAOD.cxx:48
DMTest::CLinksAOD::setVel
void setVel(const std::vector< ElementLink< CVec > > &vel)
Definition: CLinksAOD.cxx:24
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
ElementLinkVector::push_back
void push_back(const ElemLink &link)
Definition: AthLinks/ElementLinkVector.h:316
WriteHandle.h
Handle class for recording to StoreGate.
CLinksAuxContainer.h
For testing thinning of xAOD objects.
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::links
links
Definition: CLinks_v1.cxx:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
DMTest::CLinksAOD
For testing thinning of AOD objects.
Definition: CLinksAOD.h:32
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ElementLinkVector
ElementLinkVector implementation for standalone ROOT.
Definition: AthLinks/ElementLinkVector.h:27
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
CLinksAuxInfo.h
For testing thinning of xAOD objects.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ReadHandle.h
Handle class for reading from StoreGate.
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
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.
DMTest
Definition: B.h:23
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37