Commits

Anonymous committed f98469a

first import

Comments (0)

Files changed (8)

AthenaBaseComps/AthAlgTool.h

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthAlgTool.h 
+// Header file for class AthAlgTool
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+#ifndef ATHENABASECOMPS_ATHALGTOOL_H 
+#define ATHENABASECOMPS_ATHALGTOOL_H 
+
+// STL includes
+#include <string>
+
+// FrameWork includes
+#include "GaudiKernel/AlgTool.h"
+#include "GaudiKernel/MsgStream.h"
+
+class AthAlgTool : public AlgTool
+{ 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public methods: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+
+  // Copy constructor: 
+
+  /// Constructor with parameters: 
+  AthAlgTool( const std::string& type,
+	      const std::string& name, 
+	      const IInterface* parent );
+
+  /// Destructor: 
+  virtual ~AthAlgTool(); 
+
+  // Athena algorithm's Hooks
+
+  /// Initialize @AlgTool
+  virtual StatusCode initialize() { return AlgTool::initialize(); }
+  virtual StatusCode sysInitialize();
+
+  /// Finalize @AlgTool
+  virtual StatusCode finalize() { return AlgTool::finalize(); }
+  virtual StatusCode sysFinalize();
+
+  /////////////////////////////////////////////////////////////////// 
+  // Const methods: 
+  ///////////////////////////////////////////////////////////////////
+
+  /// Retrieve a reference to the @c MsgStream.
+  MsgStream& msg() const;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Non-const methods: 
+  /////////////////////////////////////////////////////////////////// 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Private data: 
+  /////////////////////////////////////////////////////////////////// 
+ private: 
+
+  /// Default constructor: 
+  AthAlgTool();
+
+  /// MsgStream instance (a std::cout like with print-out levels)
+  MsgStream m_msg;
+
+}; 
+
+// I/O operators
+//////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Inline methods: 
+/////////////////////////////////////////////////////////////////// 
+
+inline
+MsgStream& AthAlgTool::msg() const 
+{ return const_cast<MsgStream&>(m_msg); }
+
+#endif //> ATHENABASECOMPS_ATHALGTOOL_H

