| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

# 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::string & | name () const
| The identifying name of the algorithm object.
virtual const std::string & | version () 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< IService > | 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")
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 Property & | getProperty (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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (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
IntegerProperty & | outputLevelProperty ()
| 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.
Algorithm & | operator= (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< IMessageSvc > | m_MS
| Message service.
SmartIF< IDataProviderSvc > | m_EDS
| Event data service.
SmartIF< IConversionSvc > | m_ECS
| Event conversion service.
SmartIF< IDataProviderSvc > | m_DDS
| Detector data service.
SmartIF< IConversionSvc > | m_DCS
| Detector conversion service.
SmartIF< IHistogramSvc > | m_HDS
| Histogram data service.
SmartIF< INTupleSvc > | m_NTS
| N tuple service.
SmartIF< IChronoStatSvc > | m_CSS
| Chrono & Stat Service.
SmartIF< IRndmGenSvc > | m_RGS
| Random Number Generator Service.
SmartIF< IExceptionSvc > | m_EXS
| Exception Handler Service.
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service.
SmartIF< IToolSvc > | m_ptoolSvc
| ToolSvc Service.
SmartIF< IMonitorSvc > | m_pMonitorSvc
| Online Monitoring Service.
SmartIF< IAlgContextSvc > | m_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< ISvcLocator > | m_pSvcLocator
| Pointer to service locator service.
PropertyMgr * | m_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 28 of file Algorithm.cpp.

      : m_name(name),
        m_version(version),
        m_registerContext ( false ) ,
        m_pSvcLocator(pSvcLocator),
        m_filterPassed(true),
        m_isEnabled(true),
        m_isExecuted(false),
        m_state(Gaudi::StateMachine::CONFIGURED),
        m_targetState(Gaudi::StateMachine::CONFIGURED)
    {
      m_propertyMgr = new PropertyMgr();
      m_subAlgms = new std::vector<Algorithm *>();

      // Declare common Algorithm properties with their defaults
      declareProperty( "OutputLevel",        m_outputLevel = MSG::NIL);
      declareProperty( "Enable",             m_isEnabled = true);
      declareProperty( "ErrorMax",           m_errorMax  = 1);
      declareProperty( "ErrorCount",         m_errorCount = 0);
      // Auditor monitoring properties

      // Get the default setting for service auditing from the AppMgr
      declareProperty( "AuditAlgorithms", m_auditInit );

      bool audit(false);
      SmartIF<IProperty> appMgr(serviceLocator()->service("ApplicationMgr"));
      if (appMgr.isValid()) {
        const Property& prop = appMgr->getProperty("AuditAlgorithms");
        Property &pr = const_cast<Property&>(prop);
        if (m_name != "IncidentSvc") {
          setProperty( pr ).ignore();
        }
        audit = m_auditInit.value();
      }

      declareProperty( "AuditInitialize"  , m_auditorInitialize   = audit ) ;
      declareProperty( "AuditReinitialize", m_auditorReinitialize = audit ) ;
      declareProperty( "AuditRestart"     , m_auditorRestart      = audit ) ;
      declareProperty( "AuditExecute"     , m_auditorExecute      = audit ) ;
      declareProperty( "AuditFinalize"    , m_auditorFinalize     = audit ) ;
      declareProperty( "AuditBeginRun"    , m_auditorBeginRun     = audit ) ;
      declareProperty( "AuditEndRun"      , m_auditorEndRun       = audit ) ;
      declareProperty( "AuditStart"       , m_auditorStart        = audit ) ;
      declareProperty( "AuditStop"        , m_auditorStop         = audit ) ;

      declareProperty( "MonitorService"   , m_monitorSvcName      = "MonitorSvc" );

      declareProperty
        ( "RegisterForContextService" ,
          m_registerContext  ,
          "The flag to enforce the registration for Algorithm Context Service") ;

      // update handlers.
      m_outputLevel.declareUpdateHandler(&Algorithm::initOutputLevel, this);

    }

Algorithm::~Algorithm | ( | ) | `[virtual]`

Destructor.

Definition at line 87 of file Algorithm.cpp.

                          {
      delete m_subAlgms;
      delete m_propertyMgr;
    }

Algorithm::Algorithm | ( | const Algorithm & | a ) | `[private]`

Private Copy constructor: NO COPY ALLOWED.

## Member Function Documentation

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

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

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 497 of file Algorithm.cpp.

                                   {
      return StatusCode::SUCCESS;
    }

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 923 of file Algorithm.cpp.

                                                                {
      return chronoSvc();
    }

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

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

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

Dummy implementation of IStateful::configure() method.

Definition at line 148 of file Algorithm.h.

    { return StatusCode::SUCCESS ; }

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

get Algorithm Context Service

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 1116 of file Algorithm.cpp.

                                                                        {
      if( m_pSvcLocator == 0 ) return StatusCode::FAILURE;

      SmartIF<IAlgManager> am(m_pSvcLocator);
      if ( !am.isValid() ) return StatusCode::FAILURE;

      // Maybe modify the AppMgr interface to return Algorithm* ??
      IAlgorithm *tmp;
      StatusCode sc = am->createAlgorithm
        (type, name+getGaudiThreadIDfromName(Algorithm::name()), tmp);
      if( sc.isFailure() ) return StatusCode::FAILURE;

      try{
        pSubAlgorithm = dynamic_cast<Algorithm*>(tmp);
        m_subAlgms->push_back(pSubAlgorithm);
      } catch(...){
        sc = StatusCode::FAILURE;
      }
      return sc;
    }

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.

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

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.

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

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.

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

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.

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

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 931 of file Algorithm.cpp.

                                                                {
      return detCnvSvc();
    }

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

Obsoleted name, kept due to the backwards compatibility.

Definition at line 927 of file Algorithm.cpp.

                                                               {
      return detSvc();
    }

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

The standard detector data service.

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

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 573 of file Algorithm.cpp.

                                 {
      return StatusCode::SUCCESS;
    }

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 939 of file Algorithm.cpp.

                                                                  {
      return eventCnvSvc();
    }

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

Obsoleted name, kept due to the backwards compatibility.

Definition at line 935 of file Algorithm.cpp.

                                                                 {
      return eventSvc();
    }

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.

    { return eventSvc() ; }

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

Get the exception Service.

bool Algorithm::filterPassed | ( | ) | const`[virtual]`

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

Definition at line 862 of file Algorithm.cpp.

                                       {
      return m_filterPassed;
    }

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

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

Reimplemented in EventCounter, GaudiAlgorithm, GaudiHistoAlg, GaudiSequencer, GaudiTupleAlg, Prescaler, Sequencer, PartitionSwitchAlg, StoreExplorerAlg, StoreSnifferAlg, EvtCollectionStream, InputCopyStream, OutputStream, RecordStream, RunRecordStream, TagCollectionStream, GaudiPython::PyAlgorithm, CollectionCloneAlg, GaudiCommon< Algorithm >, GaudiHistos< GaudiAlgorithm >, and GaudiTuples< GaudiHistoAlg >.

Definition at line 159 of file Algorithm.h.

    { return StatusCode::SUCCESS ; }

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

returns the current state of the algorithm

Definition at line 186 of file Algorithm.h.

    { return m_state; }

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

Implementation of IProperty::getProperties.

Definition at line 1159 of file Algorithm.cpp.

                                                                {
      return m_propertyMgr->getProperties();
    }

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

Implementation of IProperty::getProperty.

Definition at line 1153 of file Algorithm.cpp.

                                                                      {
      return m_propertyMgr->getProperty(name);
    }

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

Implementation of IProperty::getProperty.

Definition at line 1150 of file Algorithm.cpp.

                                                       {
      return m_propertyMgr->getProperty(p);
    }

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

Implementation of IProperty::getProperty.

Definition at line 1156 of file Algorithm.cpp.

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

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

Obsoleted name, kept due to the backwards compatibility.

Definition at line 943 of file Algorithm.cpp.

                                                                  {
      return histoSvc();
    }

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

The standard histogram service.

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

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

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

Reimplemented in EventCounter, GaudiAlgorithm, GaudiHistoAlg, GaudiSequencer, GaudiTupleAlg, Prescaler, Sequencer, PartitionSwitchAlg, StoreExplorerAlg, StoreSnifferAlg, EvtCollectionStream, InputCopyStream, OutputStream, TagCollectionStream, GaudiPython::PyAlgorithm, CollectionCloneAlg, GaudiCommon< Algorithm >, GaudiHistos< GaudiAlgorithm >, and GaudiTuples< GaudiHistoAlg >.

Definition at line 153 of file Algorithm.h.

    { return StatusCode::SUCCESS ; }

void Algorithm::initOutputLevel | ( | Property & | prop ) | `[protected]`

callback for output level property

Protected Member Functions.

Definition at line 1167 of file Algorithm.cpp.

    {
      // do nothing... yet ?
    }

bool Algorithm::isEnabled | ( | ) | const`[virtual]`

Is this algorithm enabled or disabled?

Definition at line 858 of file Algorithm.cpp.

                                    {
      return m_isEnabled;
    }

bool Algorithm::isExecuted | ( | ) | const`[virtual]`

Has this algorithm been executed since the last reset?

Definition at line 845 of file Algorithm.cpp.

                                     {
      return m_isExecuted;
    }

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

Has the Algorithm already been finalized?

Definition at line 514 of file Algorithm.h.

    { return Gaudi::StateMachine::CONFIGURED == m_state; }

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

Has the Algorithm already been initialized?

Definition at line 511 of file Algorithm.h.

    { return Gaudi::StateMachine::INITIALIZED == m_state; }

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

Obsoleted name, kept due to the backwards compatibility.

Definition at line 947 of file Algorithm.cpp.

                                                          {
      return msgSvc();
    }

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.

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

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 896 of file Algorithm.cpp.

                                                  {
      if ( !m_MS.isValid() ) {
        //can not use service() method (infinite recursion!)
        m_MS = serviceLocator(); // default message service
        if( !m_MS.isValid() ) {
          throw GaudiException("Service [MessageSvc] not found", name(), StatusCode::FAILURE);
        }
      }
      return m_MS;
    }

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 837 of file Algorithm.cpp.

                                           {
      return m_name;
    }

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

Obsoleted name, kept due to the backwards compatibility.

Definition at line 951 of file Algorithm.cpp.

                                                        {
      return ntupleSvc();
    }

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

The standard N tuple service.

Returns a pointer to the N tuple service if present.

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

Private assignment operator: NO ASSIGNMENT ALLOWED.

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

retrieve the Algorithm output level

Definition at line 517 of file Algorithm.h.

    { return (int)m_outputLevel ; }

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

Accessor for the Message level property.

Definition at line 520 of file Algorithm.h.

    { return m_outputLevel; }

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

bool Algorithm::registerContext | ( | ) | const`[inline]`

register for Algorithm Context Service?

Definition at line 318 of file Algorithm.h.

    { return m_registerContext ; }

StatusCode Algorithm::reinitialize | ( | ) | `[virtual]`

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

Reimplemented in Sequencer.

Definition at line 798 of file Algorithm.cpp.

                                       {
      /* @TODO
       * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
       *                 is causing too many problems
       *
      // Default implementation is finalize+initialize
      StatusCode sc = finalize();
      if (sc.isFailure()) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR << "reinitialize(): cannot be finalized" << endmsg;
        return sc;
      }
      sc = initialize();
      if (sc.isFailure()) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR << "reinitialize(): cannot be initialized" << endmsg;
        return sc;
      }
      */
      return StatusCode::SUCCESS;
    }

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 853 of file Algorithm.cpp.

                                  {
      m_isExecuted   = false;
      m_filterPassed = true;
    }

StatusCode Algorithm::restart | ( | ) | `[virtual]`

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

Definition at line 820 of file Algorithm.cpp.

                                  {
      // Default implementation is stop+start
      StatusCode sc = stop();
      if (sc.isFailure()) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR << "restart(): cannot be stopped" << endmsg;
        return sc;
      }
      sc = start();
      if (sc.isFailure()) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR << "restart(): cannot be started" << endmsg;
        return sc;
      }
      return StatusCode::SUCCESS;
    }

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 1190 of file Algorithm.cpp.

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

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.

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

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.

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

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

Definition at line 1182 of file Algorithm.cpp.

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

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

implementation of service method

Definition at line 1173 of file Algorithm.cpp.

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

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 1091 of file Algorithm.cpp.

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

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

Set the executed flag to the specified state.

Definition at line 849 of file Algorithm.cpp.

                                            {
      m_isExecuted = state;
    }

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

Set the filter passed flag to the specified state.

Definition at line 866 of file Algorithm.cpp.

                                                {
      m_filterPassed = state;
    }

void Algorithm::setOutputLevel | ( | int | level ) |

Set the output level for current algorithm.

Definition at line 874 of file Algorithm.cpp.

                                              {
      if ( msgSvc() != 0 )
      {
        if ( MSG::NIL != level )
        { msgSvc()->setOutputLevel( name(), level ) ; }
        m_outputLevel = msgSvc()->outputLevel( name() );
      }
    }

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 1096 of file Algorithm.cpp.

                                        {
      if( m_pSvcLocator != 0 )    {
        SmartIF<IJobOptionsSvc> jos(m_pSvcLocator->service("JobOptionsSvc"));
        if( jos.isValid() ) {
          // set first generic Properties
          StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
          if( sc.isFailure() ) return StatusCode::FAILURE;

          // set specific Properties
          if (isGaudiThreaded(name())) {
            if(jos->setMyProperties( name(), this ).isFailure()) {
              return StatusCode::FAILURE;
            }
          }
          return sc;
        }
      }
      return StatusCode::FAILURE;
    }

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.

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

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

Implementation of IProperty::setProperty.

Definition at line 1147 of file Algorithm.cpp.

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

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

Implementation of IProperty::setProperty.

Definition at line 1144 of file Algorithm.cpp.

                                                        {
      return m_propertyMgr->setProperty(s);
    }

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

Implementation of IProperty::setProperty.

Definition at line 1141 of file Algorithm.cpp.

                                                       {
      return m_propertyMgr->setProperty(p);
    }

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.

    { 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.

    { return StatusCode::SUCCESS ; }

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

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

Definition at line 870 of file Algorithm.cpp.

                                                           {
      return m_subAlgms;
    }

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

shortcut for method serviceLocator

Definition at line 315 of file Algorithm.h.

    { return serviceLocator() ; }

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 426 of file Algorithm.cpp.

                                      {

      // Bypass the beginRun if the algorithm is disabled.
      if ( !isEnabled( ) ) return StatusCode::SUCCESS;

      // Check current outputLevel to evetually inform the MessagsSvc
      //if( m_outputLevel != MSG::NIL ) {
      setOutputLevel( m_outputLevel );
      //}

      // Reset Error count
      m_errorCount = 0;

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::FAILURE);
      // Invoke beginRun() method of the derived class inside a try/catch clause
      try {
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorBeginRun) ? auditorSvc().get() : 0,
                                            IAuditor::BeginRun);
          // Invoke the beginRun() method of the derived class
          sc = beginRun();
        }
        if( sc.isSuccess() ) {

          // Now call beginRun for any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if((*it)->sysBeginRun().isFailure()) fail = true;
          }
          if( fail ) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR << " Error executing BeginRun for one or several sub-algorithms"
              << endmsg;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Exception with tag=" << Exception.tag()
            << " is caught " << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }
      return sc;
    }

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 502 of file Algorithm.cpp.

                                    {

      // Bypass the endRun if the algorithm is disabled.
      if ( !isEnabled( ) ) return StatusCode::SUCCESS;

      // Check current outputLevel to eventually inform the MessagsSvc
      //if( m_outputLevel != MSG::NIL ) {
      setOutputLevel( m_outputLevel );
      //}

      // Reset Error count
      m_errorCount = 0;

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      // Invoke endRun() method of the derived class inside a try/catch clause
      StatusCode sc(StatusCode::FAILURE);
      try {
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorEndRun) ? auditorSvc().get() : 0,
                                            IAuditor::EndRun);
          // Invoke the endRun() method of the derived class
          sc = endRun();
        }
        if( sc.isSuccess() ) {

          // Now call endRun for any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if ((*it)->sysEndRun().isFailure()) fail = true;
          }
          if( fail ) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR << " Error calling endRun for one or several sub-algorithms"
                << endmsg;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Exception with tag=" << Exception.tag()
            << " is caught " << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }
      return sc;
    }

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 578 of file Algorithm.cpp.

                                     {
      if (!isEnabled()) {
        if (UNLIKELY(m_outputLevel <= MSG::VERBOSE)) {
          MsgStream log ( msgSvc() , name() );
          log << MSG::VERBOSE << ".sysExecute(): is not enabled. Skip execution" << endmsg;
        }
        return StatusCode::SUCCESS;
      }

      StatusCode status;

      // Should performance profile be performed ?
      // invoke execute() method of Algorithm class
      //   and catch all uncaught exceptions

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      Gaudi::Guards::AuditorGuard guard(this,
                                        // check if we want to audit the initialize
                                        (m_auditorExecute) ? auditorSvc().get() : 0,
                                        IAuditor::Execute,
                                        status);
      try {
        status = execute();
        setExecuted(true);  // set the executed flag

        if (status.isFailure()) {
          status = exceptionSvc()->handleErr(*this,status);
        }

      }
      catch( const GaudiException& Exception )
      {
        setExecuted(true);  // set the executed flag

        MsgStream log ( msgSvc() , name() );
        if (Exception.code() == StatusCode::FAILURE) {
          log << MSG::FATAL;
        } else {
          log << MSG::ERROR << " Recoverable";
        }

        log << " Exception with tag=" << Exception.tag()
            << " is caught " << endmsg;

        log << MSG::ERROR << Exception  << endmsg;

        Stat stat( chronoSvc() , Exception.tag() ) ;
        status = exceptionSvc()->handle(*this,Exception);
      }
      catch( const std::exception& Exception )
      {
        setExecuted(true);  // set the executed flag

        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" ) ;
        status = exceptionSvc()->handle(*this,Exception);
      }
      catch(...)
      {
        setExecuted(true);  // set the executed flag

        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;

        status = exceptionSvc()->handle(*this);
      }

      if( status.isFailure() ) {
        MsgStream log ( msgSvc() , name() );
        // Increment the error count
        m_errorCount++;
        // Check if maximum is exeeded
        if( m_errorCount < m_errorMax ) {
          log << MSG::WARNING << "Continuing from error (cnt=" << m_errorCount
              << ", max=" << m_errorMax << ")" << endmsg;
          // convert to success
          status = StatusCode::SUCCESS;
        }
      }
      return status;
    }

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 726 of file Algorithm.cpp.

                                      {

      // Bypass the finalialization if the algorithm hasn't been initilized.
      if ( Gaudi::StateMachine::CONFIGURED == FSMState() ||
           !isEnabled() ) return StatusCode::SUCCESS;

      m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::FAILURE);
      // Invoke finalize() method of the derived class inside a try/catch clause
      try {
        // Order changed (bug #3903 overview: finalize and nested algorithms)
        // Finalize first any sub-algoithms (it can be done more than once)
        std::vector<Algorithm *>::iterator it;
        bool fail(false);
        for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
          if (!(*it)->sysFinalize().isSuccess()) {
            fail = true;
          }
        }

        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorFinalize) ? auditorSvc().get() : 0,
                                            IAuditor::Finalize);
          // Invoke the finalize() method of the derived class
          sc = finalize();
        }
        if (fail) sc = StatusCode::FAILURE;

        if( sc.isSuccess() ) {

          // Release all sub-algorithms
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            (*it)->release();
          }
          // Indicate that this Algorithm has been finalized to prevent duplicate attempts
          m_state = m_targetState;
        }
      }
      catch( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Exception with tag=" << Exception.tag()
            << " is caught " << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() ) ;
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" ) ;
        sc = StatusCode::FAILURE;
      }
      catch( ... )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }
      return sc;
    }

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 93 of file Algorithm.cpp.

                                        {

      // Bypass the initialization if the algorithm
      // has already been initialized.
      if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;

      // Set the Algorithm's properties
      StatusCode sc = setProperties();
      if( sc.isFailure() ) return StatusCode::FAILURE;

      // Bypass the initialization if the algorithm is disabled.
      // Need to do this after setProperties.
      if ( !isEnabled( ) ) return StatusCode::SUCCESS;

      m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);

      // Check current outputLevel to eventually inform the MessagsSvc
      //if( m_outputLevel != MSG::NIL ) {
      setOutputLevel( m_outputLevel );
      //}

      // TODO: (MCl) where shoud we do this? initialize or start?
      // Reset Error count
      //m_errorCount = 0;

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      // Invoke initialize() method of the derived class inside a try/catch clause
      try {

        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard
            ( this,
              // check if we want to audit the initialize
              (m_auditorInitialize) ? auditorSvc().get() : 0,
              IAuditor::Initialize);
          // Invoke the initialize() method of the derived class
          sc = initialize();
        }
        if( sc.isSuccess() ) {

          // Now initialize care of any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if ((*it)->sysInitialize().isFailure()) fail = true;
          }
          if( fail ) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR << " Error initializing one or several sub-algorithms"
                << endmsg;
          } else {
            // Update the state.
            m_state = m_targetState;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() ) ;
        log << MSG::FATAL << " Exception with tag=" << Exception.tag()
            << " is caught " << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() ) ;
        log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() ) ;
        log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }

      return sc;
    }

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 259 of file Algorithm.cpp.

                                          {

      // Bypass the initialization if the algorithm is disabled.
      if ( !isEnabled( ) ) return StatusCode::SUCCESS;

      // Check that the current status is the correct one.
      if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR
            << "sysReinitialize(): cannot reinitialize algorithm not initialized"
            << endmsg;
        return StatusCode::FAILURE;
      }

      // Check current outputLevel to evetually inform the MessagsSvc
      //if( m_outputLevel != MSG::NIL ) {
      setOutputLevel( m_outputLevel );
      //}

      // Reset Error count
      // m_errorCount = 0; // done during start

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::SUCCESS);
      // Invoke reinitialize() method of the derived class inside a try/catch clause
      try {
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorReinitialize) ? auditorSvc().get() : 0,
                                            IAuditor::ReInitialize);
          // Invoke the reinitialize() method of the derived class
          sc = reinitialize();
        }
        if( sc.isSuccess() ) {

          // Now initialize care of any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if((*it)->sysReinitialize().isFailure()) fail = true;
          }

          if (fail) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR
                << "sysReinitialize(): Error reinitializing one or several "
                << "sub-algorithms" << endmsg;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysReinitialize(): Exception with tag=" << Exception.tag()
            << " is caught" << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysReinitialize(): Standard std::exception is caught" << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }

      return sc;
    }

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 343 of file Algorithm.cpp.

                                     {

      // Bypass the initialization if the algorithm is disabled.
      if ( !isEnabled( ) ) return StatusCode::SUCCESS;

      // Check that the current status is the correct one.
      if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::ERROR
            << "sysRestart(): cannot restart algorithm not started"
            << endmsg;
        return StatusCode::FAILURE;
      }

      // Check current outputLevel to evetually inform the MessagsSvc
      //if( m_outputLevel != MSG::NIL ) {
      setOutputLevel( m_outputLevel );
      //}

      // Reset Error count
      m_errorCount = 0;

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::FAILURE);
      // Invoke reinitialize() method of the derived class inside a try/catch clause
      try {
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorRestart) ? auditorSvc().get() : 0,
                                            IAuditor::ReStart);
          // Invoke the reinitialize() method of the derived class
          sc = restart();
        }
        if( sc.isSuccess() ) {

          // Now initialize care of any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if ((*it)->sysRestart().isFailure()) fail = true;
          }
          if( fail ) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR
                << "sysRestart(): Error restarting one or several sub-algorithms"
                << endmsg;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysRestart(): Exception with tag=" << Exception.tag()
            << " is caught" << endmsg;
        log << MSG::ERROR << Exception  << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysRestart(): Standard std::exception is caught" << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }

      return sc;
    }

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 182 of file Algorithm.cpp.

                                   {

      // Bypass the startup if already running or disabled.
      if ( Gaudi::StateMachine::RUNNING == FSMState() ||
           !isEnabled() ) return StatusCode::SUCCESS;

      m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);

      // TODO: (MCl) where shoud we do this? initialize or start?
      // Reset Error count
      m_errorCount = 0;

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::FAILURE);
      // Invoke start() method of the derived class inside a try/catch clause
      try
      {
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard
            (this,
             // check if we want to audit the initialize
             (m_auditorStart) ? auditorSvc().get() : 0,
             IAuditor::Start);
          // Invoke the start() method of the derived class
          sc = start();
        }
        if( sc.isSuccess() ) {

          // Now start any sub-algorithms
          std::vector<Algorithm *>::iterator it;
          bool fail(false);
          for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
            if ((*it)->sysStart().isFailure()) fail = true;
          }
          if( fail ) {
            sc = StatusCode::FAILURE;
            MsgStream log ( msgSvc() , name() );
            log << MSG::ERROR << " Error starting one or several sub-algorithms"
                << endmsg;
          } else {
            // Update the state.
            m_state = m_targetState;
          }
        }
      }
      catch ( const GaudiException& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStart(): exception with tag=" << Exception.tag()
            << " is caught" << endmsg;
        log << MSG::ERROR << Exception << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception )
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStart(): standard std::exception is caught" << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...)
      {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }

      return sc;
    }

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 667 of file Algorithm.cpp.

                                  {

      // Bypass the startup if already running or disabled.
      if ( Gaudi::StateMachine::INITIALIZED == FSMState() ||
           !isEnabled() ) return StatusCode::SUCCESS;

      m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);

      // lock the context service
      Gaudi::Utils::AlgContext cnt
        ( this , registerContext() ? contextSvc().get() : 0 ) ;

      StatusCode sc(StatusCode::FAILURE);
      // Invoke stop() method of the derived class inside a try/catch clause
      try {
        // Stop first any sub-algorithms (in reverse order)
        std::vector<Algorithm *>::iterator it;
        for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
          (*it)->sysStop().ignore();
        }
        { // limit the scope of the guard
          Gaudi::Guards::AuditorGuard guard(this,
                                            // check if we want to audit the initialize
                                            (m_auditorStop) ? auditorSvc().get() : 0,
                                            IAuditor::Stop);

          // Invoke the stop() method of the derived class
          sc = stop();
        }
        if( sc.isSuccess() ) {
          // Update the state.
          m_state = m_targetState;
        }
      }
      catch ( const GaudiException& Exception )  {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStop(): exception with tag=" << Exception.tag()
            << " is caught" << endmsg;
        log << MSG::ERROR << Exception << endmsg;
        Stat stat( chronoSvc() , Exception.tag() );
        sc = StatusCode::FAILURE;
      }
      catch( const std::exception& Exception ) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStop(): standard std::exception is caught" << endmsg;
        log << MSG::ERROR << Exception.what()  << endmsg;
        Stat stat( chronoSvc() , "*std::exception*" );
        sc = StatusCode::FAILURE;
      }
      catch(...) {
        MsgStream log ( msgSvc() , name() );
        log << MSG::FATAL << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
        sc = StatusCode::FAILURE;
      }

      return sc;
    }

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.

    { return m_targetState; }

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

