Gaudi Framework, version v21r11

Home   Generated: 30 Sep 2010

Algorithm Class Reference

Base class from which all concrete algorithm classes should be derived. More...

#include <GaudiKernel/Algorithm.h>

Inheritance diagram for Algorithm:
[legend]
Collaboration diagram for Algorithm:
[legend]

List of all members.

Public Member Functions

 Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
 Constructor.
virtual ~Algorithm ()
 Destructor.
virtual StatusCode sysStart ()
 Reinitialization method invoked by the framework.
virtual StatusCode sysInitialize ()
 Initialization method invoked by the framework.
virtual StatusCode sysReinitialize ()
 Reinitialization method invoked by the framework.
virtual StatusCode sysRestart ()
 Restart method invoked by the framework.
virtual StatusCode sysExecute ()
 The actions to be performed by the algorithm on an event.
virtual StatusCode sysStop ()
 System stop.
virtual StatusCode sysFinalize ()
 System finalization.
virtual StatusCode sysBeginRun ()
 beginRun method invoked by the framework.
virtual StatusCode sysEndRun ()
 endRun method invoked by the framework.
virtual const std::stringname () const
 The identifying name of the algorithm object.
virtual const std::stringversion () const
virtual StatusCode configure ()
 Dummy implementation of IStateful::configure() method.
virtual StatusCode terminate ()
 Dummy implementation of IStateful::terminate() method.
virtual StatusCode initialize ()
 the default (empty) implementation of IStateful::initialize() method
virtual StatusCode start ()
 the default (empty) implementation of IStateful::start() method
virtual StatusCode stop ()
 the default (empty) implementation of IStateful::stop() method
virtual StatusCode finalize ()
 the default (empty) implementation of IStateful::finalize() method
virtual StatusCode reinitialize ()
 the default (empty) implementation of IStateful::reinitialize() method
virtual StatusCode restart ()
 the default (empty) implementation of IStateful::restart() method
virtual bool isExecuted () const
 Has this algorithm been executed since the last reset?
virtual void setExecuted (bool state)
 Set the executed flag to the specified state.
virtual void resetExecuted ()
 Reset the executed state of the Algorithm for the duration of the current event.
virtual StatusCode beginRun ()
 Algorithm begin run.
virtual StatusCode endRun ()
 Algorithm end run. This method is called at the end of the event loop.
virtual Gaudi::StateMachine::State FSMState () const
 returns the current state of the algorithm
virtual Gaudi::StateMachine::State targetFSMState () const
 returns the state the algorithm will be in after the ongoing transition
virtual bool isEnabled () const
 Is this algorithm enabled or disabled?
virtual bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event?
virtual void setFilterPassed (bool state)
 Set the filter passed flag to the specified state.
template<class T>
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
template<class T>
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name").
void setOutputLevel (int level)
 Set the output level for current algorithm.
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present.
SmartIF< IChronoStatSvc > & chronoStatService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service.
SmartIF< IDataProviderSvc > & detDataService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service.
SmartIF< IConversionSvc > & detDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service.
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc
SmartIF< IDataProviderSvc > & eventDataService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service.
SmartIF< IConversionSvc > & eventDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service.
SmartIF< IHistogramSvc > & histogramDataService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
SmartIF< IMessageSvc > & messageService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service.
SmartIF< INTupleSvc > & ntupleService () const
 Obsoleted name, kept due to the backwards compatibility.
SmartIF< IRndmGenSvc > & randSvc () const
 AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service.
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service
SmartIF< ISvcLocator > & serviceLocator () const
 The standard service locator.
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator
bool registerContext () const
 register for Algorithm Context Service?
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
 Create a sub algorithm.
std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
virtual StatusCode setProperty (const Property &p)
 Implementation of IProperty::setProperty.
virtual StatusCode setProperty (const std::string &s)
 Implementation of IProperty::setProperty.
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Implementation of IProperty::setProperty.
virtual StatusCode getProperty (Property *p) const
 Implementation of IProperty::getProperty.
virtual const PropertygetProperty (const std::string &name) const
 Implementation of IProperty::getProperty.
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Implementation of IProperty::getProperty.
virtual const std::vector
< Property * > & 
getProperties () const
 Implementation of IProperty::getProperties.
StatusCode setProperties ()
 Set the algorithm's properties.
template<class T>
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service.
template<class T>
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information.
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case).
template<class TYPE>
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value

Protected Member Functions

bool isInitialized () const
 Has the Algorithm already been initialized?
bool isFinalized () const
 Has the Algorithm already been finalized?
int outputLevel () const
 retrieve the Algorithm output level
IntegerPropertyoutputLevelProperty ()
 Accessor for the Message level property.
void initOutputLevel (Property &prop)
 callback for output level property

Private Member Functions

