Gaudi Framework, version v23r3

Home   Generated: Thu Jun 28 2012

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 
00259   template < class TYPE  >
00260   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00261   getIfExists ( IDataProviderSvc*  svc       ,
00262                 const std::string& location  ,
00263                 const bool useRootInTES = true ) const
00264   {
00265     return GaudiCommon<Algorithm>::getIfExists<TYPE> ( svc , location , useRootInTES ) ;
00266   }
00267 
00294   template < class TYPE  >
00295   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00296   get  ( const std::string& location,
00297          const bool useRootInTES = true ) const
00298   {
00299     return GaudiCommon<Algorithm>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
00300   }
00301 
00305   template < class TYPE  >
00306   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00307   getIfExists ( const std::string& location  ,
00308                 const bool useRootInTES = true ) const
00309   {
00310     return GaudiCommon<Algorithm>::getIfExists<TYPE> ( evtSvc() , location , useRootInTES ) ;
00311   }
00312 
00331   template < class TYPE  >
00332   inline TYPE* getDet ( IDataProviderSvc*  svc        ,
00333                         const std::string& location   ) const
00334   {
00335     return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , false ) ;
00336   }
00337 
00341   template < class TYPE  >
00342   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00343   getDetIfExists ( IDataProviderSvc*  svc       ,
00344                    const std::string& location  ) const
00345   {
00346     return GaudiCommon<Algorithm>::getIfExists<TYPE> ( svc , location , false ) ;
00347   }
00348 
00366   template < class TYPE  >
00367   inline TYPE* getDet ( const std::string& location   ) const
00368   {
00369     return GaudiCommon<Algorithm>::get<TYPE> ( detSvc() , location , false ) ;
00370   }
00371 
00375   template < class TYPE  >
00376   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00377   getDetIfExists ( const std::string& location  ) const
00378   {
00379     return GaudiCommon<Algorithm>::getIfExists<TYPE> ( detSvc() , location , false ) ;
00380   }
00381 
00408   template < class TYPE  >
00409   inline bool  exist    ( IDataProviderSvc*  svc      ,
00410                           const std::string& location ,
00411                           const bool useRootInTES = true ) const
00412   {
00413     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , useRootInTES ) ;
00414   }
00415 
00441   template < class TYPE  >
00442   inline bool  exist    ( const std::string& location ,
00443                           const bool useRootInTES = true ) const
00444   {
00445     return GaudiCommon<Algorithm>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
00446   }
00447 
00464   template < class TYPE  >
00465   inline bool  existDet    ( IDataProviderSvc*  svc      ,
00466                              const std::string& location ) const
00467   {
00468     return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , false ) ;
00469   }
00470 
00486   template < class TYPE  >
00487   inline bool  existDet    ( const std::string& location ) const
00488   {
00489     return GaudiCommon<Algorithm>::exist<TYPE> ( detSvc() , location , false ) ;
00490   }
00491 
00519   template < class TYPE , class TYPE2 >
00520   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00521   getOrCreate ( IDataProviderSvc*  svc      ,
00522                 const std::string& location ,
00523                 const bool useRootInTES = true ) const
00524   {
00525     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
00526   }
00527 
00554   template < class TYPE , class TYPE2 >
00555   inline typename Gaudi::Utils::GetData<TYPE>::return_type
00556   getOrCreate ( const std::string& location            ,
00557                 const bool         useRootInTES = true ) const
00558   {
00559     return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
00560   }
00561 public:
00562   // ==========================================================================
00568   GaudiAlgorithm ( const std::string& name        ,
00569                    ISvcLocator*       pSvcLocator );
00570   // ==========================================================================
00572   virtual ~GaudiAlgorithm();
00573   // ==========================================================================
00574 public:
00575   // ==========================================================================
00579   SmartIF<INTupleSvc>&     evtColSvc  () const;
00580   // ==========================================================================
00581 private:
00582   // ==========================================================================
00583   // no public default constructor
00584   GaudiAlgorithm(); 
00585   // ==========================================================================
00586   // no public copy constructor
00587   GaudiAlgorithm             ( const GaudiAlgorithm& ); 
00588   // ==========================================================================
00589   // no public assignment operator
00590   GaudiAlgorithm& operator = ( const GaudiAlgorithm& ); 
00591   // ==========================================================================
00592 private:
00593   // ==========================================================================
00594   // Pointer to the Event Tag Collection Service
00595   mutable SmartIF<INTupleSvc> m_evtColSvc ; 
00596 
00597   std::vector<std::string> m_vetoObjs;
00599   std::vector<std::string> m_requireObjs;
00600   // ==========================================================================
00601 };
00602 // ============================================================================
00603 // The END
00604 // ============================================================================
00605 #endif // GAUDIALG_GaudiAlgorithm_H
00606 // ============================================================================
00607 
00608 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 12:29:51 for Gaudi Framework, version v23r3 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004