AthenaBaseComps/AthAlgorithm.h

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthAlgorithm.h 
+// Header file for class AthAlgorithm
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+#ifndef ATHENABASECOMPS_ATHALGORITHM_H 
+#define ATHENABASECOMPS_ATHALGORITHM_H 
+
+// STL includes
+#include <string>
+#include <vector>
+
+// HepMC / CLHEP includes
+
+// FrameWork includes
+#include "GaudiKernel/IProperty.h"
+#include "GaudiKernel/IAlgorithm.h"
+#include "GaudiKernel/IService.h"
+#include "GaudiKernel/ISvcLocator.h"
+#include "GaudiKernel/IMessageSvc.h"
+#include "GaudiKernel/IMonitorSvc.h"
+#include "GaudiKernel/Property.h"
+#include "GaudiKernel/PropertyMgr.h"
+#include "GaudiKernel/MsgStream.h"
+#include "GaudiKernel/ServiceHandle.h"
+
+// Forward declaration
+class StoreGateSvc;
+class IHistogramSvc;
+class INTupleSvc;
+class IChronoStatSvc;
+class IAuditorSvc;
+class IToolSvc;
+class IExceptionSvc;
+
+#ifndef PACKAGE_VERSION
+ #define PACKAGE_VERSION "unknown"
+#endif
+
+/** @class AthAlgorithm AthAlgorithm.h AthenaBaseComps/AthAlgorithm.h
+ *
+ *  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 (StoreGate 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 initialise() and afterwards (see the 
+ *  Gaudi user guide).
+ *
+ *  @author Paul Maley
+ *  @author Pere Mato
+ *  @author David Quarrie
+ *  @author Sebastien Binet
+ *  @date   1998
+ */ 
+
+class AthAlgorithm : virtual public IAlgorithm,
+		     virtual public IProperty
+{ 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public methods: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+
+  // Copy constructor: 
+
+  /// Constructor with parameters: 
+  AthAlgorithm( const std::string& name, 
+		ISvcLocator* pSvcLocator,
+		const std::string& version = PACKAGE_VERSION );
+
+  /// Destructor: 
+  virtual ~AthAlgorithm(); 
+
+  /** 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. 
+   */
+  virtual StatusCode sysReinitialize();
+  
+  /** 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. 
+   */
+  virtual StatusCode sysInitialize();
+  
+  /** 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. 
+   */
+  virtual StatusCode sysExecute();
+
+  /** System finalization. This method invokes the finalize() method of a 
+   *  concrete algorithm and the finalize() methods of all of that algorithm's 
+   *  sub algorithms. 
+   */ 
+  virtual StatusCode sysFinalize();
+
+  /** 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.
+   */
+  virtual StatusCode sysBeginRun();
+
+  /** 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.
+   */
+  virtual StatusCode sysEndRun();
+
+  /** 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. 
+   */
+  virtual const std::string& name() const;
+
+  virtual const std::string& version() const;
+
+  /// the default (empty) implementation of IAlgorithm::initialize() method
+  virtual StatusCode initialize()   { return StatusCode::SUCCESS; }
+  /// the default (empty) implementation of IAlgorithm::reinitialize() method
+  virtual StatusCode reinitialize();
+  /// the default (empty) implementation of IAlgorithm::finalize() method
+  virtual StatusCode finalize()     { return StatusCode::SUCCESS; }
+
+  /// Has this algorithm been executed since the last reset?
+  virtual bool isExecuted( ) const;
+
+  /// Set the executed flag to the specified state
+  virtual StatusCode setExecuted( bool state );
+
+  /** Reset the executed state of the Algorithm for the duration 
+   *  of the current event.
+   */
+  virtual StatusCode resetExecuted( );
+  
+  /** Algorithm begin run. This method is called at the beginning 
+   *  of the event loop.
+   */
+  virtual StatusCode beginRun();
+  
+  /// Algorithm end run. This method is called at the end of the event loop
+  virtual StatusCode endRun();
+
+  /// Is this algorithm enabled or disabled?
+  virtual bool isEnabled( ) const;
+
+  /// Did this algorithm pass or fail its filter criterion for the last event?
+  virtual bool filterPassed( ) const;
+
+  /// Set the filter passed flag to the specified state
+  virtual StatusCode setFilterPassed( bool state );
+  
+  /// Access a service by name, creating it if it doesn't already exist.
+  template <class T>
+  StatusCode service 
+  ( const std::string& name, T*& psvc, bool createIf = true ) const {
+    return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
+  }
+
+  /// Access a service by name and type, creating it if it doesn't 
+  /// already exist.
+  template <class T>
+  StatusCode service( const std::string& svcType, const std::string& svcName,
+		      T*& psvc) const {
+    return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
+  }
+
+  /// Set the outputlevel for current algorithm
+  void setOutputLevel( int level );
+
+  /** The standard auditor service.May not be invoked before sysInitialize() 
+   *  has been invoked.
+   */
+  IAuditorSvc* auditorSvc() const;
+  
+  /** The standard Chrono & Stat service, 
+   *  Return a pointer to the service if present
+   */
+  IChronoStatSvc* chronoSvc() const;
+  
+  /** The standard histogram service. 
+   *  May not be invoked before sysInitialize() has been invoked.
+   */
+  IHistogramSvc* histoSvc() const;
+
+  /** The standard message service. 
+   *  Returns a pointer to the standard message service. 
+   *  May not be invoked before sysInitialize() has been invoked.
+   */
+  IMessageSvc*      msgSvc() const;
+
+  /** The standard N tuple service. 
+   *  Returns a pointer to the N tuple service if present.
+   */
+  INTupleSvc* ntupleSvc() const;
+  
+  /// The standard ToolSvc service, Return a pointer to the service if present
+  IToolSvc* toolSvc() const;
+
+  /// Get the exception svc
+  IExceptionSvc* exceptionSvc() 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.
+   */
+  ISvcLocator* serviceLocator() const;
+
+  /// shortcut for method serviceLocator 
+  ISvcLocator* svcLoc        () const { return serviceLocator() ; }
+  
+  /// Retrieve a reference to the @c MsgStream
+  MsgStream& msg() const;
+
+  /// The standard @c StoreGateSvc
+  /// Returns (kind of) a pointer to the @c StoreGateSvc
+  ServiceHandle<StoreGateSvc>& sgSvc() const;
+
+  /** Create a sub algorithm. 
+   *  A call to this method creates a child algorithm object.
+   *  Note that the returned pointer is to @c AthAlgorithm 
+   *  (as opposed to @c IAlgorithm), and thus the methods of @c 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.
+   *  @param type The concrete algorithm class of the sub algorithm
+   *  @param name The name to be given to the sub algorithm
+   *  @param pSubAlg Set to point to the newly created algorithm object
+   */
+  StatusCode createSubAlgorithm( const std::string& type, 
+                                 const std::string& name, 
+				 AthAlgorithm*& pSubAlg );
+  
+  /// List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms
+  std::vector<AthAlgorithm*>* subAlgorithms() const;
+  
+  /// Implementation of IProperty::setProperty 
+  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::getProperty
+  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::getProperties
+  virtual const std::vector<Property*>& getProperties( ) const;
+
+  /** 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.
+   */
+  StatusCode setProperties();
+  
+  /// Declare named properties
+  template <class T>
+  StatusCode declareProperty( const std::string& name, 
+			      T& property,
+			      const std::string& doc = "none" ) const {
+        m_propertyMgr->declareProperty(name, property, doc);
+        return StatusCode(StatusCode::SUCCESS,true);
+  }
+
+  /// Declare remote named properties
+  StatusCode declareRemoteProperty( const std::string& name, 
+				    IProperty* rsvc, 
+                                    const std::string& rname = "" ) const {
+  	m_propertyMgr->declareRemoteProperty(name, rsvc, rname);
+  	return StatusCode(StatusCode::SUCCESS,true);
+  }
+
+  /// Declare named monitoring information items
+  template <class T>
+  void declareInfo( const std::string& name, 
+		    const T& var, 
+		    const std::string& desc ) const {
+    // If not already located try to locate it without forcing a creation
+    if ( !m_pMonitorSvc ) {
+      service_i( "MonitorSvc", false, IMonitorSvc::interfaceID(), 
+		 (void**)&m_pMonitorSvc );
+    }
+    if ( m_pMonitorSvc ) {
+      m_pMonitorSvc->declareInfo( name, var, desc, this );
+    }
+  }
+
+  /// Special case of general structure monitoring
+  void declareInfo( const std::string& name, 
+		    const std::string& format, 
+		    const void* var, 
+		    int size, 
+		    const std::string& desc ) const {
+    // If not already located try to locate it without forcing a creation
+    if ( !m_pMonitorSvc ) {
+      service_i( "MonitorSvc", false, IMonitorSvc::interfaceID(), 
+		 (void**)&m_pMonitorSvc );
+    }
+    if ( m_pMonitorSvc ) {
+      m_pMonitorSvc->declareInfo( name, format, var, size, desc, this );
+    }
+  }
+
+  /// Methods for IInterface::addRef()
+  unsigned long addRef();
+  /// Methods for IInterface::release()
+  unsigned long release();
+  /// Methods for IInterface::queryInterface()
+  StatusCode queryInterface(const InterfaceID& riid, void**);
+
+  /////////////////////////////////////////////////////////////////// 
+  // Protected methods: 
+  /////////////////////////////////////////////////////////////////// 
+ protected: 
+
+  /// Has the Algorithm already been initialized?
+  bool isInitialized( ) const;
+
+  /// Set the Algorithm initialized state
+  void setInitialized( );
+
+  /// Has the Algorithm already been finalized?
+  bool isFinalized( ) const;
+
+  /// Set the Algorithm finalized state
+  void setFinalized( );
+  
+  /// retrieve the Algorithm output level
+  int  outputLevel() const;
+
+  /// Accessor for the Message level property
+  IntegerProperty & outputLevelProperty() { return m_outputLevel; }
+  
+  /// Callback method being triggered when the output level is modified
+  void initOutputLevel( Property& outputLvl );
+
+  /// Change the @c StoreGate store we are pointing to
+  StatusCode setStoreGateSvc( const std::string& sgName = "StoreGateSvc" );
+
+  /////////////////////////////////////////////////////////////////// 
+  // Private methods: 
+  /////////////////////////////////////////////////////////////////// 
+ private: 
+
+  /// Default constructor: 
+  AthAlgorithm();
+
+  /// Private Copy constructor: NO COPY ALLOWED
+  AthAlgorithm(const AthAlgorithm& rhs);                 
+
+  /// Private asignment operator: NO ASSIGNMENT ALLOWED
+  AthAlgorithm& operator=(const AthAlgorithm& rhs);
+
+  /// implementation of service method
+  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;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Private data: 
+  /////////////////////////////////////////////////////////////////// 
+ private: 
+
+  long m_refCount;               ///< Counter for references to Algorithm
+  std::string m_name;            ///< Algorithm's name for identification
+  std::string m_version;         ///< Algorithm's version
+  std::vector<AthAlgorithm *>* m_subAlgms; ///< Sub algorithms
+
+  typedef ServiceHandle<IMessageSvc> IMessageSvc_t;
+  /// Message service
+  IMessageSvc_t m_MS;
+
+  typedef ServiceHandle<IHistogramSvc> IHistogramSvc_t;
+  /// Histogram data service
+  IHistogramSvc_t m_HDS;
+
+  typedef ServiceHandle<INTupleSvc> INTupleSvc_t;
+  /// N tuple service
+  INTupleSvc_t m_NTS;
+
+  typedef ServiceHandle<IChronoStatSvc> IChronoStatSvc_t;
+  /// Chrono & Stat service
+  IChronoStatSvc_t m_CSS;
+
+  typedef ServiceHandle<IExceptionSvc> IExceptionSvc_t;
+  /// Exception Handler service
+  IExceptionSvc_t m_EXS;
+
+  typedef ServiceHandle<IAuditorSvc> IAuditorSvc_t;
+  /// Auditor service
+  IAuditorSvc_t m_pAuditorSvc;
+
+  typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
+  /// Pointer to a StoreGate service
+  StoreGateSvc_t m_sgSvc;
+
+  typedef ServiceHandle<IToolSvc> IToolSvc_t;
+  /// ToolSvc service
+  IToolSvc_t m_pToolSvc;
+
+  typedef ServiceHandle<IMonitorSvc> IMonitorSvc_t;
+  /// Online monitoring service
+  IMonitorSvc_t m_pMonitorSvc;
+
+  /// Pointer to Service locator service
+  ISvcLocator* m_pSvcLocator;
+
+  /// For the management of properties
+  PropertyMgr* m_propertyMgr;
+
+  /// Algorithm output level
+  IntegerProperty m_outputLevel;
+
+  /// Algorithm Max number of errors
+  int m_errorMax;
+
+  /// Algorithm error counter
+  int m_errorCount;
+
+  /// Global flag for auditors
+  BooleanProperty m_auditInit;
+
+  /// Flag for auditors in @c initialize()
+  bool m_auditorInitialize;
+
+  /// Flag for auditors in @c reinitialize()
+  bool m_auditorReinitialize;
+
+  /// Flag for auditors in @c execute()
+  bool m_auditorExecute;
+
+  /// Flag for auditors in @c finalize()
+  bool m_auditorFinalize;
+
+  /// Flag for auditors in @c beginRun()
+  bool m_auditorBeginRun;
+
+  /// Flag for auditors in @c endRun()
+  bool m_auditorEndRun;
+
+  /// Filter passed flag
+  bool m_filterPassed;
+
+  /// Algorithm is enabled flag
+  bool m_isEnabled;
+
+  /// Algorithm is executed flag
+  bool m_isExecuted;
+
+  /// Algorithm has been initialized flag
+  bool m_isInitialized;
+
+  /// Algorithm has been finalized flag
+  bool m_isFinalized;
+
+  /// MsgStream instance (a std::cout like with print-out levels)
+  MsgStream m_msg;
+
+}; 
+
+/////////////////////////////////////////////////////////////////// 
+// Inline methods: 
+/////////////////////////////////////////////////////////////////// 
+
+inline
+MsgStream& AthAlgorithm::msg() const 
+{ return const_cast<MsgStream&>(m_msg); }
+
+inline
+ServiceHandle<StoreGateSvc>& AthAlgorithm::sgSvc() const 
+{ return const_cast<StoreGateSvc_t&>(m_sgSvc); }
+
+inline
+int AthAlgorithm::outputLevel() const 
+{ return m_outputLevel.value(); }
+
+#endif //> ATHENABASECOMPS_ATHALGORITHM_H