StatusCode service_i (const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
 implementation of service method
StatusCode service_i (const std::string &svcType, const std::string &svcName, const InterfaceID &iid, void **ppSvc) const
 Algorithm (const Algorithm &a)
 Private Copy constructor: NO COPY ALLOWED.
Algorithmoperator= (const Algorithm &rhs)
 Private assignment operator: NO ASSIGNMENT ALLOWED.

Private Attributes

std::string m_name
 Algorithm's name for identification.
std::string m_version
 Algorithm's version.
std::vector< Algorithm * > * m_subAlgms
 Sub algorithms.
SmartIF< IMessageSvcm_MS
 Message service.
SmartIF< IDataProviderSvcm_EDS
 Event data service.
SmartIF< IConversionSvcm_ECS
 Event conversion service.
SmartIF< IDataProviderSvcm_DDS
 Detector data service.
SmartIF< IConversionSvcm_DCS
 Detector conversion service.
SmartIF< IHistogramSvcm_HDS
 Histogram data service.
SmartIF< INTupleSvcm_NTS
 N tuple service.
SmartIF< IChronoStatSvcm_CSS
 Chrono & Stat Service.
SmartIF< IRndmGenSvcm_RGS
 Random Number Generator Service.
SmartIF< IExceptionSvcm_EXS
 Exception Handler Service.
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
SmartIF< IToolSvcm_ptoolSvc
 ToolSvc Service.
SmartIF< IMonitorSvcm_pMonitorSvc
 Online Monitoring Service.
SmartIF< IAlgContextSvcm_contextSvc
 Algorithm Context Service.
bool m_registerContext
 flag to register for Algorithm Context Service
std::string m_monitorSvcName
 Name to use for Monitor Service.
SmartIF< ISvcLocatorm_pSvcLocator
 Pointer to service locator service.
PropertyMgrm_propertyMgr
 For management of properties.
IntegerProperty m_outputLevel
 Algorithm output level.
int m_errorMax
 Algorithm Max number of errors.
int m_errorCount
 Algorithm error counter.
BooleanProperty m_auditInit
 global flag for auditors
bool m_auditorInitialize
 flag for auditors in "initialize()"
bool m_auditorReinitialize
 flag for auditors in "Reinitialize()"
bool m_auditorRestart
 flag for auditors in "Restart()"
bool m_auditorExecute
 flag for auditors in "execute()"
bool m_auditorFinalize
 flag for auditors in "finalize()"
bool m_auditorBeginRun
 flag for auditors in "beginRun()"
bool m_auditorEndRun
 flag for auditors in "endRun()"
bool m_auditorStart
 flag for auditors in "initialize()"
bool m_auditorStop
 flag for auditors in "Reinitialize()"
bool m_filterPassed
 Filter passed flag.
bool m_isEnabled
 Algorithm is enabled flag.
bool m_isExecuted
 Algorithm is executed flag.
Gaudi::StateMachine::State m_state
 Algorithm has been initialized flag.
Gaudi::StateMachine::State m_targetState
 Algorithm has been initialized flag.
bool m_isFinalized
 Algorithm has been finalized flag.


Detailed Description

Base class from which all concrete algorithm classes should be derived.

In order for a concrete algorithm class to do anything useful the methods initialize(), execute() and finalize() should be overridden.

The base class provides utility methods for accessing standard services (event data service etc.); for declaring properties which may be configured by the job options service; and for creating sub algorithms. The only base class functionality which may be used in the constructor of a concrete algorithm is the declaration of member variables as properties. All other functionality, i.e. the use of services and the creation of sub-algorithms, may be used only in initialize() and afterwards (see the Gaudi user guide).

Author:
Paul Maley

Pere Mato

David Quarrie

Date:
1998

Definition at line 62 of file Algorithm.h.


Constructor & Destructor Documentation

Algorithm::Algorithm ( const std::string name,
ISvcLocator svcloc,
const std::string version = PACKAGE_VERSION 
)

Constructor.

Parameters:
name The algorithm object's name
svcloc A pointer to a service location service

Definition at line 29 of file Algorithm.cpp.

00031   : m_name(name),
00032     m_version(version),
00033     m_registerContext ( false ) ,
00034     m_pSvcLocator(pSvcLocator),
00035     m_filterPassed(true),
00036     m_isEnabled(true),
00037     m_isExecuted(false),
00038     m_state(Gaudi::StateMachine::CONFIGURED),
00039     m_targetState(Gaudi::StateMachine::CONFIGURED)
00040 {
00041   m_propertyMgr = new PropertyMgr();
00042   m_subAlgms = new std::vector<Algorithm *>();
00043 
00044   // Declare common Algorithm properties with their defaults
00045   declareProperty( "OutputLevel",        m_outputLevel = MSG::NIL);
00046   declareProperty( "Enable",             m_isEnabled = true);
00047   declareProperty( "ErrorMax",           m_errorMax  = 1);
00048   declareProperty( "ErrorCount",         m_errorCount = 0);
00049   // Auditor monitoring properties
00050 
00051   // Get the default setting for service auditing from the AppMgr
00052   declareProperty( "AuditAlgorithms", m_auditInit );
00053 
00054   bool audit(false);
00055   SmartIF<IProperty> appMgr(serviceLocator()->service("ApplicationMgr"));
00056   if (appMgr.isValid()) {
00057     const Property& prop = appMgr->getProperty("AuditAlgorithms");
00058     Property &pr = const_cast<Property&>(prop);
00059     if (m_name != "IncidentSvc") {
00060       setProperty( pr ).ignore();
00061     }
00062     audit = m_auditInit.value();
00063   }
00064 
00065   declareProperty( "AuditInitialize"  , m_auditorInitialize   = audit ) ;
00066   declareProperty( "AuditReinitialize", m_auditorReinitialize = audit ) ;
00067   declareProperty( "AuditRestart"     , m_auditorRestart      = audit ) ;
00068   declareProperty( "AuditExecute"     , m_auditorExecute      = audit ) ;
00069   declareProperty( "AuditFinalize"    , m_auditorFinalize     = audit ) ;
00070   declareProperty( "AuditBeginRun"    , m_auditorBeginRun     = audit ) ;
00071   declareProperty( "AuditEndRun"      , m_auditorEndRun       = audit ) ;
00072   declareProperty( "AuditStart"       , m_auditorStart        = audit ) ;
00073   declareProperty( "AuditStop"        , m_auditorStop         = audit ) ;
00074 
00075   declareProperty( "MonitorService"   , m_monitorSvcName      = "MonitorSvc" );
00076 
00077   declareProperty
00078     ( "RegisterForContextService" ,
00079       m_registerContext  ,
00080       "The flag to enforce the registration for Algorithm Context Service") ;
00081   
00082   // update handlers.
00083   m_outputLevel.declareUpdateHandler(&Algorithm::initOutputLevel, this);
00084 
00085 }

Algorithm::~Algorithm (  )  [virtual]

Destructor.

Definition at line 88 of file Algorithm.cpp.

00088                       {
00089   delete m_subAlgms;
00090   delete m_propertyMgr;
00091 }

Algorithm::Algorithm ( const Algorithm a  )  [private]

Private Copy constructor: NO COPY ALLOWED.


Member Function Documentation

StatusCode Algorithm::sysStart (  )  [virtual]

Reinitialization method invoked by the framework.

This method is responsible for any reinitialization required by the framework itself. It will in turn invoke the reinitialize() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 183 of file Algorithm.cpp.

00183                                {
00184 
00185   // Bypass the startup if already running or disabled.
00186   if ( Gaudi::StateMachine::RUNNING == FSMState() ||
00187        !isEnabled() ) return StatusCode::SUCCESS;
00188 
00189   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
00190 
00191   // TODO: (MCl) where shoud we do this? initialize or start?
00192   // Reset Error count
00193   m_errorCount = 0;
00194 
00195   // lock the context service 
00196   Gaudi::Utils::AlgContext cnt
00197     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00198   
00199   StatusCode sc(StatusCode::FAILURE);
00200   // Invoke start() method of the derived class inside a try/catch clause
00201   try 
00202   {
00203     { // limit the scope of the guard
00204       Gaudi::Guards::AuditorGuard guard
00205         (this,
00206          // check if we want to audit the initialize
00207          (m_auditorStart) ? auditorSvc().get() : 0,
00208          IAuditor::Start);
00209       // Invoke the start() method of the derived class
00210       sc = start();
00211     }
00212     if( sc.isSuccess() ) {
00213 
00214       // Now start any sub-algorithms
00215       std::vector<Algorithm *>::iterator it;
00216       bool fail(false);
00217       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00218         if ((*it)->sysStart().isFailure()) fail = true;
00219       }
00220       if( fail ) {
00221         sc = StatusCode::FAILURE;
00222         MsgStream log ( msgSvc() , name() );
00223         log << MSG::ERROR << " Error starting one or several sub-algorithms"
00224             << endmsg;
00225       } else {
00226         // Update the state.
00227         m_state = m_targetState;
00228       }
00229     }
00230   }
00231   catch ( const GaudiException& Exception ) 
00232   {
00233     MsgStream log ( msgSvc() , name() );
00234     log << MSG::FATAL << "in sysStart(): exception with tag=" << Exception.tag()
00235         << " is caught" << endmsg;
00236     log << MSG::ERROR << Exception << endmsg;
00237     Stat stat( chronoSvc() , Exception.tag() );
00238     sc = StatusCode::FAILURE;
00239   }
00240   catch( const std::exception& Exception ) 
00241   {
00242     MsgStream log ( msgSvc() , name() );
00243     log << MSG::FATAL << "in sysStart(): standard std::exception is caught" << endmsg;
00244     log << MSG::ERROR << Exception.what()  << endmsg;
00245     Stat stat( chronoSvc() , "*std::exception*" );
00246     sc = StatusCode::FAILURE;
00247   }
00248   catch(...) 
00249   {
00250     MsgStream log ( msgSvc() , name() );
00251     log << MSG::FATAL << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
00252     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00253     sc = StatusCode::FAILURE;
00254   }
00255 
00256   return sc;
00257 }

StatusCode Algorithm::sysInitialize (  )  [virtual]

Initialization method invoked by the framework.

This method is responsible for any bookkeeping of initialization required by the framework itself. It will in turn invoke the initialize() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 94 of file Algorithm.cpp.

