ATLAS Offline Software
AthViews/src_dflow/DFlowAlg2.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2020 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 
12 // AthExStoreGateExample includes
13 #include "DFlowAlg2.h"
14 
15 // STL includes
16 
17 // FrameWork includes
18 #include "Gaudi/Property.h"
19 #include "StoreGate/ReadHandle.h"
20 #include "StoreGate/WriteHandle.h"
21 #include "StoreGate/UpdateHandle.h"
22 
23 namespace AthViews {
24 
26 // Public methods:
28 
29 // Constructors
31 DFlowAlg2::DFlowAlg2( const std::string& name,
32  ISvcLocator* pSvcLocator ) :
33  ::AthAlgorithm( name, pSvcLocator ),
34  m_r_int( "dflow_int" ),
35  m_ints( "dflow_ints" ),
36  m_testUpdate( "testUpdate" )
37 {
38  //
39  // Property declaration
40  //
41  //declareProperty( "Property", m_nProperty );
42 
43  declareProperty( "RIntFlow", m_r_int, "Data flow of int" );
44 
45  declareProperty( "IntsFlow", m_ints, "Data flow of integers" );
46 
47  declareProperty( "TestUpdate", m_testUpdate, "Test update handle" );
48 }
49 
50 // Destructor
53 {}
54 
55 // Athena Algorithm's Hooks
58 {
59  ATH_MSG_INFO ("Initializing " << name() << "...");
60 
62  CHECK( m_ints.initialize() );
64 
65  return StatusCode::SUCCESS;
66 }
67 
69 {
70  ATH_MSG_INFO ("Finalizing " << name() << "...");
71 
72  return StatusCode::SUCCESS;
73 }
74 
76 {
77  ATH_MSG_DEBUG ("Executing " << name() << "...");
78 
79  const EventContext& ctx = getContext();
80 
81  SG::ReadHandle< int > inputHandle( m_r_int, ctx );
82  ATH_MSG_INFO("================================");
83  ATH_MSG_INFO("myint r-handle...");
84  ATH_MSG_INFO("name: [" << inputHandle.name() << "]");
85  ATH_MSG_INFO("store [" << inputHandle.store() << "]");
86  ATH_MSG_INFO("clid: [" << inputHandle.clid() << "]");
87 
88  ATH_MSG_INFO("ptr: " << inputHandle.cptr());
89  if ( inputHandle.isValid() )
90  {
91  ATH_MSG_INFO("val: " << *( inputHandle.cptr() ) );
92  }
93 
94  SG::WriteHandle< std::vector< int > > outputHandle( m_ints, ctx );
95  ATH_MSG_INFO("ints w-handle...");
96  ATH_CHECK( outputHandle.record( std::make_unique< std::vector< int > >() ) );
97  outputHandle->push_back( 10 );
98 
99  if ( inputHandle.isValid() )
100  {
101  outputHandle->push_back( *inputHandle );
102  }
103 
104  ATH_MSG_INFO( "size:" << outputHandle->size() );
105  for ( int i = 0, imax = outputHandle->size(); i != imax; ++i )
106  {
107  ATH_MSG_INFO( "val[" << i << "]= " << outputHandle->at( i ) );
108  }
109 
110  // Test update handles
112  ATH_MSG_INFO( "Update handle before: " << testUpdate->val() );
113  testUpdate->val( 1234 );
114  ATH_MSG_INFO( "Update handle after: " << testUpdate->val() );
115  *testUpdate = 4321;
116  ATH_MSG_INFO( "Update handle new: " << testUpdate->val() );
117 
118  return StatusCode::SUCCESS;
119 }
120 
121 } //> end namespace AthViews
AthViews::DFlowAlg2::execute
virtual StatusCode execute()
Definition: AthViews/src_dflow/DFlowAlg2.cxx:75
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthViews::DFlowAlg2::m_ints
SG::WriteHandleKey< std::vector< int > > m_ints
Definition: AthViews/src_dflow/DFlowAlg2.h:63
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
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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.
AthViews::DFlowAlg2::initialize
virtual StatusCode initialize()
Definition: AthViews/src_dflow/DFlowAlg2.cxx:57
AthViews::DFlowAlg2::DFlowAlg2
DFlowAlg2()
Default constructor:
WriteHandle.h
Handle class for recording to StoreGate.
DFlowAlg2.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
AthViews::DFlowAlg2::finalize
virtual StatusCode finalize()
Definition: AthViews/src_dflow/DFlowAlg2.cxx:68
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
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:376
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthViews
Definition: ViewDataVerifier.cxx:18
SG::UpdateHandle
Definition: UpdateHandle.h:94
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
AthViews::DFlowAlg2::~DFlowAlg2
virtual ~DFlowAlg2()
Destructor:
Definition: AthViews/src_dflow/DFlowAlg2.cxx:52
UpdateHandle.h
Handle class for modifying an existing object in StoreGate.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
HiveDataObj::val
void val(int i)
Definition: HiveDataObj.h:22
AthViews::DFlowAlg2::m_r_int
SG::ReadHandleKey< int > m_r_int
Containers.
Definition: AthViews/src_dflow/DFlowAlg2.h:62
ReadHandle.h
Handle class for reading from StoreGate.
AthViews::DFlowAlg2::m_testUpdate
SG::UpdateHandleKey< HiveDataObj > m_testUpdate
Definition: AthViews/src_dflow/DFlowAlg2.h:64