ATLAS Offline Software
AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.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 // DFlowAlg2.cxx
8 // Implementation file for class DFlowAlg2
9 // Author: S.Binet<binet@cern.ch>
11 #undef NDEBUG
12 
13 // AthExStoreGateExample includes
14 #include "DFlowAlg2.h"
15 
16 // STL includes
17 
18 // FrameWork includes
19 #include "Gaudi/Property.h"
20 #include "StoreGate/ReadHandle.h"
21 #include "StoreGate/WriteHandle.h"
22 
23 namespace AthEx {
24 
25 
26 DFlowAlg2::DFlowAlg2( const std::string& name,
27  ISvcLocator* pSvcLocator ) :
28  ::AthReentrantAlgorithm( name, pSvcLocator )
29 {
30 }
31 
32 // Destructor
35 {}
36 
37 // Athena Algorithm's Hooks
40 {
41  ATH_MSG_INFO ("Initializing " << name() << "...");
45 
46  return StatusCode::SUCCESS;
47 }
48 
50 {
51  ATH_MSG_INFO ("Finalizing " << name() << "...");
52 
53  return StatusCode::SUCCESS;
54 }
55 
56 StatusCode DFlowAlg2::execute (const EventContext& ctx) const
57 {
58  ATH_MSG_DEBUG ("Executing " << name() << "...");
59  ATH_MSG_INFO("================================");
60  ATH_MSG_INFO("myint r-handle...");
61  SG::ReadHandle<int> r_int (m_r_int, ctx);
62  ATH_MSG_INFO("name: [" << r_int.name() << "]");
63  ATH_MSG_INFO("store [" << r_int.store() << "]");
64  ATH_MSG_INFO("clid: [" << r_int.clid() << "]");
65 
66  ATH_MSG_INFO("ptr: " << r_int.cptr());
67  if (r_int.isValid()) {
68  ATH_MSG_INFO("val: " << *(r_int.cptr()));
69  }
70  SG::WriteHandle<int> w_int (m_w_int, ctx);
71  ATH_MSG_INFO("myint w-handle...");
72  ATH_MSG_INFO("name: [" << w_int.name() << "]");
73  ATH_MSG_INFO("store [" << w_int.store() << "]");
74  ATH_MSG_INFO("clid: [" << w_int.clid() << "]");
75 
76  ATH_CHECK( w_int.record (std::make_unique<int> (*r_int + 1000)) );
77 
78  ATH_MSG_INFO("val: " << *w_int);
79  ATH_MSG_INFO("cptr: " << w_int.cptr());
80 
81  ATH_MSG_INFO("ints w-handle...");
83  ATH_CHECK( ints.record (std::make_unique<std::vector<int> >()) );
84  ints->push_back(10);
85  if (r_int.isValid()) ints->push_back(*r_int);
86  ATH_MSG_INFO("size:" << ints->size());
87  for (int i = 0, imax = ints->size();
88  i!=imax;
89  ++i) {
90  ATH_MSG_INFO("val[" << i << "]= " << ints->at(i));
91  }
92  return StatusCode::SUCCESS;
93 }
94 
95 } //> end namespace AthEx
AthEx::DFlowAlg2::initialize
virtual StatusCode initialize() override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx:39
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
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::DFlowAlg2::m_w_int
SG::WriteHandleKey< int > m_w_int
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.h:45
SG::WriteHandle::cptr
const_pointer_type cptr() const
Dereference the pointer.
AthEx::DFlowAlg2::m_r_int
SG::ReadHandleKey< int > m_r_int
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.h:43
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
AthEx::DFlowAlg2::~DFlowAlg2
virtual ~DFlowAlg2()
Destructor:
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx:34
DFlowAlg2.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
AthEx::DFlowAlg2::finalize
virtual StatusCode finalize() override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx:49
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
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
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
AthEx::DFlowAlg2::DFlowAlg2
DFlowAlg2()=delete
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthEx::DFlowAlg2::m_ints
SG::WriteHandleKey< std::vector< int > > m_ints
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.h:47
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::DFlowAlg2::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: AthenaExamples/AthExStoreGateExample/src_dflow/DFlowAlg2.cxx:56
ReadHandle.h
Handle class for reading from StoreGate.