00094                                     {
00095 
00096   // Bypass the initialization if the algorithm
00097   // has already been initialized.
00098   if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
00099 
00100   // Set the Algorithm's properties
00101   StatusCode sc = setProperties();
00102   if( sc.isFailure() ) return StatusCode::FAILURE;
00103 
00104   // Bypass the initialization if the algorithm is disabled.
00105   // Need to do this after setProperties.
00106   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
00107 
00108   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);
00109 
00110   // Check current outputLevel to evetually inform the MessagsSvc
00111   //if( m_outputLevel != MSG::NIL ) {
00112   setOutputLevel( m_outputLevel );
00113   //}
00114 
00115   // TODO: (MCl) where shoud we do this? initialize or start?
00116   // Reset Error count
00117   //m_errorCount = 0;
00118   
00119   // lock the context service 
00120   Gaudi::Utils::AlgContext cnt
00121     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00122   
00123   // Invoke initialize() method of the derived class inside a try/catch clause
00124   try {
00125     
00126     { // limit the scope of the guard
00127       Gaudi::Guards::AuditorGuard guard
00128         ( this,
00129           // check if we want to audit the initialize
00130           (m_auditorInitialize) ? auditorSvc().get() : 0,
00131           IAuditor::Initialize);
00132       // Invoke the initialize() method of the derived class
00133       sc = initialize();
00134     }
00135     if( sc.isSuccess() ) {
00136 
00137       // Now initialize care of any sub-algorithms
00138       std::vector<Algorithm *>::iterator it;
00139       bool fail(false);
00140       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00141         if ((*it)->sysInitialize().isFailure()) fail = true;
00142       }
00143       if( fail ) {
00144         sc = StatusCode::FAILURE;
00145         MsgStream log ( msgSvc() , name() );
00146         log << MSG::ERROR << " Error initializing one or several sub-algorithms"
00147             << endmsg;
00148       } else {
00149         // Update the state.
00150         m_state = m_targetState;
00151       }
00152     }
00153   }
00154   catch ( const GaudiException& Exception )  
00155   {
00156     MsgStream log ( msgSvc() , name() ) ;
00157     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00158         << " is caught " << endmsg;
00159     log << MSG::ERROR << Exception  << endmsg;
00160     Stat stat( chronoSvc() , Exception.tag() );
00161     sc = StatusCode::FAILURE;
00162   }
00163   catch( const std::exception& Exception ) 
00164   {
00165     MsgStream log ( msgSvc() , name() ) ;
00166     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
00167     log << MSG::ERROR << Exception.what()  << endmsg;
00168     Stat stat( chronoSvc() , "*std::exception*" );
00169     sc = StatusCode::FAILURE;
00170   }
00171   catch(...) 
00172   {
00173     MsgStream log ( msgSvc() , name() ) ;
00174     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
00175     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00176     sc = StatusCode::FAILURE;
00177   }
00178 
00179   return sc;
00180 }

StatusCode Algorithm::sysReinitialize (  )  [virtual]

Reinitialization method invoked by the framework.

This method is responsible for any reinitialization required by the framework itself. It will in turn invoke the reinitialize() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 260 of file Algorithm.cpp.

00260                                       {
00261 
00262   // Bypass the initialization if the algorithm is disabled.
00263   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
00264 
00265   // Check that the current status is the correct one.
00266   if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
00267     MsgStream log ( msgSvc() , name() );
00268     log << MSG::ERROR
00269         << "sysReinitialize(): cannot reinitialize algorithm not initialized"
00270         << endmsg;
00271     return StatusCode::FAILURE;
00272   }
00273 
00274   // Check current outputLevel to evetually inform the MessagsSvc
00275   //if( m_outputLevel != MSG::NIL ) {
00276   setOutputLevel( m_outputLevel );
00277   //}
00278 
00279   // Reset Error count
00280   // m_errorCount = 0; // done during start
00281 
00282   // lock the context service 
00283   Gaudi::Utils::AlgContext cnt
00284     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00285   
00286   StatusCode sc(StatusCode::SUCCESS);
00287   // Invoke reinitialize() method of the derived class inside a try/catch clause
00288   try {
00289     { // limit the scope of the guard
00290       Gaudi::Guards::AuditorGuard guard(this,
00291                                         // check if we want to audit the initialize
00292                                         (m_auditorReinitialize) ? auditorSvc().get() : 0,
00293                                         IAuditor::ReInitialize);
00294       // Invoke the reinitialize() method of the derived class
00295       sc = reinitialize();
00296     }
00297     if( sc.isSuccess() ) { 
00298 
00299       // Now initialize care of any sub-algorithms
00300       std::vector<Algorithm *>::iterator it;
00301       bool fail(false);
00302       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00303         if((*it)->sysReinitialize().isFailure()) fail = true;
00304       }
00305 
00306       if (fail) {
00307         sc = StatusCode::FAILURE;
00308         MsgStream log ( msgSvc() , name() );
00309         log << MSG::ERROR
00310             << "sysReinitialize(): Error reinitializing one or several "
00311             << "sub-algorithms" << endmsg;
00312       }
00313     }
00314   }
00315   catch ( const GaudiException& Exception )  
00316   {
00317     MsgStream log ( msgSvc() , name() );
00318     log << MSG::FATAL << "sysReinitialize(): Exception with tag=" << Exception.tag()
00319         << " is caught" << endmsg;
00320     log << MSG::ERROR << Exception  << endmsg;
00321     Stat stat( chronoSvc() , Exception.tag() );
00322     sc = StatusCode::FAILURE;
00323   }
00324   catch( const std::exception& Exception ) 
00325   {
00326     MsgStream log ( msgSvc() , name() );
00327     log << MSG::FATAL << "sysReinitialize(): Standard std::exception is caught" << endmsg;
00328     log << MSG::ERROR << Exception.what()  << endmsg;
00329     Stat stat( chronoSvc() , "*std::exception*" );
00330     sc = StatusCode::FAILURE;
00331   }
00332   catch(...) 
00333   {
00334     MsgStream log ( msgSvc() , name() );
00335     log << MSG::FATAL << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
00336     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00337     sc = StatusCode::FAILURE;
00338   }
00339   
00340   return sc;
00341 }

StatusCode Algorithm::sysRestart (  )  [virtual]

Restart method invoked by the framework.

It will in turn invoke the restart() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 344 of file Algorithm.cpp.

00344                                  {
00345 
00346   // Bypass the initialization if the algorithm is disabled.
00347   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
00348 
00349   // Check that the current status is the correct one.
00350   if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
00351     MsgStream log ( msgSvc() , name() );
00352     log << MSG::ERROR
00353         << "sysRestart(): cannot restart algorithm not started"
00354         << endmsg;
00355     return StatusCode::FAILURE;
00356   }
00357 
00358   // Check current outputLevel to evetually inform the MessagsSvc
00359   //if( m_outputLevel != MSG::NIL ) {
00360   setOutputLevel( m_outputLevel );
00361   //}
00362 
00363   // Reset Error count
00364   m_errorCount = 0;
00365 
00366   // lock the context service 
00367   Gaudi::Utils::AlgContext cnt
00368     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00369 
00370   StatusCode sc(StatusCode::FAILURE);
00371   // Invoke reinitialize() method of the derived class inside a try/catch clause
00372   try {
00373     { // limit the scope of the guard
00374       Gaudi::Guards::AuditorGuard guard(this,
00375                                         // check if we want to audit the initialize
00376                                         (m_auditorRestart) ? auditorSvc().get() : 0,
00377                                         IAuditor::ReStart);
00378       // Invoke the reinitialize() method of the derived class
00379       sc = restart();
00380     }
00381     if( sc.isSuccess() ) {
00382     
00383       // Now initialize care of any sub-algorithms
00384       std::vector<Algorithm *>::iterator it;
00385       bool fail(false);
00386       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00387         if ((*it)->sysRestart().isFailure()) fail = true;
00388       }
00389       if( fail ) {
00390         sc = StatusCode::FAILURE;
00391         MsgStream log ( msgSvc() , name() );
00392         log << MSG::ERROR
00393             << "sysRestart(): Error restarting one or several sub-algorithms"
00394             << endmsg;
00395       }
00396     }
00397   }
00398   catch ( const GaudiException& Exception )  
00399   {
00400     MsgStream log ( msgSvc() , name() );
00401     log << MSG::FATAL << "sysRestart(): Exception with tag=" << Exception.tag()
00402         << " is caught" << endmsg;
00403     log << MSG::ERROR << Exception  << endmsg;
00404     Stat stat( chronoSvc() , Exception.tag() );
00405     sc = StatusCode::FAILURE;
00406   }
00407   catch( const std::exception& Exception ) 
00408   {
00409     MsgStream log ( msgSvc() , name() );
00410     log << MSG::FATAL << "sysRestart(): Standard std::exception is caught" << endmsg;
00411     log << MSG::ERROR << Exception.what()  << endmsg;
00412     Stat stat( chronoSvc() , "*std::exception*" );
00413     sc = StatusCode::FAILURE;
00414   }
00415   catch(...) 
00416   {
00417     MsgStream log ( msgSvc() , name() );
00418     log << MSG::FATAL << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
00419     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00420     sc = StatusCode::FAILURE;
00421   }
00422 
00423   return sc;
00424 }