Dummy implementation of IStateful::terminate() method.

Definition at line 150 of file Algorithm.h.

    { return StatusCode::SUCCESS ; }

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

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

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

Definition at line 841 of file Algorithm.cpp.

                                              {
      return m_version;
    }

## Member Data Documentation

BooleanProperty Algorithm::m_auditInit`[private]`

global flag for auditors

Definition at line 554 of file Algorithm.h.

bool Algorithm::m_auditorBeginRun`[private]`

flag for auditors in "beginRun()"

Definition at line 560 of file Algorithm.h.

bool Algorithm::m_auditorEndRun`[private]`

flag for auditors in "endRun()"

Definition at line 561 of file Algorithm.h.

bool Algorithm::m_auditorExecute`[private]`

flag for auditors in "execute()"

Definition at line 558 of file Algorithm.h.

bool Algorithm::m_auditorFinalize`[private]`

flag for auditors in "finalize()"

Definition at line 559 of file Algorithm.h.

bool Algorithm::m_auditorInitialize`[private]`

flag for auditors in "initialize()"

Definition at line 555 of file Algorithm.h.

bool Algorithm::m_auditorReinitialize`[private]`

flag for auditors in "Reinitialize()"

Definition at line 556 of file Algorithm.h.

bool Algorithm::m_auditorRestart`[private]`