AthenaBaseComps/AthService.h

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthService.h 
+// Header file for class AthService
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+#ifndef ATHENABASECOMPS_ATHSERVICE_H 
+#define ATHENABASECOMPS_ATHSERVICE_H 
+
+// STL includes
+#include <string>
+
+// FrameWork includes
+#include "GaudiKernel/Service.h"
+#include "GaudiKernel/MsgStream.h"
+
+// Forward declaration
+class ISvcLocator;
+template <class TYPE> class SvcFactory;
+
+class AthService : public Service
+{ 
+ protected:
+  friend class SvcFactory<AthService>;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public methods: 
+  /////////////////////////////////////////////////////////////////// 
+ public: 
+
+  // Copy constructor: 
+
+  /// Constructor with parameters: 
+  AthService( const std::string& name, ISvcLocator* pSvcLocator );
+
+  /// Destructor: 
+  virtual ~AthService(); 
+
+  /// Initialize @c Service
+  virtual StatusCode sysInitialize();
+  virtual StatusCode initialize() { return ::Service::initialize(); }
+
+  /// Finalize @c Service
+  virtual StatusCode sysFinalize();
+  virtual StatusCode finalize() { return ::Service::finalize(); }
+
+  virtual StatusCode queryInterface( const InterfaceID& riid, 
+                                     void** ppvInterface );
+
+  /////////////////////////////////////////////////////////////////// 
+  // Const methods: 
+  ///////////////////////////////////////////////////////////////////
+
+  /// Retrieve a reference to the embedded @c MsgStream.
+  MsgStream& msg() const;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Non-const methods: 
+  /////////////////////////////////////////////////////////////////// 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Private data: 
+  /////////////////////////////////////////////////////////////////// 
+ private: 
+
+  /// Default constructor: 
+  AthService();
+
+  /// MsgStream instance (a std::cout like with print-out levels)
+  MsgStream m_msg;
+
+}; 
+
+/////////////////////////////////////////////////////////////////// 
+// Inline methods: 
+/////////////////////////////////////////////////////////////////// 
+
+inline
+MsgStream& AthService::msg() const 
+{ return const_cast<MsgStream&>(m_msg); }
+
+#endif //> ATHENABASECOMPS_ATHSERVICE_H
+2007-05-11  Sebastien Binet  <binet@lblbox>
+
+	* tagging AthenaBaseComps-00-00-00
+	* first import
+	* AthAlgorithm needs patch #1073
+
+package AthenaBaseComps
+
+author  Sebastien Binet <binet@cern.ch>
+
+## For Athena policies: it has to be the first use statement
+use AtlasPolicy 	AtlasPolicy-*
+
+## For Gaudi tools, services and objects
+use GaudiInterface 	GaudiInterface-* 	External
+
+use AthenaKernel	AthenaKernel-*		Control
+use StoreGate		StoreGate-*		Control
+
+branches AthenaBaseComps src
+
+library AthenaBaseComps *.cxx
+
+apply_pattern installed_library
+# apply_pattern declare_joboptions files="*.py"
+# apply_pattern declare_python_modules files="*.py"