StatusCode Algorithm::sysExecute (  )  [virtual]

The actions to be performed by the algorithm on an event.

This method is invoked once per event for top level algorithms by the application manager. This method invokes execute() method. For sub-algorithms either the sysExecute() method or execute() method must be EXPLICITLY invoked by the parent algorithm.

Reimplemented in GaudiAlgorithm.

Definition at line 579 of file Algorithm.cpp.

00579                                  {
00580   if (!isEnabled()) {
00581     MsgStream log ( msgSvc() , name() );
00582     log << MSG::VERBOSE << ".sysExecute(): is not enabled. Skip execution" <<endmsg;
00583     return StatusCode::SUCCESS;
00584   }
00585   
00586   StatusCode status;
00587   
00588   // Should performance profile be performed ?
00589   // invoke execute() method of Algorithm class
00590   //   and catch all uncaught exceptions
00591 
00592   // lock the context service 
00593   Gaudi::Utils::AlgContext cnt
00594     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00595   
00596   Gaudi::Guards::AuditorGuard guard(this,
00597                                     // check if we want to audit the initialize
00598                                     (m_auditorExecute) ? auditorSvc().get() : 0,
00599                                     IAuditor::Execute,
00600                                     status);
00601   try {
00602     status = execute();
00603     setExecuted(true);  // set the executed flag
00604 
00605     if (status.isFailure()) {
00606       status = exceptionSvc()->handleErr(*this,status);
00607     }
00608 
00609   }
00610   catch( const GaudiException& Exception ) 
00611   {
00612     setExecuted(true);  // set the executed flag
00613     
00614     MsgStream log ( msgSvc() , name() );
00615     if (Exception.code() == StatusCode::FAILURE) {
00616       log << MSG::FATAL;
00617     } else {
00618       log << MSG::ERROR << " Recoverable";
00619     }
00620     
00621     log << " Exception with tag=" << Exception.tag()
00622         << " is caught " << endmsg;
00623 
00624     log << MSG::ERROR << Exception  << endmsg;
00625 
00626     Stat stat( chronoSvc() , Exception.tag() ) ;
00627     status = exceptionSvc()->handle(*this,Exception);
00628   }
00629   catch( const std::exception& Exception ) 
00630   {
00631     setExecuted(true);  // set the executed flag
00632     
00633     MsgStream log ( msgSvc() , name() );
00634     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
00635     log << MSG::ERROR << Exception.what()  << endmsg;
00636     Stat stat( chronoSvc() , "*std::exception*" ) ;
00637     status = exceptionSvc()->handle(*this,Exception);
00638   }
00639   catch(...) 
00640   {
00641     setExecuted(true);  // set the executed flag
00642     
00643     MsgStream log ( msgSvc() , name() );
00644     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
00645     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00646     
00647     status = exceptionSvc()->handle(*this);
00648   }
00649   
00650   if( status.isFailure() ) {
00651     MsgStream log ( msgSvc() , name() );
00652     // Increment the error count
00653     m_errorCount++;
00654     // Check if maximum is exeeded
00655     if( m_errorCount < m_errorMax ) {
00656       log << MSG::WARNING << "Continuing from error (cnt=" << m_errorCount
00657           << ", max=" << m_errorMax << ")" << endmsg;
00658       // convert to success
00659       status = StatusCode::SUCCESS;
00660     }
00661   }
00662   return status;
00663 }

StatusCode Algorithm::sysStop (  )  [virtual]

System stop.

This method invokes the stop() method of a concrete algorithm and the stop() methods of all of that algorithm's sub algorithms.

Definition at line 666 of file Algorithm.cpp.

00666                               {
00667 
00668   // Bypass the startup if already running or disabled.
00669   if ( Gaudi::StateMachine::INITIALIZED == FSMState() ||
00670        !isEnabled() ) return StatusCode::SUCCESS;
00671 
00672   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
00673 
00674   // lock the context service 
00675   Gaudi::Utils::AlgContext cnt
00676     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00677   
00678   StatusCode sc(StatusCode::FAILURE);
00679   // Invoke stop() method of the derived class inside a try/catch clause
00680   try {
00681     // Stop first any sub-algorithms (in reverse order)
00682     std::vector<Algorithm *>::reverse_iterator it;
00683     for (it = m_subAlgms->rbegin(); it != m_subAlgms->rend(); it++) {
00684       (*it)->sysStop().ignore();
00685     }
00686     { // limit the scope of the guard
00687       Gaudi::Guards::AuditorGuard guard(this,
00688                                         // check if we want to audit the initialize
00689                                         (m_auditorStop) ? auditorSvc().get() : 0,
00690                                         IAuditor::Stop);
00691       
00692       // Invoke the stop() method of the derived class
00693       sc = stop();
00694     }
00695     if( sc.isSuccess() ) {
00696       // Update the state.
00697       m_state = m_targetState;
00698     }
00699   }
00700   catch ( const GaudiException& Exception )  {
00701     MsgStream log ( msgSvc() , name() );
00702     log << MSG::FATAL << "in sysStop(): exception with tag=" << Exception.tag()
00703         << " is caught" << endmsg;
00704     log << MSG::ERROR << Exception << endmsg;
00705     Stat stat( chronoSvc() , Exception.tag() );
00706     sc = StatusCode::FAILURE;
00707   }
00708   catch( const std::exception& Exception ) {
00709     MsgStream log ( msgSvc() , name() );
00710     log << MSG::FATAL << "in sysStop(): standard std::exception is caught" << endmsg;
00711     log << MSG::ERROR << Exception.what()  << endmsg;
00712     Stat stat( chronoSvc() , "*std::exception*" );
00713     sc = StatusCode::FAILURE;
00714   }
00715   catch(...) {
00716     MsgStream log ( msgSvc() , name() );
00717     log << MSG::FATAL << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
00718     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00719     sc = StatusCode::FAILURE;
00720   }
00721 
00722   return sc;
00723 }

StatusCode Algorithm::sysFinalize (  )  [virtual]

System finalization.

This method invokes the finalize() method of a concrete algorithm and the finalize() methods of all of that algorithm's sub algorithms.

Definition at line 725 of file Algorithm.cpp.

00725                                   {
00726 
00727   // Bypass the finalialization if the algorithm hasn't been initilized.
00728   if ( Gaudi::StateMachine::CONFIGURED == FSMState() ||
00729        !isEnabled() ) return StatusCode::SUCCESS;
00730 
00731   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);
00732 
00733   // lock the context service 
00734   Gaudi::Utils::AlgContext cnt
00735     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00736   
00737   StatusCode sc(StatusCode::FAILURE);
00738   // Invoke finalize() method of the derived class inside a try/catch clause
00739   try {
00740     // Order changed (bug #3903 overview: finalize and nested algorithms)
00741     // Finalize first any sub-algoithms (it can be done more than once)
00742     std::vector<Algorithm *>::iterator it;
00743     bool fail(false);
00744     for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00745       if (!(*it)->sysFinalize().isSuccess()) {
00746         fail = true;
00747       }
00748     }
00749 
00750     { // limit the scope of the guard
00751       Gaudi::Guards::AuditorGuard guard(this,
00752                                         // check if we want to audit the initialize
00753                                         (m_auditorFinalize) ? auditorSvc().get() : 0,
00754                                         IAuditor::Finalize);
00755       // Invoke the finalize() method of the derived class
00756       sc = finalize();
00757     }
00758     if (fail) sc = StatusCode::FAILURE;
00759 
00760     if( sc.isSuccess() ) {
00761 
00762       // Release all sub-algorithms
00763       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00764         (*it)->release();
00765       }
00766       // Indicate that this Algorithm has been finalized to prevent duplicate attempts
00767       m_state = m_targetState;
00768     }
00769   }
00770   catch( const GaudiException& Exception ) 
00771   {
00772     MsgStream log ( msgSvc() , name() );
00773     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00774         << " is caught " << endmsg;
00775     log << MSG::ERROR << Exception  << endmsg;
00776     Stat stat( chronoSvc() , Exception.tag() ) ;
00777     sc = StatusCode::FAILURE;
00778   }
00779   catch( const std::exception& Exception ) 
00780   {
00781     MsgStream log ( msgSvc() , name() );
00782     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
00783     log << MSG::ERROR << Exception.what()  << endmsg;
00784     Stat stat( chronoSvc() , "*std::exception*" ) ;
00785     sc = StatusCode::FAILURE;
00786   }
00787   catch( ... ) 
00788   {
00789     MsgStream log ( msgSvc() , name() );
00790     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
00791     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00792     sc = StatusCode::FAILURE;
00793   }
00794   return sc;
00795 }

