ATLAS Offline Software
Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "ReadData.h"
12 
13 // the user data-class defintions
16 
18 
19 #include "EventInfo/EventID.h"
22 
23 #include <set>
24 
25 using namespace AthPoolEx;
26 
27 //___________________________________________________________________________
28 ReadData::ReadData(const std::string& name, ISvcLocator* pSvcLocator)
29  : AthReentrantAlgorithm(name, pSvcLocator),
30  p_SGinMeta("StoreGateSvc/InputMetaDataStore", name),
31  p_SGmeta("StoreGateSvc/MetaDataStore", name)
32 {
33 }
34 //___________________________________________________________________________
36 }
37 //___________________________________________________________________________
39  ATH_MSG_INFO("in initialize()");
40 
41  // Locate the StoreGateSvc and initialize our local ptr
42  if (!p_SGinMeta.retrieve().isSuccess()) {
43  ATH_MSG_ERROR("Could not find Input MetaData StoreGateSvc");
44  return StatusCode::FAILURE;
45  }
46  if (!p_SGmeta.retrieve().isSuccess()) {
47  ATH_MSG_ERROR("Could not find Tag MetaData StoreGateSvc");
48  return StatusCode::FAILURE;
49  }
50 
52  if (!m_exampleTrackKey.key().empty()) {
54  }
56  return StatusCode::SUCCESS;
57 }
58 //___________________________________________________________________________
59 StatusCode ReadData::execute (const EventContext& ctx) const {
60  ATH_MSG_DEBUG("in execute()");
61 
63  if (p_SGinMeta->retrieve(esi1, esi2).isFailure() || esi1 == esi2) {
64  ATH_MSG_WARNING("Could not find EventStreamInfo");
65  } else {
66  for (; esi1 != esi2; ++esi1) {
67  ATH_MSG_INFO("EventStreamInfo: Number of events = " << esi1->getNumberOfEvents());
68  ATH_MSG_INFO("EventStreamInfo: ItemList:");
69  for (const std::pair<CLID, std::string>& p : esi1->getItemList()) {
70  ATH_MSG_INFO("CLID = " << p.first << ", key = " << p.second);
71  }
72  for (const EventType& et : esi1->getEventTypes()) {
73  ATH_MSG_INFO("EventType: " << et.typeToString());
74  ATH_MSG_INFO("TagInfo: " << et.get_detdescr_tags());
75  }
76  }
77  }
78  const std::string ebcKey = "EventSelector.Counter";
79  if (p_SGmeta->contains<EventBookkeeperCollection>(ebcKey)) {
80  const EventBookkeeperCollection* ebc = nullptr;
81  if (p_SGmeta->retrieve(ebc, ebcKey).isFailure()) {
82  ATH_MSG_FATAL("Could not find EventBookkeeperCollection, key =");
83  return StatusCode::FAILURE;
84  }
85  for (const EventBookkeeper* bk : *ebc) {
86  ATH_MSG_INFO("EventBookkeeper " << bk->getName() << " accepted events: = " << bk->getNAcceptedEvents());
87  }
88  }
89  const std::string ebcInKey = "EventBookkeepers";
90  if (p_SGinMeta->contains<EventBookkeeperCollection>(ebcInKey)) {
91  const EventBookkeeperCollection* ebc = nullptr;
92  if (p_SGinMeta->retrieve(ebc, ebcInKey).isFailure()) {
93  ATH_MSG_FATAL("Could not find EventBookkeeperCollection, key =");
94  return StatusCode::FAILURE;
95  }
96  for (const EventBookkeeper* bk : *ebc) {
97  ATH_MSG_INFO("EventBookkeeper (In) " << bk->getName() << " accepted events: = " << bk->getNAcceptedEvents());
98  }
99  }
100 
102  for (const DataHeaderElement& dhe : *dh) {
103  ATH_MSG_INFO("DataHeader (Event Content) " << dhe.getToken()->toString());
104  }
105  for (std::vector<DataHeaderElement>::const_iterator dhe_p = dh->beginProvenance(); dhe_p != dh->endProvenance(); ++dhe_p) {
106  ATH_MSG_INFO("DataHeader (Provenance) " << dhe_p->getToken()->toString());
107  }
108 
109  // Get the event header, print out event and run number
110  const EventIDBase& eid = ctx.eventID();
111  ATH_MSG_INFO("EventInfo event: " << eid.event_number() << " run: " << eid.run_number());
112  // Get the DataObject, print out its contents
113  ATH_MSG_INFO("Get Smart data ptr 1");
114 
115  if (!m_exampleTrackKey.key().empty()) {
117  if (tracks.isValid()) {
118  for (const ExampleTrack* track : *tracks) {
119  ATH_MSG_INFO("Track pt = " << track->getPT() << " eta = " << track->getEta() << " phi = " << track->getPhi() << " detector = " << track->getDetector());
120  try {
121  double x = track->getElement1()->getX();
122  ATH_MSG_INFO("ElementLink1 = " << x);
123  ATH_MSG_INFO("ElementLink2 = " << track->getElement2()->getX());
124  ATH_MSG_INFO("Link ElementLinkVector = " << track->getElementLinkVector()->size());
125  for (ElementLinkVector<ExampleHitContainer>::const_iterator iter = track->getElementLinkVector()->begin(); iter != track->getElementLinkVector()->end(); ++iter) {
126  ATH_MSG_INFO("Element = " << (**iter) << " : " << (**iter)->getX());
127  }
128  ATH_MSG_INFO("Link Navigable = " << track->getNavigable()->size());
129  for (Navigable<ExampleHitContainer>::object_iter iter = track->getNavigable()->begin(); iter != track->getNavigable()->end(); iter++) {
130  ATH_MSG_INFO("Element = " << (*iter) << " : " << (*iter)->getX());
131  }
132  ATH_MSG_INFO("Link Weighted Navigable = " << track->getWeightedNavigable()->size());
133  for (Navigable<ExampleHitContainer, double>::object_iter iter = track->getWeightedNavigable()->begin(); iter != track->getWeightedNavigable()->end(); iter++) {
134  ATH_MSG_INFO("Element = " << (*iter) << " : " << (*iter)->getX());
135  }
136  } catch (...) {
137  ATH_MSG_WARNING("Could not follow ExampleTrackContainer/MyTracks ElementLinks to ExampleHitContainer/MyHits");
138  }
139  }
140  }
141  else {
142  ATH_MSG_INFO("Could not find ExampleTrackContainer/MyTracks");
143  }
144  }
145 
147  if (hits.isValid()) {
148  for (const ExampleHit* hit : *hits) {
149  ATH_MSG_INFO("Hit x = " << hit->getX() << " y = " << hit->getY() << " z = " << hit->getZ() << " detector = " << hit->getDetector());
150  }
151 
152  if (evtStore()->contains<ExampleHitContainer>("PetersHits")) {
153  ATH_MSG_INFO("Found ExampleHitContainer/PetersHits (alias)");
154  }
155  }
156  else {
157  ATH_MSG_INFO("Could not find ExampleHitContainer/MyHits");
158  }
159 
160  return StatusCode::SUCCESS;
161 }
162 //___________________________________________________________________________
164  ATH_MSG_INFO("in finalize()");
165  return StatusCode::SUCCESS;
166 }
et
Extra patterns decribing particle interation process.
AthPoolEx::ReadData::m_dataHeaderKey
SG::ReadHandleKey< DataHeader > m_dataHeaderKey
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.h:45
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ReadData.h
This file contains the class definition for the ReadData class.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventBookkeeperCollection.h
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
AthPoolEx::ReadData::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx:59
AthPoolEx::ReadData::p_SGmeta
ServiceHandle< StoreGateSvc > p_SGmeta
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.h:44
ExampleTrack
This class provides a dummy track data object for AthenaPool.
Definition: ExampleTrack.h:24
EventBookkeeperCollection
Definition: EventBookkeeperCollection.h:21
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
x
#define x
EventStreamInfo.h
This file contains the class definition for the EventStreamInfo class.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AthPoolEx::ReadData::p_SGinMeta
ServiceHandle< StoreGateSvc > p_SGinMeta
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.h:43
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
AthPoolEx::ReadData::m_exampleTrackKey
SG::ReadHandleKey< ExampleTrackContainer > m_exampleTrackKey
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.h:46
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthPoolEx::ReadData::ReadData
ReadData(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx:28
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
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
AthPoolEx::ReadData::~ReadData
virtual ~ReadData()
Destructor.
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx:35
AthPoolEx::ReadData::finalize
virtual StatusCode finalize() override
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx:163
AthPoolEx::ReadData::m_exampleHitKey
SG::ReadHandleKey< ExampleHitContainer > m_exampleHitKey
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ExampleHit
This class provides a dummy hit data object for AthenaPool.
Definition: ExampleHit.h:24
EventBookkeeper
Definition: EventBookkeeper.h:24
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
AthPoolEx::ReadData::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/src/ReadData.cxx:38
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ElementLinkVector
ElementLinkVector implementation for standalone ROOT.
Definition: AthLinks/ElementLinkVector.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Navigable
Navigable template generalization to handle navigation.
Definition: Navigable.h:93
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ExampleTrackContainer.h
This file contains the class definition for the ExampleTrackContainer class.
AthPoolEx
Definition: PassNoneFilter.h:16
ExampleHitContainer.h
This file contains the class definition for the ExampleHitContainer class.
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
SG::ConstIterator
Definition: SGIterator.h:163