src/AthAlgTool.cxx

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthAlgTool.cxx 
+// Implementation file for class AthAlgTool
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+
+
+// STL includes
+
+// FrameWork includes
+
+// AthenaBaseComps includes
+#include "AthenaBaseComps/AthAlgTool.h"
+
+/////////////////////////////////////////////////////////////////// 
+// Public methods: 
+/////////////////////////////////////////////////////////////////// 
+
+// Constructors
+////////////////
+AthAlgTool::AthAlgTool( const std::string& type, 
+			const std::string& name, 
+			const IInterface* parent ) : 
+  AlgTool( type, name, parent ),
+  m_msg  ( msgSvc(),     name )
+{
+  //
+  // Property declaration
+  // 
+  //declareProperty( "Property", m_nProperty );
+
+}
+
+// Destructor
+///////////////
+AthAlgTool::~AthAlgTool()
+{ 
+  msg() << MSG::DEBUG << "Calling destructor" << endreq;
+}
+
+// Athena Algorithm's Hooks
+////////////////////////////
+StatusCode AthAlgTool::sysInitialize()
+{
+  // configure our MsgStream
+  m_msg.setLevel( outputLevel() );
+
+  return AlgTool::sysInitialize();
+}
+
+StatusCode AthAlgTool::sysFinalize()
+{
+  return AlgTool::sysFinalize();
+}
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+/////////////////////////////////////////////////////////////////// 
+
+/////////////////////////////////////////////////////////////////// 
+// Protected methods: 
+/////////////////////////////////////////////////////////////////// 
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+/////////////////////////////////////////////////////////////////// 
+