StatusCode Algorithm::sysBeginRun (  )  [virtual]

beginRun method invoked by the framework.

This method is responsible for any beginRun actions required by the framework itself. It will in turn invoke the beginRun() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 427 of file Algorithm.cpp.

00427                                   {
00428 
00429   // Bypass the beginRun if the algorithm is disabled.
00430   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
00431 
00432   // Check current outputLevel to evetually inform the MessagsSvc
00433   //if( m_outputLevel != MSG::NIL ) {
00434   setOutputLevel( m_outputLevel );
00435   //}
00436 
00437   // Reset Error count
00438   m_errorCount = 0;
00439   
00440   // lock the context service 
00441   Gaudi::Utils::AlgContext cnt
00442     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00443 
00444   StatusCode sc(StatusCode::FAILURE);
00445   // Invoke beginRun() method of the derived class inside a try/catch clause
00446   try {
00447     { // limit the scope of the guard
00448       Gaudi::Guards::AuditorGuard guard(this,
00449                                         // check if we want to audit the initialize
00450                                         (m_auditorBeginRun) ? auditorSvc().get() : 0,
00451                                         IAuditor::BeginRun);
00452       // Invoke the beginRun() method of the derived class
00453       sc = beginRun();
00454     }
00455     if( sc.isSuccess() ) {
00456 
00457       // Now call beginRun for any sub-algorithms
00458       std::vector<Algorithm *>::iterator it;
00459       bool fail(false);
00460       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00461         if((*it)->sysBeginRun().isFailure()) fail = true;
00462       }
00463       if( fail ) {
00464         sc = StatusCode::FAILURE;
00465         MsgStream log ( msgSvc() , name() );
00466         log << MSG::ERROR << " Error executing BeginRun for one or several sub-algorithms"
00467           << endmsg;
00468       }
00469     }
00470   }
00471   catch ( const GaudiException& Exception ) 
00472   {
00473     MsgStream log ( msgSvc() , name() );
00474     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00475         << " is caught " << endmsg;
00476     log << MSG::ERROR << Exception  << endmsg;
00477     Stat stat( chronoSvc() , Exception.tag() );
00478     sc = StatusCode::FAILURE;
00479   }
00480   catch( const std::exception& Exception ) 
00481   {
00482     MsgStream log ( msgSvc() , name() );
00483     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
00484     log << MSG::ERROR << Exception.what()  << endmsg;
00485     Stat stat( chronoSvc() , "*std::exception*" );
00486     sc = StatusCode::FAILURE;
00487   }
00488   catch(...) 
00489   {
00490     MsgStream log ( msgSvc() , name() );
00491     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
00492     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00493     sc = StatusCode::FAILURE;
00494   }
00495   return sc;
00496 }

StatusCode Algorithm::sysEndRun (  )  [virtual]

endRun method invoked by the framework.

This method is responsible for any endRun actions required by the framework itself. It will in turn invoke the endRun() method of the derived algorithm, and of any sub-algorithms which it creates.

Definition at line 503 of file Algorithm.cpp.

00503                                 {
00504   
00505   // Bypass the endRun if the algorithm is disabled.
00506   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
00507   
00508   // Check current outputLevel to eventually inform the MessagsSvc
00509   //if( m_outputLevel != MSG::NIL ) {
00510   setOutputLevel( m_outputLevel );
00511   //}
00512   
00513   // Reset Error count
00514   m_errorCount = 0;
00515 
00516   // lock the context service 
00517   Gaudi::Utils::AlgContext cnt
00518     ( this , registerContext() ? contextSvc().get() : 0 ) ;
00519 
00520   // Invoke endRun() method of the derived class inside a try/catch clause
00521   StatusCode sc(StatusCode::FAILURE);
00522   try {
00523     { // limit the scope of the guard
00524       Gaudi::Guards::AuditorGuard guard(this,
00525                                         // check if we want to audit the initialize
00526                                         (m_auditorEndRun) ? auditorSvc().get() : 0,
00527                                         IAuditor::EndRun);
00528       // Invoke the endRun() method of the derived class
00529       sc = endRun();
00530     }
00531     if( sc.isSuccess() ) {
00532 
00533       // Now call endRun for any sub-algorithms
00534       std::vector<Algorithm *>::iterator it;
00535       bool fail(false);
00536       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
00537         if ((*it)->sysEndRun().isFailure()) fail = true;
00538       }
00539       if( fail ) {
00540         sc = StatusCode::FAILURE;
00541         MsgStream log ( msgSvc() , name() );
00542         log << MSG::ERROR << " Error calling endRun for one or several sub-algorithms"
00543             << endmsg;
00544       }
00545     }
00546   }
00547   catch ( const GaudiException& Exception ) 
00548   {
00549     MsgStream log ( msgSvc() , name() );
00550     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00551         << " is caught " << endmsg;
00552     log << MSG::ERROR << Exception  << endmsg;
00553     Stat stat( chronoSvc() , Exception.tag() );
00554     sc = StatusCode::FAILURE;
00555   }
00556   catch( const std::exception& Exception ) 
00557   {
00558     MsgStream log ( msgSvc() , name() );
00559     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
00560     log << MSG::ERROR << Exception.what()  << endmsg;
00561     Stat stat( chronoSvc() , "*std::exception*" );
00562     sc = StatusCode::FAILURE;
00563   }
00564   catch(...) 
00565   {
00566     MsgStream log ( msgSvc() , name() );
00567     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
00568     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00569     sc = StatusCode::FAILURE;
00570   }
00571   return sc;
00572 }

const std::string & Algorithm::name (  )  const [virtual]

The identifying name of the algorithm object.

This is the name of a particular instantiation of an algorithm object as opposed to the name of the algorithm itself, e.g. "LinearTrackFit" may be the name of a concrete algorithm class, whereas "ApproxTrackFit" and "BestTrackFit" may be two instantiations of the class configured to find tracks with different fit criteria.

Definition at line 836 of file Algorithm.cpp.

00836                                        {
00837   return m_name;
00838 }

const std::string & Algorithm::version (  )  const [virtual]

Definition at line 840 of file Algorithm.cpp.

00840                                           {
00841   return m_version;
00842 }

virtual StatusCode Algorithm::configure (  )  [inline, virtual]

Dummy implementation of IStateful::configure() method.

Definition at line 148 of file Algorithm.h.

00148 { return StatusCode::SUCCESS ; }

virtual StatusCode Algorithm::terminate (  )  [inline, virtual]

Dummy implementation of IStateful::terminate() method.

Definition at line 150 of file Algorithm.h.

00150 { return StatusCode::SUCCESS ; }

virtual StatusCode Algorithm::initialize (  )  [inline, virtual]

virtual StatusCode Algorithm::start (  )  [inline, virtual]

the default (empty) implementation of IStateful::start() method

Reimplemented in Sequencer, and GaudiPython::PyAlgorithm.

Definition at line 155 of file Algorithm.h.

00155 { return StatusCode::SUCCESS ; }

virtual StatusCode Algorithm::stop (  )  [inline, virtual]

the default (empty) implementation of IStateful::stop() method

Reimplemented in Sequencer, and GaudiPython::PyAlgorithm.

Definition at line 157 of file Algorithm.h.

00157 { return StatusCode::SUCCESS ; }

virtual StatusCode Algorithm::finalize (  )  [inline, virtual]

StatusCode Algorithm::reinitialize (  )  [virtual]

the default (empty) implementation of IStateful::reinitialize() method

Reimplemented in Sequencer.

Definition at line 797 of file Algorithm.cpp.

