ATLAS Offline Software
SGRead.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SGRead.h"
6 
7 #include "MyDataObj.h"
8 #include "LinkObj.h"
9 #include "Tutorial_ClassDEF.h"
10 
11 #include "GaudiKernel/ISvcLocator.h"
12 
13 #include "AthLinks/DataLink.h"
14 #include "AthLinks/ElementLink.h"
15 
16 #include "StoreGate/StoreGateSvc.h"
17 
18 using namespace SGTutorial;
19 
21 
22 SGRead::SGRead(const std::string& name, ISvcLocator* pSvcLocator) :
23  AthAlgorithm(name, pSvcLocator)
24 {
25 
26  // Declare the properties
27  // Key of the Data Object in the TDS:
28  declareProperty("DataObjKey", m_DataObjKey);
29 
30 }
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33 
35 {
36 
37  ATH_MSG_INFO ("in initialize()");
38 
39  // Print out the key of the data objects
40 
41  ATH_MSG_INFO ("Data Object key: " << m_DataObjKey);
42 
43  StatusCode sc = evtStore().retrieve();
44  if (sc.isFailure())
45  {
46  ATH_MSG_ERROR ("Unable to retrieve pointer to StoreGate Service");
47  return sc;
48  }
49 
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55 
57 {
58 
59  ATH_MSG_INFO ("in execute()");
60 
62  // PART1 Objective:
63  // Retrieve the Data Object "MyDataObj" from SG (which was
64  // registered in SG by the SGWrite algorithm.
65  // Print out the value set in the MyDataObj
67 
68 
70  // PART2 Objective:
71  // Retrieve the Collection of MyElement objects from the SG which was
72  // registered in SG by the SGWrite algorithm.
73  // Iterate over the collection to gain access to MyElement.
74  // Print out each MyElement.
76 
77 
79  // PART3 Objective:
80  // Retrieve LinkObj and dump its content.
81  // LinkObj contains a DataLink to MyDataObj and a DataLink to a MyElement
82  // in a vector. It provides an accessor method myLinkedObj() that returns
83  // a reference to the linked MyDataObj.
84  // Another accessor myLinkedElement() returns a reference to the linked
85  // MyElement.
86  // Verify that the contents (time and id) match with the
87  // direct-dump of MyDataObj in PART1 and MyElement[0] in PART2.
89 
90  return StatusCode::SUCCESS;
91 }
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94 
96 {
97  ATH_MSG_INFO ("in finalize()");
98  return StatusCode::SUCCESS;
99 }
100 
101 
102 
103 
MyDataObj.h
SGRead::m_DataObjKey
std::string m_DataObjKey
Definition: SGRead.h:36
Tutorial_ClassDEF.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SGRead.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SGRead::SGRead
SGRead(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SGRead.cxx:22
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SGRead::finalize
StatusCode finalize()
Definition: SGRead.cxx:95
SGRead::execute
StatusCode execute()
Definition: SGRead.cxx:56
AthAlgorithm
Definition: AthAlgorithm.h:47
SGTutorial
Definition: LinkObj.h:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SGRead::initialize
StatusCode initialize()
Definition: SGRead.cxx:34
LinkObj.h
StoreGateSvc.h