ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestWriteCVec.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
12#include "xAODTestWriteCVec.h"
20#include "AthLinks/ElementLink.h"
21
22
23namespace DMTest {
24
25
31xAODTestWriteCVec::xAODTestWriteCVec (const std::string &name,
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
56StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
Hold information about an option setting request.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Helper class to provide type-safe access to aux data.
#define CHECK(...)
Evaluate an expression and check for errors.
Helper class to provide type-safe access to aux data.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecDecorKey
SG::WriteHandleKey< DMTest::CVec > m_cvecKey
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
xAODTestWriteCVec(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Helper class to provide type-safe access to aux data.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Definition B.h:23
C_v1 C
Definition C.h:26
Algorithm to test writing xAOD classes with auxiliary data (cvec).