00797                                    {
00798   /* @TODO
00799    * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
00800    *                 is causing too many problems
00801    *
00802   // Default implementation is finalize+initialize
00803   StatusCode sc = finalize();
00804   if (sc.isFailure()) {
00805     MsgStream log ( msgSvc() , name() );
00806     log << MSG::ERROR << "reinitialize(): cannot be finalized" << endmsg;
00807     return sc;
00808   }
00809   sc = initialize();
00810   if (sc.isFailure()) {
00811     MsgStream log ( msgSvc() , name() );
00812     log << MSG::ERROR << "reinitialize(): cannot be initialized" << endmsg;
00813     return sc;
00814   }
00815   */
00816   return StatusCode::SUCCESS;
00817 }

StatusCode Algorithm::restart (  )  [virtual]

the default (empty) implementation of IStateful::restart() method

Definition at line 819 of file Algorithm.cpp.

00819                               {
00820   // Default implementation is stop+start
00821   StatusCode sc = stop();
00822   if (sc.isFailure()) {
00823     MsgStream log ( msgSvc() , name() );
00824     log << MSG::ERROR << "restart(): cannot be stopped" << endmsg;
00825     return sc;
00826   }
00827   sc = start();
00828   if (sc.isFailure()) {
00829     MsgStream log ( msgSvc() , name() );
00830     log << MSG::ERROR << "restart(): cannot be started" << endmsg;
00831     return sc;
00832   }
00833   return StatusCode::SUCCESS;
00834 }

bool Algorithm::isExecuted (  )  const [virtual]

Has this algorithm been executed since the last reset?

Definition at line 844 of file Algorithm.cpp.

00844                                  {
00845   return m_isExecuted;
00846 }

void Algorithm::setExecuted ( bool  state  )  [virtual]

Set the executed flag to the specified state.

Definition at line 848 of file Algorithm.cpp.

00848                                         {
00849   m_isExecuted = state;
00850 }

void Algorithm::resetExecuted (  )  [virtual]

Reset the executed state of the Algorithm for the duration of the current event.

Reimplemented in GaudiSequencer, and Sequencer.

Definition at line 852 of file Algorithm.cpp.

00852                               {
00853   m_isExecuted   = false;
00854   m_filterPassed = true;
00855 }

StatusCode Algorithm::beginRun (  )  [virtual]

Algorithm begin run.

This method is called at the beginning of the event loop.

Reimplemented in GaudiSequencer, Sequencer, and GaudiPython::PyAlgorithm.

Definition at line 498 of file Algorithm.cpp.

00498                                {
00499   return StatusCode::SUCCESS;
00500 }

StatusCode Algorithm::endRun (  )  [virtual]

Algorithm end run. This method is called at the end of the event loop.

Reimplemented in GaudiSequencer, Sequencer, and GaudiPython::PyAlgorithm.

Definition at line 574 of file Algorithm.cpp.

00574                              {
00575   return StatusCode::SUCCESS;
00576 }

virtual Gaudi::StateMachine::State Algorithm::FSMState (  )  const [inline, virtual]

returns the current state of the algorithm

Definition at line 186 of file Algorithm.h.

00186 { return m_state; }

virtual Gaudi::StateMachine::State Algorithm::targetFSMState (  )  const [inline, virtual]

returns the state the algorithm will be in after the ongoing transition

Definition at line 189 of file Algorithm.h.

00189 { return m_targetState; }

bool Algorithm::isEnabled (  )  const [virtual]

Is this algorithm enabled or disabled?

Definition at line 857 of file Algorithm.cpp.

00857                                 {
00858   return m_isEnabled;
00859 }

bool Algorithm::filterPassed (  )  const [virtual]

Did this algorithm pass or fail its filter criterion for the last event?

Definition at line 861 of file Algorithm.cpp.

00861                                    {
00862   return m_filterPassed;
00863 }

void Algorithm::setFilterPassed ( bool  state  )  [virtual]

Set the filter passed flag to the specified state.

Definition at line 865 of file Algorithm.cpp.

00865                                             {
00866   m_filterPassed = state;
00867 }

template<class T>
StatusCode Algorithm::service ( const std::string name,
T *&  psvc,
bool  createIf = true 
) const [inline]

Access a service by name, creating it if it doesn't already exist.

Definition at line 203 of file Algorithm.h.

00203                                                                   {
00204     return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
00205   }

template<class T>
StatusCode Algorithm::service ( const std::string svcType,
const std::string svcName,
T *&  psvc 
) const [inline]

Access a service by name and type, creating it if it doesn't already exist.

Definition at line 209 of file Algorithm.h.

00210                                       {
00211     return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
00212   }

SmartIF< IService > Algorithm::service ( const std::string name,
const bool  createIf = true,
const bool  quiet = false 
) const

Return a pointer to the service identified by name (or "type/name").

Definition at line 1189 of file Algorithm.cpp.

01189                                                                                                        {
01190   const ServiceLocatorHelper helper(*serviceLocator(), *this);
01191   return helper.service(name, quiet, createIf);
01192 }

void Algorithm::setOutputLevel ( int  level  ) 

Set the output level for current algorithm.

Definition at line 873 of file Algorithm.cpp.

00873                                           {
00874   if ( msgSvc() != 0 )
00875   {
00876     if ( MSG::NIL != level )
00877     { msgSvc()->setOutputLevel( name(), level ) ; }
00878     m_outputLevel = msgSvc()->outputLevel( name() );
00879   }
00880 }

SmartIF<IAuditorSvc>& Algorithm::auditorSvc (  )  const

The standard auditor service.May not be invoked before sysInitialize() has been invoked.

SmartIF<IChronoStatSvc>& Algorithm::chronoSvc (  )  const

The standard Chrono & Stat service, Return a pointer to the service if present.

m_CSS m_DCS m_ECS m_EXS m_RGS m_contextSvc SmartIF< IChronoStatSvc > & Algorithm::chronoStatService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 922 of file Algorithm.cpp.

00922                                                             {
00923   return chronoSvc();
00924 }

SmartIF<IDataProviderSvc>& Algorithm::detSvc (  )  const

The standard detector data service.

May not be invoked before sysInitialize() has been invoked.

SmartIF< IDataProviderSvc > & Algorithm::detDataService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 926 of file Algorithm.cpp.

00926                                                            {
00927   return detSvc();
00928 }

SmartIF<IConversionSvc>& Algorithm::detCnvSvc (  )  const

The standard detector data persistency conversion service.

May not be invoked before sysInitialize() has been invoked.

SmartIF< IConversionSvc > & Algorithm::detDataCnvService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 930 of file Algorithm.cpp.

00930                                                             {
00931   return detCnvSvc();
00932 }

SmartIF<IDataProviderSvc>& Algorithm::eventSvc (  )  const

The standard event data service.

May not be invoked before sysInitialize() has been invoked.

SmartIF<IDataProviderSvc>& Algorithm::evtSvc (  )  const [inline]

shortcut for method eventSvc

Definition at line 253 of file Algorithm.h.

00253 { return eventSvc() ; }

SmartIF< IDataProviderSvc > & Algorithm::eventDataService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 934 of file Algorithm.cpp.

00934                                                              {
00935   return eventSvc();
00936 }

SmartIF<IConversionSvc>& Algorithm::eventCnvSvc (  )  const

The standard event data persistency conversion service.

May not be invoked before sysInitialize() has been invoked.

SmartIF< IConversionSvc > & Algorithm::eventDataCnvService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 938 of file Algorithm.cpp.

00938                                                               {
00939   return eventCnvSvc();
00940 }

SmartIF<IHistogramSvc>& Algorithm::histoSvc (  )  const

The standard histogram service.

May not be invoked before sysInitialize() has been invoked.

SmartIF< IHistogramSvc > & Algorithm::histogramDataService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 942 of file Algorithm.cpp.

00942                                                               {
00943   return histoSvc();
00944 }

SmartIF< IMessageSvc > & Algorithm::msgSvc (  )  const

The standard message service.

Returns a pointer to the standard message service. May not be invoked before sysInitialize() has been invoked.

Definition at line 895 of file Algorithm.cpp.

