ATLAS Offline Software
xAODTestWriteCVec.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "xAODTestWriteCVec.h"
17 #include "AthContainers/Accessor.h"
20 #include "AthLinks/ElementLink.h"
21 
22 
23 namespace DMTest {
24 
25 
32  ISvcLocator *pSvcLocator)
33  : AthReentrantAlgorithm (name, pSvcLocator)
34 {
35 }
36 
37 
42 {
43  ATH_CHECK( m_cvecKey.initialize() );
44 
45  if (m_cvecDecorKey.key().empty())
46  m_cvecDecorKey = m_cvecKey.key() + ".dtest";
47  ATH_CHECK( m_cvecDecorKey.initialize() );
48 
49  return StatusCode::SUCCESS;
50 }
51 
52 
56 StatusCode xAODTestWriteCVec::execute (const EventContext& ctx) const
57 {
58  unsigned int count = ctx.eventID().event_number() + 1;
59 
60  auto coll = std::make_unique<DMTest::CVec>();
61  auto store = std::make_unique<DMTest::CAuxContainer>();
62  coll->setStore (store.get());
63 
64  const static SG::Accessor<int> anInt2 ("anInt2");
65  const static SG::Decorator<int> dVar1 ("dVar1");
66  const static SG::Decorator<int> dVar2 ("dVar2");
67  const static SG::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
68 
69  int nent = 10;
70  if (count == 5) nent = 0;
71  for (int i=0; i < nent; i++) {
72  coll->push_back (new DMTest::C);
73  C& c = *coll->back();
74  c.setAnInt (count * 100 + i+1);
75  c.setAFloat (count * 200 + (float)i*0.1);
76 
77  anInt2(c) = count*300 + i+1;
78  dVar1(c) = count*450 + i+1;
79  dVar2(c) = count*750 + i+1;
80  cEL(c).toIndexedElement (*coll, 9-i);
81  }
82 
84  CHECK( cvec.record (std::move(coll), std::move(store)) );
85 
87  for (int i=0; i < nent; i++) {
88  dtest (*(*dtest)[i]) = i+123;
89  }
90 
91  return StatusCode::SUCCESS;
92 }
93 
94 
95 } // namespace DMTest
96 
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
DMTest::xAODTestWriteCVec::xAODTestWriteCVec
xAODTestWriteCVec(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestWriteCVec.cxx:31
SG::Accessor< int >
CAuxContainer.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestWriteCVec::m_cvecDecorKey
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecDecorKey
Definition: xAODTestWriteCVec.h:58
DMTest::C_v1
Definition: C_v1.h:27
xAODTestWriteCVec.h
Algorithm to test writing xAOD classes with auxiliary data (cvec).
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AuxDataOption.h
Hold information about an option setting request.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CVec.h
Class used for testing xAOD data reading/writing.
SG::Decorator< int >
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
C.h
Class used for testing xAOD data reading/writing.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DMTest::xAODTestWriteCVec::m_cvecKey
SG::WriteHandleKey< DMTest::CVec > m_cvecKey
Definition: xAODTestWriteCVec.h:56
DMTest::xAODTestWriteCVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestWriteCVec.cxx:56
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DMTest::xAODTestWriteCVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestWriteCVec.cxx:41
Accessor.h
Helper class to provide type-safe access to aux data.
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.
python.compressB64.c
def c
Definition: compressB64.py:93
Decorator.h
Helper class to provide type-safe access to aux data.
DMTest
Definition: B.h:23