Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011

GaudiAlgorithm.h

Go to the documentation of this file.
00001 // $Id: GaudiAlgorithm.h,v 1.19 2008/11/04 22:49:25 marcocle Exp $
00002 // ============================================================================
00003 #ifndef GAUDIALG_GaudiAlgorithm_H
00004 #define GAUDIALG_GaudiAlgorithm_H 1
00005 // ============================================================================
00006 // Include files
00007 // ============================================================================
00008 #include <vector>
00009 #include <string>
00010 // ============================================================================
00011 // GaudiKernel
00012 // ============================================================================
00013 #include "GaudiKernel/Algorithm.h"
00014 // ============================================================================
00015 // GaudiAlg
00016 // ============================================================================
00017 #include "GaudiAlg/GaudiAlg.h"
00018 #include "GaudiAlg/GaudiCommon.h"
00019 // ============================================================================
00020 // forward declarations:
00021 // ============================================================================
00022 class                   INTupleSvc     ; // GaudiKernel
00023 template<class T> class  AlgFactory    ; // GaudiKernel
00024 // ============================================================================
00025 /* @file GaudiAlgorithm.h
00026  *
00027  * Header file for class GaudiAlgorithm.
00028  * The actual code is mainly imported from
00029  *   - LHCb Calorimeter software and
00030  *   - LHCb C++ toolkit for smart and friendly physics analysis "LoKi"
00031  *
00032  *  This base class allows "easy"(=="1 line") access to tools
00033  *  and services. This access is safe in the sense that there
00034  *  is no need to worry about the reference counts for tools
00035  *  and services.
00036  *
00037  *  The base class allows "easy" (=="1 line") access to data in
00038  *  Gaudi Transient Stores. The functionality includes the checking
00039  *  of the presence of the data at the given location, checking the
00040  *  validity of the data, retrieval of valid data and "forced" retrieve
00041  *  of valid data (create if there is no data).
00042  *
00043  *  The base class allows to perform an easy error, warning and exception
00044  *  treatments, including the accumulated statistics of exceptions, errors
00045  *  and warnings.
00046  *
00047  *  The base class also includes utilities for general statistical counters.
00048  *
00049  *  It has been reported that usage of this base class results in
00050  *  significant shrinkage of existing code lines.
00051  *
00052  *  @attention
00053  *  See also the class GaudiCommon, which implements some of the common
00054  *  functionality between GaudiTool and GaudiAlgorithm.
00055  *
00056  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
00057  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
00058  *  @date 30/06/2001
00059  */
00060 // ============================================================================
00094 // ============================================================================
00095 class GAUDI_API GaudiAlgorithm: public GaudiCommon<Algorithm>
00096 {
00097   // friend factory for instantiation
00098   friend class AlgFactory<GaudiAlgorithm>;
00099 public:
00100   // ==========================================================================
00106   virtual StatusCode initialize();
00107   // ==========================================================================
00113   virtual StatusCode execute   ();
00114   // ==========================================================================
00120   virtual StatusCode finalize  ();
00121   // ==========================================================================
00128   virtual StatusCode sysExecute () ;
00129   // ==========================================================================
00130 public:
00131 
00132   // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
00133   // and detDvc() ) that are not members of AlgTool.
00134   // Also some methods seem which are members of the base class do not seem
00135   // to be found unless forwarding methods are put here ??
00136 
00169   inline void put ( IDataProviderSvc*  svc     ,
00170                     DataObject*        object  ,
00171                     const std::string& address ,
00172                     const bool useRootInTES = true ) const
00173   {
00174     GaudiCommon<Algorithm>::put ( svc , object , address , useRootInTES ) ;
00175   }
00176 
00208   inline void put ( DataObject*        object   ,
00209                     const std::string& address  ,
00210                     const bool useRootInTES = true ) const
00211   {
00212     GaudiCommon<Algorithm>::put ( evtSvc() , object , address , useRootInTES ) ;
00213   }
00214 
00247   template < class TYPE  >
00248   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00249   get  ( IDataProviderSvc*  svc       ,
00250          const std::string& location  ,
00251          const bool useRootInTES = true ) const
00252   {
00253     return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , useRootInTES ) ;
00254   }
00255 
00282   template < class TYPE  >
00283   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00284   get  ( const std::string& location,
00285          const bool useRootInTES = true ) const
00286   {
00287     return GaudiCommon<Algorithm>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
00288   }
00289 
00308   template < class TYPE  >
00309   inline TYPE* getDet ( IDataProviderSvc*  svc        ,
00310                         const std::string& location   ) const
00311   {
00312     return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , false ) ;
00313   }
00314 
00332   template < class TYPE  >
00333   inline TYPE* getDet ( const std::string& location   ) const
00334   {
00335     return GaudiCommon<Algorithm>::get<TYPE> ( detSvc() , location , false ) ;
00336   }
00337 
00364   template < class TYPE  >
00365   inline bool  exist    ( IDataProviderSvc*  svc      ,
00366                           const std::string& location ,
00367                           const bool useRootInTES = true ) const
00368   {
00369     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , useRootInTES ) ;
00370   }
00371 
00397   template < class TYPE  >
00398   inline bool  exist    ( const std::string& location ,
00399                           const bool useRootInTES = true ) const
00400   {
00401     return GaudiCommon<Algorithm>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
00402   }
00403 
00420   template < class TYPE  >
00421   inline bool  existDet    ( IDataProviderSvc*  svc      ,
00422                              const std::string& location ) const
00423   {
00424     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , false ) ;
00425   }
00426 
00442   template < class TYPE  >
00443   inline bool  existDet    ( const std::string& location ) const
00444   {
00445     return GaudiCommon<Algorithm>::exist<TYPE> ( detSvc() , location , false ) ;
00446   }
00447 
00475   template < class TYPE , class TYPE2 >
00476   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00477   getOrCreate ( IDataProviderSvc*  svc      ,
00478                 const std::string& location ,
00479                 const bool useRootInTES = true ) const
00480   {
00481     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
00482   }
00483 
00510   template < class TYPE , class TYPE2 >
00511   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00512   getOrCreate ( const std::string& location            ,
00513                 const bool         useRootInTES = true ) const
00514   {
00515     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
00516   }
00517 public:
00518   // ==========================================================================
00524   GaudiAlgorithm ( const std::string& name        ,
00525                    ISvcLocator*       pSvcLocator );
00526   // ==========================================================================
00528   virtual ~GaudiAlgorithm();
00529   // ==========================================================================
00530 public:
00531   // ==========================================================================
00535   SmartIF<INTupleSvc>&     evtColSvc  () const;
00536   // ==========================================================================
00537 private:
00538   // ==========================================================================
00539   // no public default constructor
00540   GaudiAlgorithm(); 
00541   // ==========================================================================
00542   // no public copy constructor
00543   GaudiAlgorithm             ( const GaudiAlgorithm& ); 
00544   // ==========================================================================
00545   // no public assignment operator
00546   GaudiAlgorithm& operator = ( const GaudiAlgorithm& ); 
00547   // ==========================================================================
00548 private:
00549   // ==========================================================================
00550   // Pointer to the Event Tag Collection Service
00551   mutable SmartIF<INTupleSvc> m_evtColSvc ; 
00552 
00553   std::vector<std::string> m_vetoObjs;
00555   std::vector<std::string> m_requireObjs;
00556   // ==========================================================================
00557 };
00558 // ============================================================================
00559 // The END
00560 // ============================================================================
00561 #endif // GAUDIALG_GaudiAlgorithm_H
00562 // ============================================================================
00563 
00564 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:53:18 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004