00895                                               {
00896   if ( !m_MS.isValid() ) {
00897     //can not use service() method (infinite recursion!)
00898     m_MS = serviceLocator(); // default message service
00899     if( !m_MS.isValid() ) {
00900       throw GaudiException("Service [MessageSvc] not found", name(), StatusCode::FAILURE);
00901     }
00902   }
00903   return m_MS;
00904 }

SmartIF< IMessageSvc > & Algorithm::messageService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 946 of file Algorithm.cpp.

00946                                                       {
00947   return msgSvc();
00948 }

SmartIF<INTupleSvc>& Algorithm::ntupleSvc (  )  const

The standard N tuple service.

Returns a pointer to the N tuple service if present.

SmartIF< INTupleSvc > & Algorithm::ntupleService (  )  const

Obsoleted name, kept due to the backwards compatibility.

Definition at line 950 of file Algorithm.cpp.

00950                                                     {
00951   return ntupleSvc();
00952 }

SmartIF<IRndmGenSvc>& Algorithm::randSvc (  )  const

AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.

The standard RandomGen service, Return a pointer to the service if present

SmartIF<IToolSvc>& Algorithm::toolSvc (  )  const

The standard ToolSvc service, Return a pointer to the service if present.

SmartIF<IExceptionSvc>& Algorithm::exceptionSvc (  )  const

Get the exception Service.

SmartIF<IAlgContextSvc>& Algorithm::contextSvc (  )  const

get Algorithm Context Service

SmartIF< ISvcLocator > & Algorithm::serviceLocator (  )  const

The standard service locator.

Returns a pointer to the service locator service. This service may be used by an algorithm to request any services it requires in addition to those provided by default.

Definition at line 1090 of file Algorithm.cpp.

01090                                                       {
01091   return *const_cast<SmartIF<ISvcLocator>*>(&m_pSvcLocator);
01092 }

SmartIF<ISvcLocator>& Algorithm::svcLoc (  )  const [inline]

shortcut for method serviceLocator

Definition at line 315 of file Algorithm.h.

00315 { return serviceLocator() ; }

bool Algorithm::registerContext (  )  const [inline]

register for Algorithm Context Service?

Definition at line 318 of file Algorithm.h.

00318 { return m_registerContext ; }

StatusCode Algorithm::createSubAlgorithm ( const std::string type,
const std::string name,
Algorithm *&  pSubAlg 
)

Create a sub algorithm.

A call to this method creates a child algorithm object. Note that the returned pointer is to Algorithm (as opposed to IAlgorithm), and thus the methods of IProperty are also available for the direct setting of the sub-algorithm's properties. Using this mechanism instead of creating daughter algorithms directly via the new operator is prefered since then the framework may take care of all of the necessary book-keeping.

Parameters:
type The concrete algorithm class of the sub algorithm
name The name to be given to the sub algorithm
pSubAlg Set to point to the newly created algorithm object

Definition at line 1115 of file Algorithm.cpp.

01117                                                                     {
01118   if( m_pSvcLocator == 0 ) return StatusCode::FAILURE;
01119 
01120   SmartIF<IAlgManager> am(m_pSvcLocator);
01121   if ( !am.isValid() ) return StatusCode::FAILURE;
01122 
01123   // Maybe modify the AppMgr interface to return Algorithm* ??
01124   IAlgorithm *tmp;
01125   StatusCode sc = am->createAlgorithm
01126     (type, name+getGaudiThreadIDfromName(Algorithm::name()), tmp);
01127   if( sc.isFailure() ) return StatusCode::FAILURE;
01128 
01129   try{
01130     pSubAlgorithm = dynamic_cast<Algorithm*>(tmp);
01131     m_subAlgms->push_back(pSubAlgorithm);
01132   } catch(...){
01133     sc = StatusCode::FAILURE;
01134   }
01135   return sc;
01136 }

std::vector< Algorithm * > * Algorithm::subAlgorithms (  )  const

List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.

Definition at line 869 of file Algorithm.cpp.

00869                                                        {
00870   return m_subAlgms;
00871 }

StatusCode Algorithm::setProperty ( const Property p  )  [virtual]

Implementation of IProperty::setProperty.

Definition at line 1140 of file Algorithm.cpp.

01140                                                    {
01141   return m_propertyMgr->setProperty(p);
01142 }

StatusCode Algorithm::setProperty ( const std::string s  )  [virtual]

Implementation of IProperty::setProperty.

Definition at line 1143 of file Algorithm.cpp.

01143                                                     {
01144   return m_propertyMgr->setProperty(s);
01145 }

StatusCode Algorithm::setProperty ( const std::string n,
const std::string v 
) [virtual]

Implementation of IProperty::setProperty.

Definition at line 1146 of file Algorithm.cpp.

01146                                                                         {
01147   return m_propertyMgr->setProperty(n,v);
01148 }

StatusCode Algorithm::getProperty ( Property p  )  const [virtual]

Implementation of IProperty::getProperty.

Definition at line 1149 of file Algorithm.cpp.

01149                                                    {
01150   return m_propertyMgr->getProperty(p);
01151 }

const Property & Algorithm::getProperty ( const std::string name  )  const [virtual]

Implementation of IProperty::getProperty.

Definition at line 1152 of file Algorithm.cpp.

01152                                                                   {
01153   return m_propertyMgr->getProperty(name);
01154 }

StatusCode Algorithm::getProperty ( const std::string n,
std::string v 
) const [virtual]

Implementation of IProperty::getProperty.

Definition at line 1155 of file Algorithm.cpp.

01155                                                                          {
01156   return m_propertyMgr->getProperty(n,v);
01157 }

const std::vector< Property * > & Algorithm::getProperties (  )  const [virtual]

Implementation of IProperty::getProperties.

Definition at line 1158 of file Algorithm.cpp.

01158                                                             {
01159   return m_propertyMgr->getProperties();
01160 }

StatusCode Algorithm::setProperties (  ) 

Set the algorithm's properties.

This method requests the job options service to set the values of any declared properties. The method is invoked from within sysInitialize() by the framework and does not need to be explicitly called by a concrete algorithm.

Definition at line 1095 of file Algorithm.cpp.

01095                                     {
01096   if( m_pSvcLocator != 0 )    {
01097     SmartIF<IJobOptionsSvc> jos(m_pSvcLocator->service("JobOptionsSvc"));
01098     if( jos.isValid() ) {
01099       // set first generic Properties
01100       StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
01101       if( sc.isFailure() ) return StatusCode::FAILURE;
01102 
01103       // set specific Properties
01104       if (isGaudiThreaded(name())) {
01105         if(jos->setMyProperties( name(), this ).isFailure()) {
01106           return StatusCode::FAILURE;
01107         }
01108       }
01109       return sc;
01110     }
01111   }
01112   return StatusCode::FAILURE;
01113 }

template<class T>
Property* Algorithm::declareProperty ( const std::string name,
T &  property,
const std::string doc = "none" 
) const [inline]

Declare the named property.

  MyAlg ( const std::string& name ,
          ISvcLocator*       pSvc )
     : Algorithm ( name , pSvc )
     , m_property1   ( ... )
     , m_property2   ( ... )
   {
     // declare the property
     declareProperty( "Property1" , m_property1 , "Doc fro property #1" ) ;

     // declare the property and attach the handler  to it
     declareProperty( "Property2" , m_property2 , "Doc for property #2" )
        -> declareUpdateHandler( &MyAlg::handler_2 ) ;

   }

See also:
PropertyMgr

PropertyMgr::declareProperty

Parameters:
name the property name
property the property itself,
doc the documentation string
Returns:
the actual property objects

Definition at line 393 of file Algorithm.h.

00396   {
00397     return m_propertyMgr->declareProperty(name, property, doc);
00398   }

Property* Algorithm::declareRemoteProperty ( const std::string name,
IProperty rsvc,
const std::string rname = "" 
) const [inline]

Declare remote named properties.

Definition at line 402 of file Algorithm.h.

00405   {
00406     return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname );
00407   }

SmartIF<IMonitorSvc>& Algorithm::monitorSvc (  )  const [inline]

Access the monitor service.

