ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestWriteCInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
10
11
12#include "xAODTestWriteCInfo.h"
15#include "AthLinks/ElementLink.h"
16
17
18namespace DMTest {
19
20
27 ISvcLocator *pSvcLocator)
28 : AthReentrantAlgorithm (name, pSvcLocator),
29 m_cvecKey ("cvec"),
30 m_cinfoKey ("cinfo")
31{
32 declareProperty ("Offset", m_offset = 0);
33 declareProperty ("CVecKey", m_cvecKey);
34 declareProperty ("CInfoKey", m_cinfoKey);
35}
36
37
42{
43 ATH_CHECK( m_eventInfoKey.initialize() );
44 ATH_CHECK( m_cvecKey.initialize() );
45 ATH_CHECK( m_cinfoKey.initialize() );
46 return StatusCode::SUCCESS;
47}
48
49
53StatusCode xAODTestWriteCInfo::execute (const EventContext& ctx) const
54{
56 unsigned int count = eventInfo->eventNumber() + 1;
57
59
60 auto cinfo = std::make_unique<DMTest::C>();
61 auto info_store = std::make_unique<DMTest::CInfoAuxContainer>();
62 cinfo->setStore (info_store.get());
63
64 static const C::Accessor<int> anInt2 ("anInt2");
65 static const C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
66
67 cinfo->setAnInt (count * 1000 + m_offset);
68 cinfo->setAFloat ((float)count * 0.1 + m_offset);
69 anInt2(*cinfo) = count * 2000 + m_offset;
70
71 if (!cvec->empty()) {
72 cEL(*cinfo).toIndexedElement (*cvec, count % cvec->size(), ctx);
73 }
74
76 std::unique_ptr<const DMTest::C> cinfo_c (std::move (cinfo));
77 std::unique_ptr<const DMTest::CInfoAuxContainer> info_store_c (std::move (info_store));
78 if (cinfoH.put (std::move(cinfo_c), std::move(info_store_c)) == nullptr) {
79 ATH_MSG_ERROR ("Can't record CInfo");
80 return StatusCode::FAILURE;
81 }
82
83 return StatusCode::SUCCESS;
84}
85
86
91{
92 return StatusCode::SUCCESS;
93}
94
95
96} // namespace DMTest
97
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
xAODTestWriteCInfo(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
SG::WriteHandleKey< DMTest::C > m_cinfoKey
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an 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:148
Definition B.h:23
Algorithm to test writing xAOD classes with auxiliary data (cinfo).