PropertiesExample
Jump to navigation
Jump to search
Introduction
Setting properties allows the user to steer the Algorithms with help of the jobOptions.py. The advantage of this that you don't need to recompile your algorithms/tool every time you think of a change. Properties are handy too if one wants to set cut-offs, point to different files in CASTOR, use different names for ntuples and trees, and the like.
Accessing StoreGate
To let your Algorithm point to StoreGate, one should first concider two things:
- What kind of DataObject do I want to retrieve? (answer: a DummyTrackCollection)
- What is the key under what StoreGate has recorded it? (answer: "DummyTrackCollection")
So the ExampleAlg should have an instance of the DummyTrackCollection (to store the DummyTracks in): declare this in the header ExampleAlg.h:
class DummyTrackCollection; class StoreGateSvc; class ExampleAlg : public Algorithm{ ... private : DummyTrackCollection* m_tracks; StoreGateSvc* m_storeGate;
In the implementation of ExampleAlg::initialize(), retrieve the StoregateService:
sc=service("StoreGateSvc",m_StoreGate); if (sc.isFailure()) { mLog << MSG::FATAL << "StoreGate service not found !" << endreq; return StatusCode::FAILURE; }
Every event, we want to retrieve the collection of DummyTracks:
StatusCode ExampleAlg::execute(){ StatusCode sc = m_storeGate->retrieve( m_tracks, "DummyTrackCollection" ); }