Attention:
Note that this method will return a NULL pointer if no monitor service is configured to be present. You must take this possibility into account when using the pointer
Returns:
Pointer to the Monitor service
Return values:
NULL No monitor service is present
non-NULL A monitor service is present and available to be used

Definition at line 418 of file Algorithm.h.

00419   {
00420     // If not already located try to locate it without forcing a creation
00421     if ( !m_pMonitorSvc.isValid() ){
00422       m_pMonitorSvc = service(m_monitorSvcName, false, true); // do not create and be quiet
00423     }
00424     return m_pMonitorSvc;
00425   }

template<class T>
void Algorithm::declareInfo ( const std::string name,
const T &  var,
const std::string desc 
) const [inline]

Declare monitoring information.

Parameters:
name Monitoring information name known to the external system
var Monitoring Listener address (the item to monitor...)
desc Textual description of the information being monitored

Definition at line 433 of file Algorithm.h.

00436   {
00437     IMonitorSvc* mS = monitorSvc().get();
00438     if ( mS ) mS->declareInfo(name, var, desc, this);
00439   }

void Algorithm::declareInfo ( const std::string name,
const std::string format,
const void *  var,
int  size,
const std::string desc 
) const [inline]

Declare monitoring information (special case).

Parameters:
name Monitoring information name known to the external system
format Format information
var Monitoring Listener address
size Monitoring Listener address size
desc Textual description of the information being monitored

Definition at line 448 of file Algorithm.h.

00453   {
00454     IMonitorSvc* mS = monitorSvc().get();
00455     if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
00456   }

template<class TYPE>
StatusCode Algorithm::setProperty ( const std::string name,
const TYPE &  value 
) [inline]

set the property form the value

  std::vector<double> data = ... ;

  setProperty( "Data" , data ) ;

  std::map<std::string,double> cuts = ... ;
  setProperty( "Cuts" , cuts ) ;

  std::map<std::string,std::string> dict = ... ;
  setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

    setProperty ( "OutputLevel" , "1"    ) ;
    setProperty ( "Enable"      , "True" ) ;
    setProperty ( "ErrorMax"    , "10"   ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters:
name name of the property
value value of the property
See also:
Gaudi::Utils::setProperty
Author:
Vanya BELYAEV ibelyaev@physics.syr.edu
Date:
2007-05-13

Definition at line 504 of file Algorithm.h.

00506   { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }

bool Algorithm::isInitialized (  )  const [inline, protected]

Has the Algorithm already been initialized?

Definition at line 511 of file Algorithm.h.

bool Algorithm::isFinalized (  )  const [inline, protected]

Has the Algorithm already been finalized?

Definition at line 514 of file Algorithm.h.

int Algorithm::outputLevel (  )  const [inline, protected]

retrieve the Algorithm output level

Definition at line 517 of file Algorithm.h.

00517 { return (int)m_outputLevel ; }

IntegerProperty& Algorithm::outputLevelProperty (  )  [inline, protected]

Accessor for the Message level property.

Definition at line 520 of file Algorithm.h.

00520 { return m_outputLevel; }

void Algorithm::initOutputLevel ( Property prop  )  [protected]

callback for output level property

Protected Member Functions.

Definition at line 1166 of file Algorithm.cpp.

01167 {
01168   // do nothing... yet ?
01169 }

StatusCode Algorithm::service_i ( const std::string svcName,
bool  createIf,
const InterfaceID iid,
void **  ppSvc 
) const [private]

implementation of service method

Definition at line 1172 of file Algorithm.cpp.

01175                                          {
01176   const ServiceLocatorHelper helper(*serviceLocator(), *this);
01177   return helper.getService(svcName, createIf, iid, ppSvc);
01178 }

StatusCode Algorithm::service_i ( const std::string svcType,
const std::string svcName,
const InterfaceID iid,
void **  ppSvc 
) const [private]

Definition at line 1181 of file Algorithm.cpp.

01184                                          {
01185   const ServiceLocatorHelper helper(*serviceLocator(), *this);
01186   return helper.createService(svcType, svcName, iid, ppSvc);
01187 }

Algorithm& Algorithm::operator= ( const Algorithm rhs  )  [private]

Private assignment operator: NO ASSIGNMENT ALLOWED.


Member Data Documentation

Algorithm's name for identification.

Definition at line 528 of file Algorithm.h.

Algorithm's version.

Definition at line 529 of file Algorithm.h.

Sub algorithms.

Definition at line 530 of file Algorithm.h.

SmartIF<IMessageSvc> Algorithm::m_MS [mutable, private]

Message service.

Definition at line 532 of file Algorithm.h.

Event data service.

Definition at line 533 of file Algorithm.h.

Event conversion service.

Definition at line 534 of file Algorithm.h.

Detector data service.

Definition at line 535 of file Algorithm.h.

Detector conversion service.

Definition at line 536 of file Algorithm.h.

SmartIF<IHistogramSvc> Algorithm::m_HDS [mutable, private]

Histogram data service.

Definition at line 537 of file Algorithm.h.

SmartIF<INTupleSvc> Algorithm::m_NTS [mutable, private]

N tuple service.

Definition at line 538 of file Algorithm.h.

Chrono & Stat Service.

Definition at line 540 of file Algorithm.h.

SmartIF<IRndmGenSvc> Algorithm::m_RGS [mutable, private]

Random Number Generator Service.

Definition at line 541 of file Algorithm.h.

SmartIF<IExceptionSvc> Algorithm::m_EXS [mutable, private]

Exception Handler Service.

Definition at line 542 of file Algorithm.h.

Auditor Service.

Definition at line 543 of file Algorithm.h.

SmartIF<IToolSvc> Algorithm::m_ptoolSvc [mutable, private]

ToolSvc Service.

Definition at line 544 of file Algorithm.h.

Online Monitoring Service.

Definition at line 545 of file Algorithm.h.

Algorithm Context Service.

Definition at line 546 of file Algorithm.h.

flag to register for Algorithm Context Service

Definition at line 547 of file Algorithm.h.

Name to use for Monitor Service.

Definition at line 548 of file Algorithm.h.

Pointer to service locator service.

Definition at line 549 of file Algorithm.h.

For management of properties.

Definition at line 550 of file Algorithm.h.

Algorithm output level.

Definition at line 551 of file Algorithm.h.

int Algorithm::m_errorMax [private]

Algorithm Max number of errors.

Definition at line 552 of file Algorithm.h.

int Algorithm::m_errorCount [private]

Algorithm error counter.

Definition at line 553 of file Algorithm.h.

global flag for auditors

Definition at line 554 of file Algorithm.h.

flag for auditors in "initialize()"

Definition at line 555 of file Algorithm.h.

flag for auditors in "Reinitialize()"

Definition at line 556 of file Algorithm.h.

flag for auditors in "Restart()"

Definition at line 557 of file Algorithm.h.

flag for auditors in "execute()"

Definition at line 558 of file Algorithm.h.

flag for auditors in "finalize()"

Definition at line 559 of file Algorithm.h.

flag for auditors in "beginRun()"

Definition at line 560 of file Algorithm.h.

flag for auditors in "endRun()"

Definition at line 561 of file Algorithm.h.

bool Algorithm::m_auditorStart [private]

flag for auditors in "initialize()"

Definition at line 562 of file Algorithm.h.

bool Algorithm::m_auditorStop [private]

flag for auditors in "Reinitialize()"

Definition at line 563 of file Algorithm.h.

bool Algorithm::m_filterPassed [private]

Filter passed flag.

Definition at line 564 of file Algorithm.h.

bool Algorithm::m_isEnabled [private]

Algorithm is enabled flag.

Definition at line 565 of file Algorithm.h.

bool Algorithm::m_isExecuted [private]

Algorithm is executed flag.

Definition at line 566 of file Algorithm.h.

Algorithm has been initialized flag.

Definition at line 567 of file Algorithm.h.

Algorithm has been initialized flag.

Definition at line 568 of file Algorithm.h.

bool Algorithm::m_isFinalized [private]

Algorithm has been finalized flag.

Definition at line 569 of file Algorithm.h.


The documentation for this class was generated from the following files:

Generated at Thu Sep 30 09:58:21 2010 for Gaudi Framework, version v21r11 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004