Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Algorithm - an algorithm class which is derived from Gaudi's IAlgorithm base class.  All algorithms must include:  initialize, execute, and finalize methods.

Code Block

class GAUDI_API IAlgorithm : virtual public INamedInterface {
public:  /// InterfaceID  DeclareInterfaceID(IAlgorithm,4,0);  /** The version of the algorithm   */ 
virtual StatusCode initialize() = 0; 
virtuanl StatusCode finalize() = 0;

/** The action to be performed by the algorithm on an event. This method is invoked once per event for top level algorithms by the
application manager.  */ 
virtual StatusCode execute() = 0;

...

JobOptionsSvc - Handles ASCII jobOptions files which allow setting of runtime parameters for all algorithm, services, tools, etc as well as determining the sequence of execution.  Allows for conditional execution based on user-defined conditions.

Code Block

ApplicationMgr.DLLs   += {"GaudiAlg","GaudiAud"};
ApplicationMgr.ExtSvc += {"ChronoStatSvc"};

AuditorSvc.Auditors = {"ChronoAuditor"};

//
// Set up basic event loop:
//
ApplicationMgr.ExtSvc = {"EventSelector/EventSelector" };

EventPersistencySvc.CnvServices = {"EventCnvSvc"};

EventSelector.Input     = "SVC='DbEvtSelector";
EventSelector.PrintFreq = -1;


//
// A structure for the topalg, using sequencer steps:
//
ApplicationMgr.TopAlg = {"Sequencer/Top"};

//
// Define the top sequence loop:
//
Top.Members = {"Sequencer/Digitization",
               "Sequencer/Calibration",
               "Sequencer/Integrity",
               "Sequencer/NtupleMaker",
               "Sequencer/Output"
                };

//
// Needed for EventIntegrityAlg sequence breaking:
//
Top.StopOverride = true;

//
// Digitization sequence: Read in digis from a ROOT file!
//
Digitization.Members +={"digiRootReaderAlg"};

//
// Need 'Rec' in the name to get the alignment:
//
Calibration.Members = {"TkrCalibAlg/TkrReconCalib"};

//
// Using EventIntegrityAlg to decide if we run or skip recon:
//     If the event passes, proceed as normal.
//     If EventIntegrityAlg is BAD, skip recon but output to file.
//
ApplicationMgr.DLLs += {"EventIntegrity"};

Integrity.Members    = {"EventIntegrityAlg",
                        "Sequencer/Filter",
                        "Sequencer/Reconstruction"};

//
// Detector services:
//
ApplicationMgr.DLLs   += {"GlastSvc"};
ApplicationMgr.ExtSvc += {"GlastDetSvc"};

GlastDetSvc.topVolume   = "LAT";
GlastDetSvc.visitorMode = "recon";

MessageSvc - provides logging at prescribed "levels":  DEBUG, INFO, WARNING, ERROR

Code Block

log << MSG::DEBUG << "Hello World!" << endreq; 
log << MSG::INFO << "Hello World!" << endreq; 
log << MSG::WARNING << "Hello World!" << endreq;

...

GlastRandomSvc - can't recall why, but we implemented our own random number service that initializes the seeds of the random number generators for all packages that obtain random numbers.  We desired to have event by event reproducibility (which we didn't achieve)...rather we can reproduce a run.

Toy Example

Code Block

#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/Property.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/AlgFactory.h"
#include "GaudiKernel/DataObject.h"
#include "GaudiKernel/IDataProviderSvc.h"
#include "GaudiKernel/SmartDataPtr.h"
#include "Event/TopLevel/Event.h"
#include "Event/TopLevel/EventModel.h"
/** @class HelloWorld @brief Simple Hello World example Gaudi algorithm.  Prints Hello World with different priority levels. 
$Header$
*/
class HelloWorld : public Algorithm {
public: 
/// Constructor of this form must be provided   
HelloWorld(const std::string& name, ISvcLocator* pSvcLocator)  : Algorithm(name, pSvcLocator) { };  
/// Three mandatory member functions of any Gaudi algorithm 
StatusCode initialize() { return StatusCode::SUCCESS; }; 
StatusCode execute(); 
StatusCode finalize() { return StatusCode::SUCCESS; };

private:
};
// Static Factory declaration
static const AlgFactory<HelloWorld>  Factory;
const IAlgFactory& HelloWorldFactory = Factory;

StatusCode HelloWorld::execute() { 
  MsgStream         log( msgSvc(), name() ); 
  static int eventCounter = 0; 

  // Sending informational log message
  log << MSG::INFO << "Hello World!" << endreq;

  // Access the Event TDS and retrieve the top-level "Event" object
  SmartDataPtr<Event::EventHeader> evtTds(eventSvc(), EventModel::EventHeader);
  if (evtTds) {    
    evtTds->setRun(10);    
    evtTds->setEvent(eventCounter++);  
    log << MSG::INFO << "<RunId, EvtId> = <" << evtTds->run() << ", " << evtTds->event() << ">" << endreq;
  } 
  return StatusCode::SUCCESS;
}

...

Some words from Fermi's Online Workbook.

Gaudi Home

Recent Developments reported to CHEP 2009 by Gaudi team