All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiAlgorithm.h
Go to the documentation of this file.
1 // $Id: GaudiAlgorithm.h,v 1.19 2008/11/04 22:49:25 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIALG_GaudiAlgorithm_H
4 #define GAUDIALG_GaudiAlgorithm_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 #include <vector>
9 #include <string>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/Algorithm.h"
14 // ============================================================================
15 // GaudiAlg
16 // ============================================================================
17 #include "GaudiAlg/GaudiAlg.h"
18 #include "GaudiAlg/GaudiCommon.h"
19 // ============================================================================
20 // forward declarations:
21 // ============================================================================
22 class INTupleSvc ; // GaudiKernel
23 // ============================================================================
24 /* @file GaudiAlgorithm.h
25  *
26  * Header file for class GaudiAlgorithm.
27  * The actual code is mainly imported from
28  * - LHCb Calorimeter software and
29  * - LHCb C++ toolkit for smart and friendly physics analysis "LoKi"
30  *
31  * This base class allows "easy"(=="1 line") access to tools
32  * and services. This access is safe in the sense that there
33  * is no need to worry about the reference counts for tools
34  * and services.
35  *
36  * The base class allows "easy" (=="1 line") access to data in
37  * Gaudi Transient Stores. The functionality includes the checking
38  * of the presence of the data at the given location, checking the
39  * validity of the data, retrieval of valid data and "forced" retrieve
40  * of valid data (create if there is no data).
41  *
42  * The base class allows to perform an easy error, warning and exception
43  * treatments, including the accumulated statistics of exceptions, errors
44  * and warnings.
45  *
46  * The base class also includes utilities for general statistical counters.
47  *
48  * It has been reported that usage of this base class results in
49  * significant shrinkage of existing code lines.
50  *
51  * @attention
52  * See also the class GaudiCommon, which implements some of the common
53  * functionality between GaudiTool and GaudiAlgorithm.
54  *
55  * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
56  * @author Chris Jones Christopher.Rob.Jones@cern.ch
57  * @date 30/06/2001
58  */
59 // ============================================================================
93 // ============================================================================
94 class GAUDI_API GaudiAlgorithm: public GaudiCommon<Algorithm>
95 {
96 public:
97  // ==========================================================================
103  virtual StatusCode initialize();
104  // ==========================================================================
110  virtual StatusCode execute ();
111  // ==========================================================================
117  virtual StatusCode finalize ();
118  // ==========================================================================
125  virtual StatusCode sysExecute () ;
126  // ==========================================================================
127 public:
128 
129  // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
130  // and detDvc() ) that are not members of AlgTool.
131  // Also some methods seem which are members of the base class do not seem
132  // to be found unless forwarding methods are put here ??
133 
166  inline void put ( IDataProviderSvc* svc ,
167  DataObject* object ,
168  const std::string& address ,
169  const bool useRootInTES = true ) const
170  {
171  GaudiCommon<Algorithm>::put ( svc , object , address , useRootInTES ) ;
172  }
173 
205  inline void put ( DataObject* object ,
206  const std::string& address ,
207  const bool useRootInTES = true ) const
208  {
209  GaudiCommon<Algorithm>::put ( evtSvc() , object , address , useRootInTES ) ;
210  }
211 
244  template < class TYPE >
247  const std::string& location ,
248  const bool useRootInTES = true ) const
249  {
250  return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , useRootInTES ) ;
251  }
252 
286  template < class TYPE >
289  const std::string& location ,
290  const bool useRootInTES = true ) const
291  {
292  return GaudiCommon<Algorithm>::getIfExists<TYPE> ( svc , location , useRootInTES ) ;
293  }
294 
321  template < class TYPE >
323  get ( const std::string& location,
324  const bool useRootInTES = true ) const
325  {
326  return GaudiCommon<Algorithm>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
327  }
328 
361  template < class TYPE >
363  getIfExists ( const std::string& location ,
364  const bool useRootInTES = true ) const
365  {
366  return GaudiCommon<Algorithm>::getIfExists<TYPE> ( evtSvc() , location , useRootInTES ) ;
367  }
368 
387  template < class TYPE >
388  inline TYPE* getDet ( IDataProviderSvc* svc ,
389  const std::string& location ) const
390  {
391  return GaudiCommon<Algorithm>::get<TYPE> ( svc , location , false ) ;
392  }
393 
416  template < class TYPE >
419  const std::string& location ) const
420  {
421  return GaudiCommon<Algorithm>::getIfExists<TYPE> ( svc , location , false ) ;
422  }
423 
441  template < class TYPE >
442  inline TYPE* getDet ( const std::string& location ) const
443  {
444  return GaudiCommon<Algorithm>::get<TYPE> ( detSvc() , location , false ) ;
445  }
446 
468  template < class TYPE >
470  getDetIfExists ( const std::string& location ) const
471  {
472  return GaudiCommon<Algorithm>::getIfExists<TYPE> ( detSvc() , location , false ) ;
473  }
474 
501  template < class TYPE >
502  inline bool exist ( IDataProviderSvc* svc ,
503  const std::string& location ,
504  const bool useRootInTES = true ) const
505  {
506  return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , useRootInTES ) ;
507  }
508 
534  template < class TYPE >
535  inline bool exist ( const std::string& location ,
536  const bool useRootInTES = true ) const
537  {
538  return GaudiCommon<Algorithm>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
539  }
540 
557  template < class TYPE >
558  inline bool existDet ( IDataProviderSvc* svc ,
559  const std::string& location ) const
560  {
561  return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location , false ) ;
562  }
563 
579  template < class TYPE >
580  inline bool existDet ( const std::string& location ) const
581  {
582  return GaudiCommon<Algorithm>::exist<TYPE> ( detSvc() , location , false ) ;
583  }
584 
612  template < class TYPE , class TYPE2 >
615  const std::string& location ,
616  const bool useRootInTES = true ) const
617  {
618  return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
619  }
620 
647  template < class TYPE , class TYPE2 >
649  getOrCreate ( const std::string& location ,
650  const bool useRootInTES = true ) const
651  {
652  return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
653  }
654 public:
655  // ==========================================================================
661  GaudiAlgorithm ( const std::string& name ,
662  ISvcLocator* pSvcLocator );
663  // ==========================================================================
665  virtual ~GaudiAlgorithm();
666  // ==========================================================================
667 public:
668  // ==========================================================================
672  SmartIF<INTupleSvc>& evtColSvc () const;
673  // ==========================================================================
674 private:
675  // ==========================================================================
676  // no public default constructor
677  GaudiAlgorithm();
678  // ==========================================================================
679  // no public copy constructor
680  GaudiAlgorithm ( const GaudiAlgorithm& );
681  // ==========================================================================
682  // no public assignment operator
684  // ==========================================================================
685 private:
686  // ==========================================================================
687  // Pointer to the Event Tag Collection Service
689  std::vector<std::string> m_vetoObjs;
692  std::vector<std::string> m_requireObjs;
693  // ==========================================================================
694 };
695 // ============================================================================
696 // The END
697 // ============================================================================
698 #endif // GAUDIALG_GaudiAlgorithm_H
699 // ============================================================================
700 
701 
bool exist(const std::string &location, const bool useRootInTES=true) const
Check the existence of a data object or container in the Gaudi Transient Event Store.
void put(IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
SmartIF< INTupleSvc > m_evtColSvc
Event Tag Collection Service.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
DataObject * put(IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate(const std::string &location, const bool useRootInTES=true) const
Get the existing data object from Gaudi Event Transient store.
GaudiCommon & operator=(const GaudiCommon &)
virtual StatusCode finalize()
standard finalization method
TYPE * getDet(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
bool exist(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Check the existence of a data object or container in the Gaudi Transient Event Store.
TYPE * getDet(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Helper structure for implementation of "get"-functions for GaudiCommon
Definition: GaudiCommon.h:36
Data provider interface definition.
bool existDet(const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Gaudi::Utils::GetData< TYPE >::return_type getIfExists(const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
bool existDet(IDataProviderSvc *svc, const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Gaudi::Utils::GetData< TYPE >::return_type getIfExists(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
The useful base class for data processing algorithms.
void put(DataObject *object, const std::string &address, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Get the existing data object from Gaudi Event Transient store.
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:59
std::vector< std::string > m_requireObjs
process the event only if one or more of these objects are present in TES
virtual StatusCode initialize()
standard initialization method
#define GAUDI_API
Definition: Kernel.h:108
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.