ATLAS Offline Software
xAODTestFilterCVec.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
14 #include "xAODTestFilterCVec.h"
18 #include "StoreGate/ReadHandle.h"
19 #include "StoreGate/WriteHandle.h"
20 #include <memory>
21 
22 
23 namespace DMTest {
24 
25 
32  ISvcLocator *pSvcLocator)
33  : AthReentrantAlgorithm (name, pSvcLocator),
34  m_cvecKey ("cvec_renamed"),
35  m_writeKey ("cvec")
36 {
37  declareProperty ("CVecKey", m_cvecKey);
38  declareProperty ("WriteKey", m_writeKey);
39 }
40 
41 
46 {
47  ATH_CHECK( m_cvecKey.initialize() );
48  if (!m_writeKey.key().empty())
49  ATH_CHECK( m_writeKey.initialize() );
50  return StatusCode::SUCCESS;
51 }
52 
53 
57 StatusCode xAODTestFilterCVec::execute (const EventContext& ctx) const
58 {
60  const static C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
61 
62 
63  auto vecnew = std::make_unique<CVec>();
64  auto store = std::make_unique<CAuxContainer>();
65  vecnew->setStore (store.get());
66  for (size_t i = 0; i < cvec->size(); i+=2) {
67  vecnew->push_back (new C);
68  *vecnew->back() = *(*cvec)[i];
69  }
70 
71  size_t i = 0;
72  for (C* c : *vecnew) {
73  cEL(*c).toIndexedElement (*vecnew, vecnew->size()-1-i);
74  ++i;
75  }
77  ATH_CHECK( writevec.record(std::move(vecnew), std::move(store)) );
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
87 {
88  return StatusCode::SUCCESS;
89 }
90 
91 
92 } // namespace DMTest
93 
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DMTest::xAODTestFilterCVec::m_writeKey
SG::WriteHandleKey< DMTest::CVec > m_writeKey
Definition: xAODTestFilterCVec.h:64
DMTest::xAODTestFilterCVec::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition: xAODTestFilterCVec.h:63
CAuxContainer.h
Class used for testing xAOD data reading/writing.
DMTest::C_v1
Definition: C_v1.h:29
DMTest::xAODTestFilterCVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestFilterCVec.cxx:45
DMTest::xAODTestFilterCVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestFilterCVec.cxx:57
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
CVec.h
Class used for testing xAOD data reading/writing.
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAODTestFilterCVec.h
Algorithm to test filtering xAOD data.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
C.h
Class used for testing xAOD data reading/writing.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DMTest::xAODTestFilterCVec::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition: xAODTestFilterCVec.cxx:86
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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.
DMTest::xAODTestFilterCVec::xAODTestFilterCVec
xAODTestFilterCVec(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestFilterCVec.cxx:31
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DMTest
Definition: B.h:23