flag for auditors in "Restart()"

Definition at line 557 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.

SmartIF<IAlgContextSvc> Algorithm::m_contextSvc`[mutable, private]`

Algorithm Context Service.

Definition at line 546 of file Algorithm.h.

SmartIF<IChronoStatSvc> Algorithm::m_CSS`[mutable, private]`

Chrono & Stat Service.

Definition at line 540 of file Algorithm.h.

SmartIF<IConversionSvc> Algorithm::m_DCS`[mutable, private]`

Detector conversion service.

Definition at line 536 of file Algorithm.h.

SmartIF<IDataProviderSvc> Algorithm::m_DDS`[mutable, private]`

Detector data service.

Definition at line 535 of file Algorithm.h.

SmartIF<IConversionSvc> Algorithm::m_ECS`[mutable, private]`

Event conversion service.

Definition at line 534 of file Algorithm.h.

SmartIF<IDataProviderSvc> Algorithm::m_EDS`[mutable, private]`

Event data service.

Definition at line 533 of file Algorithm.h.

int Algorithm::m_errorCount`[private]`

Algorithm error counter.

Definition at line 553 of file Algorithm.h.

int Algorithm::m_errorMax`[private]`

Algorithm Max number of errors.

Definition at line 552 of file Algorithm.h.

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