src/AthAlgorithm.cxx

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthAlgorithm.cxx 
+// Implementation file for class AthAlgorithm
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+
+
+// STL includes
+
+// FrameWork includes
+#include "GaudiKernel/Kernel.h" 
+#include "GaudiKernel/ISvcLocator.h"
+#include "GaudiKernel/IMessageSvc.h"
+#include "GaudiKernel/IJobOptionsSvc.h"
+#include "GaudiKernel/IAlgManager.h"
+#include "GaudiKernel/IAuditorSvc.h"
+#include "GaudiKernel/IHistogramSvc.h"
+#include "GaudiKernel/INTupleSvc.h"
+#include "GaudiKernel/IToolSvc.h"
+#include "GaudiKernel/IExceptionSvc.h"
+#include "GaudiKernel/IProperty.h"
+
+#include "GaudiKernel/PropertyMgr.h"
+#include "GaudiKernel/Chrono.h" 
+#include "GaudiKernel/Stat.h" 
+#include "GaudiKernel/GaudiException.h" 
+#include "GaudiKernel/ServiceLocatorHelper.h"
+#include "GaudiKernel/ThreadGaudi.h"
+
+// StoreGate
+#include "StoreGate/StoreGateSvc.h"
+
+// AthenaBaseComps includes
+#include "AthenaBaseComps/AthAlgorithm.h"
+
+/////////////////////////////////////////////////////////////////// 
+// Public methods: 
+/////////////////////////////////////////////////////////////////// 
+
+typedef std::vector<AthAlgorithm*> AthAlgs_t;
+
+// Constructors
+////////////////
+AthAlgorithm::AthAlgorithm( const std::string& name, 
+			    ISvcLocator* pSvcLocator,
+			    const std::string& version ) : 
+  m_refCount( 0 ),
+  m_name( name ),
+  m_version( version ),
+  m_MS ( "MessageSvc",       name ),
+  m_HDS( "HistogramDataSvc", name ),
+  m_NTS( "NTupleSvc",        name ),
+  m_CSS( "ChronoStatSvc",    name ),
+  m_EXS( "ExceptionSvc",     name ),
+  m_pAuditorSvc( "AuditorSvc",   name ),
+  m_sgSvc      ( "StoreGateSvc", name ),
+  m_pToolSvc   ( "ToolSvc",      name ),
+  m_pMonitorSvc( "",             name ),
+  m_pSvcLocator( pSvcLocator ),
+  m_filterPassed ( true  ),
+  m_isEnabled    ( true  ),
+  m_isExecuted   ( false ),
+  m_isInitialized( false ),
+  m_isFinalized  ( false ),
+  m_msg          ( msgSvc(), name )
+{
+
+  m_propertyMgr = new PropertyMgr;
+  m_subAlgms    = new AthAlgs_t;
+
+  //
+  // Property declaration
+  // 
+  declareProperty( "OutputLevel",
+		   m_outputLevel = MSG::NIL,
+		   "Algorithm output level (allowed verbosity)" );
+  m_outputLevel.declareUpdateHandler( &AthAlgorithm::initOutputLevel, this );
+  
+  declareProperty( "Enable",
+		   m_isEnabled = true,
+		   "Flag telling if a given algorithm is enabled or not" );
+  
+  declareProperty( "ErrorMax",
+		   m_errorMax = 1,
+		   "Maximum allowed number of errors before exiting" );
+
+  declareProperty( "ErrorCount",
+		   m_errorCount = 0,
+		   "Current number of encountered errors" );
+  
+  // Auditor monitoring properties
+  // Get the default setting for service auditing from the Application Mgr
+  declareProperty( "AuditAlgorithms",
+		   m_auditInit,
+		   "Switch to enable or not the auditing of algorithms" );
+  bool audit = false;
+  {
+    IProperty* appMgr = 0;
+    const bool createIfNotThere = false;
+    if ( svcLoc()->service( "ApplicationMgr", appMgr,
+			    createIfNotThere ).isSuccess() ) {
+      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,
+		   "Switch to enable or not the auditing of the "
+		   "'initialize' stage" );
+
+  declareProperty( "AuditReinitialize", 
+		   m_auditorReinitialize = audit,
+		   "Switch to enable or not the auditing of the "
+		   "'reinitialize' stage" );
+
+  declareProperty( "AuditExecute", 
+		   m_auditorExecute = audit,
+		   "Switch to enable or not the auditing of the "
+		   "'execute' stage" );
+
+  declareProperty( "AuditFinalize", 
+		   m_auditorFinalize = audit,
+		   "Switch to enable or not the auditing of the "
+		   "'finalize' stage" );
+
+  declareProperty( "AuditBeginRun", 
+		   m_auditorBeginRun = audit,
+		   "Switch to enable or not the auditing of the "
+		   "'beginRun' stage" );
+
+  declareProperty( "AuditEndRun", 
+		   m_auditorEndRun = audit,
+		   "Switch to enable or not the auditing of the "
+		   "'endRun' stage" );
+
+  declareProperty( "StoreGateSvc",
+		   m_sgSvc = StoreGateSvc_t( "StoreGateSvc", name ),
+		   "Handle to a StoreGateSvc instance: it will be used to "
+		   "retrieve data during the course of the job" );
+}
+
+// Destructor
+///////////////
+AthAlgorithm::~AthAlgorithm()
+{ 
+  msg() << MSG::VERBOSE << "Calling destructor" << endreq;
+  delete m_subAlgms;
+  delete m_propertyMgr;
+
+  if ( m_pMonitorSvc ) {
+    m_pMonitorSvc->undeclareAll( this );
+  }
+}
+
+// IAlgorithm implementation
+////////////////////////////
+StatusCode 
+AthAlgorithm::sysInitialize()
+{
+  // Bypass the initialization if algorithm has been already initialized
+  if ( m_isInitialized ) return StatusCode::SUCCESS;
+
+  // Set the Algorithm's properties
+  if ( !setProperties().isSuccess() ) return StatusCode::FAILURE;
+
+  // Bypass the initialization if algorithm has been disabled
+  // (need to do this *after* setProperties has gathered our properties)
+  if ( !isEnabled() ) return StatusCode::SUCCESS;
+
+  // Check current outputLevel to eventually inform the @c MessageSvc
+  setOutputLevel( outputLevel() );
+
+  // Reset Error count
+  m_errorCount = 0;
+
+  if ( m_auditorInitialize ) auditorSvc()->beforeInitialize(this).ignore();
+
+  // Get pointer to StoreGateSvc and cache it :
+  if ( !m_sgSvc.retrieve().isSuccess() ) {
+    msg() << MSG::ERROR 	
+	  << "Unable to retrieve pointer to ["
+	  << m_sgSvc.typeAndName() << "] !!"
+	  << endreq;
+    return StatusCode::FAILURE;
+  }
+
+  // Invoke initialize() method of the derived class inside a try/catch clause
+  try {
+    // Invoke the initialize() method of the derived class
+    StatusCode sc = initialize();
+    if( m_auditorInitialize ) auditorSvc( )->afterInitialize(this).ignore();
+    if( sc.isFailure() ) return StatusCode::FAILURE;
+
+    // Now take care of any sub-algorithm (initialize them'all)
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      if ( (*i)->sysInitialize().isFailure() ) {
+	sc = StatusCode::FAILURE;
+      }
+    }
+    if ( sc.isFailure() ) {
+      msg() << MSG::ERROR 
+	    << " sysInitialize: "
+	    << "Error initializing one or several sub-algorithms"
+	    << endreq;
+      return sc;
+    }
+
+    // Indicate that this Algorithm has been initialized to prevent duplicate
+    // attempts.
+    setInitialized( );
+    return StatusCode::SUCCESS;
+  }
+
+  catch ( const GaudiException& Exception )  {
+
+    if( m_auditorInitialize ) auditorSvc( )->afterInitialize(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysInitialize: "
+	  << " Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() );
+  }
+
+  catch( const std::exception& Exception ) {
+
+    if( m_auditorInitialize ) auditorSvc( )->afterInitialize(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysInitialize: "
+	  << " Standard std::exception is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , "*std::exception*" );
+  }
+
+  catch(...) {
+    if( m_auditorInitialize ) auditorSvc( )->afterInitialize(this).ignore();
+    
+    // (1) perform the printout
+    msg() << MSG::FATAL 
+	  << " sysInitialize: "
+	  << "UNKNOWN Exception is caught " 
+	  << endreq;
+    // (2) make record in Stat Table
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+  }
+
+  // return
+  return StatusCode::FAILURE;
+}
+
+// IAlgorithm implementation
+StatusCode 
+AthAlgorithm::sysReinitialize() 
+{
+  // Bypass the initialization if the algorithm is disabled.
+  if ( !isEnabled( ) ) return StatusCode::SUCCESS;
+
+  // Set the Algorithm's properties
+  if( !setProperties().isSuccess() ) return StatusCode::FAILURE;
+
+  // Check current outputLevel to evetually inform the MessagsSvc
+  setOutputLevel( outputLevel() );
+
+  // Reset Error count
+  m_errorCount = 0;
+
+  if( m_auditorReinitialize ) auditorSvc( )->beforeReinitialize(this).ignore();
+
+  // Invoke reinitialize() method of the derived class inside 
+  // a try/catch clause
+  try {
+
+    // Invoke the reinitialize() method of the derived class
+    StatusCode sc = reinitialize();
+    if( m_auditorReinitialize ) {
+      auditorSvc( )->afterReinitialize(this).ignore();
+    }
+
+    if( !sc.isSuccess() ) return StatusCode::FAILURE;
+
+    // Now initialize care of any sub-algorithms
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      if ( (*i)->sysReinitialize().isFailure() ) {
+	sc = StatusCode::FAILURE;
+      }
+    }
+    if( sc.isFailure() ) {
+      msg() << MSG::ERROR 
+	    << " sysReinitialize: "
+	    << "Error initializing one or several sub-algorithms"
+          << endreq;
+      return sc;
+    }
+
+    // Indicate that this Algorithm has been initialized to prevent duplicate
+    // attempts.
+    setInitialized( );
+    return StatusCode::SUCCESS;
+  }
+
+  catch ( const GaudiException& Exception )  {
+
+    if( m_auditorReinitialize ) {
+      auditorSvc( )->afterReinitialize(this).ignore();
+    }
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysReinitialize: "
+	  << "Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() );
+  }
+
+  catch( const std::exception& Exception ) {
+
+    if( m_auditorReinitialize ) {
+      auditorSvc( )->afterReinitialize(this).ignore();
+    }
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysReinitialize: "
+	  << "Standard std::exception is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , "*std::exception*" );
+  }
+
+  catch(...) {
+    
+    if( m_auditorReinitialize ) {
+      auditorSvc( )->afterReinitialize(this).ignore();
+    }
+
+    // (1) perform the printout
+    msg() << MSG::FATAL 
+	  << " sysReinitialize: "
+	  << "UNKNOWN Exception is caught " 
+	  << endreq;
+
+    // (2) make record in Stat Table
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+  }
+
+  // return
+  return StatusCode::FAILURE;
+}
+
+StatusCode 
+AthAlgorithm::reinitialize() 
+{
+  return StatusCode::SUCCESS;
+}
+
+// IAlgorithm implementation
+StatusCode 
+AthAlgorithm::sysBeginRun() 
+{
+  // Bypass the beginRun if the algorithm is disabled.
+  if ( !isEnabled( ) ) return StatusCode::SUCCESS;
+
+  // Check current outputLevel to evetually inform the MessagsSvc
+  setOutputLevel( m_outputLevel );
+  
+  // Reset Error count
+  m_errorCount = 0;
+
+  StatusCode sc;
+  if( m_auditorBeginRun ) auditorSvc( )->beforeBeginRun(this).ignore();
+
+  // Invoke beginRun() method of the derived class inside a try/catch clause
+  try {
+
+    // Invoke the beginRun() method of the derived class
+    sc = beginRun();
+    if( m_auditorBeginRun ) auditorSvc( )->afterBeginRun(this).ignore();
+    if( sc.isFailure() ) return StatusCode::FAILURE;
+
+    // Now call beginRun for any sub-algorithms
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      if ( (*i)->sysBeginRun().isFailure() ) {
+	sc = StatusCode::FAILURE;
+      }
+    }
+    if( sc.isFailure() ) {
+      msg() << MSG::ERROR 
+	    << " sysBeginRun:"
+	    << " Error executing BeginRun for one or several sub-algorithms"
+	    << endreq;
+      return sc;
+    }
+    return StatusCode::SUCCESS;
+  }
+
+  catch ( const GaudiException& Exception )  {
+
+    if( m_auditorBeginRun ) auditorSvc( )->afterBeginRun(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysBeginRun:"
+	  << " Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() );
+  }
+
+  catch( const std::exception& Exception ) {
+
+    if( m_auditorBeginRun ) auditorSvc( )->afterBeginRun(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL
+	  << " sysBeginRun:"
+	  << " Standard std::exception is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , "*std::exception*" );
+  }
+
+  catch(...) {
+
+    if( m_auditorBeginRun ) auditorSvc( )->afterBeginRun(this).ignore();
+
+    // (1) perform the printout
+    msg() << MSG::FATAL 
+	  << " sysBeginRun:"
+	  << "UNKNOWN Exception is caught " 
+	  << endreq;
+
+    // (2) make record in Stat Table
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+  }
+
+  return StatusCode::FAILURE;
+}
+  
+StatusCode 
+AthAlgorithm::beginRun() 
+{
+  return StatusCode::SUCCESS;
+}
+
+// IAlgorithm implementation
+StatusCode 
+AthAlgorithm::sysEndRun() 
+{
+  // Bypass the endRun if the algorithm is disabled.
+  if ( !isEnabled( ) ) return StatusCode::SUCCESS;
+
+  // Check current outputLevel to eventually inform the MessagsSvc
+  setOutputLevel( m_outputLevel );
+  
+  // Reset Error count
+  m_errorCount = 0;
+
+  // Invoke endRun() method of the derived class inside a try/catch clause
+  StatusCode sc;
+  if( m_auditorEndRun ) auditorSvc( )->beforeEndRun(this).ignore();
+  try {
+    // Invoke the endRun() method of the derived class
+    sc = endRun();
+    if( m_auditorEndRun ) auditorSvc( )->afterEndRun(this).ignore();
+    if( sc.isFailure() ) return StatusCode::FAILURE;
+
+    // Now call endRun for any sub-algorithms
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      if ( (*i)->sysEndRun().isFailure() ) {
+	sc = StatusCode::FAILURE;
+      }
+    }
+    if( sc.isFailure() ) {
+      msg() << MSG::ERROR 
+	    << " sysEndRun:"
+	    << " Error calling endRun for one or several sub-algorithms"
+	    << endreq;
+      return sc;
+    }
+    return StatusCode::SUCCESS;
+  }
+
+  catch ( const GaudiException& Exception )  {
+
+    if ( m_auditorEndRun ) auditorSvc( )->afterEndRun(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL
+	  << " sysEndRun:"
+	  << " Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() );
+  }
+
+  catch ( const std::exception& Exception ) {
+    if ( m_auditorEndRun ) auditorSvc( )->afterEndRun(this).ignore();
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysEndRun:"
+	  << " Standard std::exception is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself (NB!  - GaudiException is a linked list
+    // of all "previous exceptions")
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , "*std::exception*" );
+  }
+
+  catch (...) {
+
+    if ( m_auditorEndRun ) auditorSvc( )->afterEndRun(this).ignore();
+
+    // (1) perform the printout
+    msg() << MSG::FATAL 
+	  << " sysEndRun: "
+	  << "UNKNOWN Exception is caught " 
+	  << endreq;
+
+    // (2) make record in Stat Table
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+  }
+
+  return StatusCode::FAILURE;
+}
+
+StatusCode
+AthAlgorithm::endRun() 
+{
+  return StatusCode::SUCCESS;
+}
+
+
+StatusCode
+AthAlgorithm::sysExecute() 
+{
+  if ( !isEnabled() ) {
+    msg() << MSG::VERBOSE 
+	  << " sysExecute : is not enabled. Skip execution" 
+	  << endreq;
+    return StatusCode::SUCCESS;
+  }
+
+  StatusCode status;
+
+  // Should performance profile be performed ?
+  // invoke execute() method of Algorithm class
+  //   and catch all uncaught exceptions
+
+  if ( m_auditorExecute ) auditorSvc( )->beforeExecute(this).ignore();
+  try {
+    status = execute();
+    setExecuted(true).ignore();  // set the executed flag regardless of the status 
+
+    if ( status.isFailure() ) {
+      status = exceptionSvc()->handleErr(*this,status);
+    }
+
+  }
+
+  catch ( const GaudiException& Exception ) {
+    // set the executed flag regardless of the status 
+    setExecuted(true).ignore();
+
+    if ( Exception.code() == StatusCode::FAILURE ) {
+      msg() << MSG::FATAL << " sysExecute: ";
+    } else {
+      msg() << MSG::ERROR << " sysExecute: Recoverable";
+    }
+
+    msg() << " Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+
+    msg() << MSG::ERROR << Exception  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() ) ;
+    status = exceptionSvc()->handle(*this,Exception);
+  }
+
+  catch ( const std::exception& Exception ) {
+    // set the executed flag regardless of the status 
+    setExecuted(true).ignore();
+
+    msg() << MSG::FATAL 
+	  << " sysExecute:"
+	  << " Standard std::exception is caught " << endreq;
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+    Stat stat( chronoSvc() , "*std::exception*" ) ;
+    status = exceptionSvc()->handle(*this,Exception);
+  }
+
+  catch (...) {
+    // set the executed flag regardless of the status 
+    setExecuted(true).ignore();
+
+    msg() << MSG::FATAL 
+	  << " sysExecute: "
+	  << "UNKNOWN Exception is caught " << endreq;
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+
+    status = exceptionSvc()->handle(*this);
+  }
+
+  if ( m_auditorExecute ) auditorSvc( )->afterExecute(this, status).ignore();
+
+
+  if ( status.isFailure() ) {
+    // Increment the error count
+    m_errorCount++;
+    // Check if maximum is exeeded
+    if ( m_errorCount < m_errorMax ) {
+      msg() << MSG::WARNING << "Continuing from error (cnt=" << m_errorCount
+	    << ", max=" << m_errorMax << ")" << endreq;
+      // convert to success
+      status = StatusCode::SUCCESS;
+    }
+  }
+  return status;
+}
+
+//StatusCode Algorithm::execute() {
+//  return StatusCode::SUCCESS;
+//}
+
+StatusCode 
+AthAlgorithm::sysFinalize() 
+{
+
+  // Bypass the finalialization if the algorithm hasn't been initialized or
+  // has already been finalialized.
+  if ( !isInitialized( ) || isFinalized( ) ) return StatusCode::SUCCESS;
+
+  // Invoke finalize() method of the derived class inside a try/catch clause
+  StatusCode sc = StatusCode::SUCCESS;
+  try {
+    // Order changed (bug #3903 overview: finalize any nested algorithms)
+    // Finalize first any sub-algoithms (it can be done more than once)
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      (*i)->sysFinalize().ignore();
+    }
+    
+    // Invoke the finalize() method of the derived class
+    if ( m_auditorFinalize ) auditorSvc( )->beforeFinalize(this).ignore();
+    sc = finalize();
+    if ( m_auditorFinalize ) auditorSvc( )->afterFinalize(this).ignore();
+    if ( !sc.isSuccess() )  return StatusCode::FAILURE;
+
+    // Release all sub-algorithms
+    for ( AthAlgs_t::iterator 
+	    i    = m_subAlgms->begin(),
+	    iEnd = m_subAlgms->end(); 
+	  i != iEnd; 
+	  ++i ) {
+      (*i)->release();
+    }
+    // Indicate that this Algorithm has been finalized to 
+    // prevent duplicate attempts
+    setFinalized( );
+    return sc;
+  }
+
+  catch ( const GaudiException& Exception ) {
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysFinalize:"
+	  << " Exception with tag=" << Exception.tag()
+	  << " is caught " 
+	  << endreq;
+
+    // (2) print  the exception itself
+    //    (NB!  - GaudiException is a linked list of all "previous exceptions")
+    msg() << MSG::ERROR << Exception  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , Exception.tag() ) ;
+  }
+
+  catch ( const std::exception& Exception ) {
+
+    // (1) perform the printout of message
+    msg() << MSG::FATAL 
+	  << " sysFinalize:"
+	  << " Standard std::exception is caught " 
+	  << endreq;
+    // (2) print  the exception itself
+    msg() << MSG::ERROR << Exception.what()  << endreq;
+
+    // (3) make record in Stat Table
+    Stat stat( chronoSvc() , "*std::exception*" ) ;
+  }
+
+  catch (...) {
+
+    // (1) perform the printout
+    msg() << MSG::FATAL 
+	  << " sysFinalize: "
+	  << "UNKNOWN Exception is caught " 
+	  << endreq;
+
+    // (2) make record in Stat Table
+    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+  }
+  return StatusCode::FAILURE ;
+}
+
+const std::string& 
+AthAlgorithm::name() const 
+{
+  return m_name;
+}
+
+const std::string& 
+AthAlgorithm::version() const 
+{
+  return m_version;
+}
+
+bool AthAlgorithm::isExecuted() const 
+{
+  return m_isExecuted;
+}
+
+StatusCode 
+AthAlgorithm::setExecuted( bool state ) 
+{
+  m_isExecuted = state;
+  return StatusCode::SUCCESS;
+}
+
+StatusCode 
+AthAlgorithm::resetExecuted() 
+{
+  m_isExecuted   = false;
+  m_filterPassed = true;
+  return StatusCode::SUCCESS;
+}
+
+bool 
+AthAlgorithm::isEnabled() const 
+{
+  return m_isEnabled;
+}
+
+bool 
+AthAlgorithm::filterPassed() const 
+{
+  return m_filterPassed;
+}
+
+StatusCode 
+AthAlgorithm::setFilterPassed( bool state ) 
+{
+  m_filterPassed = state;
+  return StatusCode::SUCCESS;
+}
+
+AthAlgs_t* 
+AthAlgorithm::subAlgorithms( ) const 
+{
+  return m_subAlgms;
+}
+
+void 
+AthAlgorithm::setOutputLevel( int level ) 
+{
+  if ( 0 != msgSvc() ) {
+    if ( MSG::NIL != level ) { 
+      msgSvc()->setOutputLevel( name(), level ) ; 
+    }
+    m_outputLevel = msgSvc()->outputLevel( name() );
+  }
+}
+
+IAuditorSvc* 
+AthAlgorithm::auditorSvc() const 
+{
+  return &*m_pAuditorSvc;
+}
+
+IChronoStatSvc* 
+AthAlgorithm::chronoSvc() const 
+{
+  return &*m_CSS;
+}
+
+IHistogramSvc* 
+AthAlgorithm::histoSvc() const 
+{
+  return &*m_HDS;
+}
+
+IExceptionSvc* 
+AthAlgorithm::exceptionSvc() const 
+{
+  return &*m_EXS;
+}
+
+IMessageSvc* 
+AthAlgorithm::msgSvc() const 
+{
+  return &*m_MS;
+}
+
+INTupleSvc* 
+AthAlgorithm::ntupleSvc() const 
+{
+  return &*m_NTS;
+}
+
+IToolSvc* 
+AthAlgorithm::toolSvc() const 
+{
+  return &*m_pToolSvc;
+}
+
+ISvcLocator * 
+AthAlgorithm::serviceLocator() const 
+{
+  return m_pSvcLocator;
+}
+
+// IInterface implementation
+unsigned long 
+AthAlgorithm::addRef() 
+{
+  return ++m_refCount;
+}
+
+unsigned long 
+AthAlgorithm::release() 
+{
+  long count = --m_refCount;
+  if( count <= 0) {
+    delete this;
+  }
+  return count;
+}
+
+// Retrieve the interface requested and check its version compatibility
+StatusCode 
+AthAlgorithm::queryInterface( const InterfaceID& iid    , 
+			      void**             ppISvc ) 
+{
+  if ( 0 == ppISvc ) { return StatusCode::FAILURE ; }   // RETURN 
+  //
+	if      ( IAlgorithm ::interfaceID()      . versionMatch ( iid ) ) 
+  { *ppISvc = static_cast<IAlgorithm*>      ( this ) ; }
+	else if ( IProperty  ::interfaceID()      . versionMatch ( iid ) ) 
+  { *ppISvc = static_cast<IProperty*>       ( this ) ; }
+  else if ( INamedInterface ::interfaceID() . versionMatch ( iid ) ) 
+  { *ppISvc = static_cast<INamedInterface*> ( this ) ; }
+  else if ( IInterface ::interfaceID()      . versionMatch ( iid ) ) 
+  { *ppISvc = static_cast<IInterface*>      ( this ) ; }
+	else { *ppISvc = 0 ; return StatusCode::FAILURE; }    // RETURN 
+  // increment the reference 
+  addRef();
+  
+  return StatusCode::SUCCESS;
+}
+
+// Use the job options service to set declared properties
+StatusCode 
+AthAlgorithm::setProperties() 
+{
+  if( 0 != m_pSvcLocator )    {
+    IJobOptionsSvc* jos = 0;
+    StatusCode sc = m_pSvcLocator->getService( "JobOptionsSvc", 
+					       IID_IJobOptionsSvc, 
+					       (IInterface*&) jos );
+    if( sc.isSuccess() )    {
+      // set first generic Properties
+      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;
+	}
+      }
+      jos->release();
+      return sc;
+    }
+  }
+
+  return StatusCode::FAILURE;
+}
+
+StatusCode 
+AthAlgorithm::createSubAlgorithm( const std::string& type,
+				  const std::string& name,
+				  AthAlgorithm*& pSubAlgorithm ) 
+{
+  if( 0 == m_pSvcLocator ) return StatusCode::FAILURE;
+
+  IAlgManager* am;
+  StatusCode sc = m_pSvcLocator->getService( "", 
+					     IID_IAlgManager,
+					     (IInterface*&) am );
+  if( sc.isFailure() ) return StatusCode::FAILURE;
+
+  // Maybe modify the AppMgr interface to return AthAlgorithm* ??
+  IAlgorithm *tmp = 0;
+  sc = am->createAlgorithm( type, 
+			    name +
+			    getGaudiThreadIDfromName(AthAlgorithm::name()),
+			    tmp );
+  if( sc.isFailure() ) return StatusCode::FAILURE;
+
+  am->release();
+  
+  try{
+    pSubAlgorithm = dynamic_cast<AthAlgorithm*>(tmp);
+    m_subAlgms->push_back(pSubAlgorithm);	
+  } 
+  catch(...) {
+    sc = StatusCode::FAILURE;
+  }
+  
+  return sc;
+}
+
+// IProperty implementation
+// Delegate to the Property manager
+StatusCode
+AthAlgorithm::setProperty( const Property& p ) 
+{
+  return m_propertyMgr->setProperty(p);
+}
+
+StatusCode
+AthAlgorithm::setProperty( const std::string& s )
+{
+  return m_propertyMgr->setProperty(s);
+}
+
+StatusCode
+AthAlgorithm::setProperty( const std::string& n, const std::string& v )
+{
+  return m_propertyMgr->setProperty(n,v);
+}
+
+StatusCode 
+AthAlgorithm::getProperty( Property* p ) const 
+{
+  return m_propertyMgr->getProperty(p);
+}
+
+const Property& 
+AthAlgorithm::getProperty( const std::string& name ) const
+{
+  return m_propertyMgr->getProperty(name);
+}
+
+StatusCode 
+AthAlgorithm::getProperty(const std::string& n, std::string& v ) const 
+{
+  return m_propertyMgr->getProperty(n,v);
+}
+
+const std::vector<Property*>& 
+AthAlgorithm::getProperties( ) const 
+{
+  return m_propertyMgr->getProperties();
+}
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+/////////////////////////////////////////////////////////////////// 
+
+/////////////////////////////////////////////////////////////////// 
+// Protected methods: 
+/////////////////////////////////////////////////////////////////// 
+
+bool AthAlgorithm::isInitialized( ) const 
+{
+  return m_isInitialized;
+}
+
+void AthAlgorithm::setInitialized( ) 
+{
+  m_isInitialized = true;
+}
+
+bool
+AthAlgorithm::isFinalized( ) const
+{
+  return m_isFinalized;
+}
+
+void
+AthAlgorithm::setFinalized( )
+{
+  m_isFinalized = true;
+}
+
+void 
+AthAlgorithm::initOutputLevel(Property& /*prop*/) 
+{
+  m_msg.setLevel( outputLevel() );
+}
+
+StatusCode 
+AthAlgorithm::service_i( const std::string& svcName,
+			 bool createIf,
+			 const InterfaceID& iid,
+			 void** ppSvc ) const 
+{
+  ServiceLocatorHelper helper(*serviceLocator(), msg(), name());
+  return helper.getService(svcName, createIf, iid, ppSvc);
+}
+
+StatusCode 
+AthAlgorithm::service_i( const std::string& svcType,
+			 const std::string& svcName,
+			 const InterfaceID& iid,
+			 void** ppSvc ) const 
+{
+  ServiceLocatorHelper helper(*serviceLocator(), msg(), name());
+  return  helper.createService(svcType, svcName, iid, ppSvc);
+}
+
+StatusCode AthAlgorithm::setStoreGateSvc( const std::string& sgName ) 
+{
+  m_sgSvc.setName(sgName);
+  return m_sgSvc.retrieve();
+}
+

