Difference between revisions of "PropertiesExample"

From Atlas Wiki
Jump to navigation Jump to search
Line 18: Line 18:
 
</pre>
 
</pre>
  
In the source file, retrieve the StoregateService and retrieve the collection:
+
In the implementation of '''ExampleAlg::initialize()''', retrieve the StoregateService:
 
<pre>
 
<pre>
 
   sc=service("StoreGateSvc",m_StoreGate);
 
   sc=service("StoreGateSvc",m_StoreGate);
Line 24: Line 24:
 
     mLog << MSG::FATAL << "StoreGate service not found !" << endreq;
 
     mLog << MSG::FATAL << "StoreGate service not found !" << endreq;
 
     return StatusCode::FAILURE;
 
     return StatusCode::FAILURE;
 +
  }
 +
</pre>
 +
 +
Every event, we want to retrieve the collection of DummyTracks:
 +
<pre>
 +
  StatusCode ExampleAlg::execute(){
 +
    StatusCode sc = m_storeGate->retrieve( m_tracks, "DummyTrackCollection" );
 
   }  
 
   }  
 
</pre>
 
</pre>

Revision as of 15:46, 25 October 2006

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" );
  }