ATLAS Offline Software
xAODTestWriteCInfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
14 #include "xAODTestWriteCInfo.h"
17 #include "AthLinks/ElementLink.h"
18 
19 
20 namespace DMTest {
21 
22 
29  ISvcLocator *pSvcLocator)
30  : AthReentrantAlgorithm (name, pSvcLocator),
31  m_cvecKey ("cvec"),
32  m_cinfoKey ("cinfo")
33 {
34  declareProperty ("Offset", m_offset = 0);
35  declareProperty ("CVecKey", m_cvecKey);
36  declareProperty ("CInfoKey", m_cinfoKey);
37 }
38 
39 
44 {
46  ATH_CHECK( m_cvecKey.initialize() );
47  ATH_CHECK( m_cinfoKey.initialize() );
48  return StatusCode::SUCCESS;
49 }
50 
51 
55 StatusCode xAODTestWriteCInfo::execute (const EventContext& ctx) const
56 {
58  unsigned int count = eventInfo->eventNumber() + 1;
59 
61 
62  auto cinfo = std::make_unique<DMTest::C>();
63  auto info_store = std::make_unique<DMTest::CInfoAuxContainer>();
64  cinfo->setStore (info_store.get());
65 
66  static const C::Accessor<int> anInt2 ("anInt2");
67  static const C::Accessor<ElementLink<DMTest::CVec> > cEL ("cEL");
68 
69  cinfo->setAnInt (count * 1000 + m_offset);
70  cinfo->setAFloat ((float)count * 0.1 + m_offset);
71  anInt2(*cinfo) = count * 2000 + m_offset;
72 
73  if (!cvec->empty()) {
74  cEL(*cinfo).toIndexedElement (*cvec, count % cvec->size());
75  }
76 
78  std::unique_ptr<const DMTest::C> cinfo_c (std::move (cinfo));
79  std::unique_ptr<const DMTest::CInfoAuxContainer> info_store_c (std::move (info_store));
80  if (cinfoH.put (std::move(cinfo_c), std::move(info_store_c)) == nullptr) {
81  ATH_MSG_ERROR ("Can't record CInfo");
82  return StatusCode::FAILURE;
83  }
84 
85  return StatusCode::SUCCESS;
86 }
87 
88 
93 {
94  return StatusCode::SUCCESS;
95 }
96 
97 
98 } // namespace DMTest
99 
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
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::xAODTestWriteCInfo::m_cinfoKey
SG::WriteHandleKey< DMTest::C > m_cinfoKey
Definition: xAODTestWriteCInfo.h:68
DMTest::xAODTestWriteCInfo::m_offset
int m_offset
Definition: xAODTestWriteCInfo.h:65
DMTest::xAODTestWriteCInfo::xAODTestWriteCInfo
xAODTestWriteCInfo(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: xAODTestWriteCInfo.cxx:28
DMTest::xAODTestWriteCInfo::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition: xAODTestWriteCInfo.cxx:92
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DMTest::xAODTestWriteCInfo::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestWriteCInfo.cxx:55
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.
DMTest::xAODTestWriteCInfo::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: xAODTestWriteCInfo.h:66
xAODTestWriteCInfo.h
Algorithm to test writing xAOD classes with auxiliary data (cinfo).
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DMTest::xAODTestWriteCInfo::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition: xAODTestWriteCInfo.cxx:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DMTest::xAODTestWriteCInfo::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition: xAODTestWriteCInfo.h:67
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
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