src/AthService.cxx

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthService.cxx 
+// Implementation file for class AthService
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+
+
+// STL includes
+
+// FrameWork includes
+
+// AthenaBaseComps includes
+#include "AthenaBaseComps/AthService.h"
+
+/////////////////////////////////////////////////////////////////// 
+// Public methods: 
+/////////////////////////////////////////////////////////////////// 
+
+// Constructors
+////////////////
+AthService::AthService( const std::string& name, 
+			ISvcLocator* pSvcLocator ) : 
+  Service( name, pSvcLocator ),
+  m_msg  ( msgSvc(),    name )
+{
+  //
+  // Property declaration
+  // 
+  //declareProperty( "Property", m_nProperty, "descr" );
+
+}
+
+// Destructor
+///////////////
+AthService::~AthService()
+{ 
+  msg() << MSG::DEBUG << "Calling destructor" << endreq;
+}
+
+StatusCode AthService::sysInitialize()
+{
+  // configure our MsgStream
+  m_msg.setLevel( m_outputLevel.value() );
+
+  return Service::sysInitialize();
+}
+
+StatusCode AthService::sysFinalize()
+{
+  return Service::sysFinalize();
+}
+
+StatusCode 
+AthService::queryInterface( const InterfaceID& riid, 
+			    void**             ppvi )
+{
+  return Service::queryInterface( riid, ppvi );
+}
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+/////////////////////////////////////////////////////////////////// 
+
+/////////////////////////////////////////////////////////////////// 
+// Protected methods: 
+/////////////////////////////////////////////////////////////////// 
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+///////////////////////////////////////////////////////////////////