ATLAS Offline Software
AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // DFlowAlg1.cxx
8 // Implementation file for class DFlowAlg1
9 // Author: S.Binet<binet@cern.ch>
11 #undef NDEBUG
12 
13 // AthExStoreGateExample includes
14 #include "DFlowAlg1.h"
15 
16 // STL includes
17 
18 // FrameWork includes
19 #include "Gaudi/Property.h"
22 
23 namespace AthEx {
24 
26 // Public methods:
28 
29 // Constructors
31 DFlowAlg1::DFlowAlg1( const std::string& name,
32  ISvcLocator* pSvcLocator ) :
33  ::AthReentrantAlgorithm( name, pSvcLocator )
34 {
35 }
36 
37 // Destructor
40 {}
41 
42 // Athena Algorithm's Hooks
45 {
46  ATH_MSG_INFO ("Initializing " << name() << "...");
49 
50  return StatusCode::SUCCESS;
51 }
52 
54 {
55  ATH_MSG_INFO ("Finalizing " << name() << "...");
56 
57  return StatusCode::SUCCESS;
58 }
59 
60 StatusCode DFlowAlg1::execute (const EventContext& ctx) const
61 {
62  ATH_MSG_DEBUG ("Executing " << name() << "...");
63 
65  if (!r_evtInfo.isValid()) {
66  ATH_MSG_ERROR("Could not get the EventInfo object. Going to next event");
67  return StatusCode::RECOVERABLE;
68  }
69  ATH_MSG_INFO("evtinfo handle...");
70  ATH_MSG_INFO("name: [" << r_evtInfo.name() << "]");
71  ATH_MSG_INFO("store [" << r_evtInfo.store() << "]");
72  ATH_MSG_INFO("clid: [" << r_evtInfo.clid() << "]");
73  ATH_MSG_INFO("ei: " << *r_evtInfo);
74  ATH_MSG_INFO("retrieving event-info...");
75  unsigned int runnbr = r_evtInfo->runNumber();
76  ATH_MSG_INFO("evt-info.runnbr: " << runnbr);
77  ATH_MSG_INFO("evt-info.evtnbr: " << r_evtInfo->eventNumber());
78 
79  ATH_MSG_INFO("myint handle...");
80  SG::WriteHandle<int> w_int (m_w_int, ctx);
81  ATH_MSG_INFO("name: [" << w_int.name() << "]");
82  ATH_MSG_INFO("store [" << w_int.store() << "]");
83  ATH_MSG_INFO("clid: [" << w_int.clid() << "]");
84 
85  ATH_CHECK( w_int.record (std::make_unique<int>(r_evtInfo->eventNumber())) );
86 
87  //redundant check as op = would throw if w_int was not valid (e.g. because if clid/key combo was duplicated)
88  if (w_int.isValid()) {
89  ATH_MSG_INFO("ptr: " << w_int.cptr());
90  ATH_MSG_INFO("val: " << *w_int);
91 
92  ATH_MSG_INFO("modify myint by value...");
93  *w_int = r_evtInfo->eventNumber() + 20;
94 
95  ATH_MSG_INFO("ptr: " << w_int.cptr());
96  ATH_MSG_INFO("val: " << *w_int);
97  }
98  return StatusCode::SUCCESS;
99 }
100 
101 } //> end namespace AthEx
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::VarHandleBase::clid
CLID clid() const
Return the class ID for the referenced object.
AthEx::DFlowAlg1::m_r_evtInfo
SG::ReadHandleKey< xAOD::EventInfo > m_r_evtInfo
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.h:47
SG::WriteHandle::cptr
const_pointer_type cptr() const
Dereference the pointer.
DFlowAlg1.h
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthEx::DFlowAlg1::m_w_int
SG::WriteHandleKey< int > m_w_int
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.h:49
AthEx::DFlowAlg1::DFlowAlg1
DFlowAlg1()=delete
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthEx::DFlowAlg1::finalize
virtual StatusCode finalize() override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx:53
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthEx
Definition: Hist.h:25
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:379
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthEx::DFlowAlg1::~DFlowAlg1
virtual ~DFlowAlg1()
Destructor:
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx:39
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthEx::DFlowAlg1::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx:60
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.
AthEx::DFlowAlg1::initialize
virtual StatusCode initialize() override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg1.cxx:44