Exception Handler Service.

Definition at line 542 of file Algorithm.h.

bool Algorithm::m_filterPassed`[private]`

Filter passed flag.

Definition at line 564 of file Algorithm.h.

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

Histogram data service.

Definition at line 537 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.

bool Algorithm::m_isFinalized`[private]`

Algorithm has been finalized flag.

Definition at line 569 of file Algorithm.h.

std::string Algorithm::m_monitorSvcName`[private]`

Name to use for Monitor Service.

Definition at line 548 of file Algorithm.h.

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

Message service.

Definition at line 532 of file Algorithm.h.

std::string Algorithm::m_name`[private]`

Algorithm's name for identification.

Definition at line 528 of file Algorithm.h.

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

N tuple service.

Definition at line 538 of file Algorithm.h.

IntegerProperty Algorithm::m_outputLevel`[private]`

Algorithm output level.

Definition at line 551 of file Algorithm.h.

SmartIF<IAuditorSvc> Algorithm::m_pAuditorSvc`[mutable, private]`

Auditor Service.

Definition at line 543 of file Algorithm.h.

SmartIF<IMonitorSvc> Algorithm::m_pMonitorSvc`[mutable, private]`

Online Monitoring Service.

Definition at line 545 of file Algorithm.h.

PropertyMgr* Algorithm::m_propertyMgr`[private]`

For management of properties.

Definition at line 550 of file Algorithm.h.

SmartIF<ISvcLocator> Algorithm::m_pSvcLocator`[private]`

Pointer to service locator service.

Definition at line 549 of file Algorithm.h.

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

ToolSvc Service.

Definition at line 544 of file Algorithm.h.

bool Algorithm::m_registerContext`[private]`

flag to register for Algorithm Context Service

Definition at line 547 of file Algorithm.h.

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

Random Number Generator Service.

Definition at line 541 of file Algorithm.h.

Gaudi::StateMachine::State Algorithm::m_state`[private]`

Algorithm has been initialized flag.

Definition at line 567 of file Algorithm.h.

std::vector<Algorithm *>* Algorithm::m_subAlgms`[private]`

Sub algorithms.

Definition at line 530 of file Algorithm.h.

Gaudi::StateMachine::State Algorithm::m_targetState`[private]`

Algorithm has been initialized flag.

Definition at line 568 of file Algorithm.h.

std::string Algorithm::m_version`[private]`

Algorithm's version.

Definition at line 529 of file Algorithm.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r0/GaudiKernel/GaudiKernel/Algorithm.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r0/GaudiKernel/src/Lib/Algorithm.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines