All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiTool.h
Go to the documentation of this file.
1 // $Id: GaudiTool.h,v 1.13 2008/10/10 13:38:28 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIALG_GAUDITOOL_H
4 #define GAUDIALG_GAUDITOOL_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // GaudiKernel
9 // ============================================================================
10 #include "GaudiKernel/AlgTool.h"
11 #include "GaudiKernel/DataObject.h"
12 // ============================================================================
13 // GaudiAlg
14 // ============================================================================
15 #include "GaudiAlg/GaudiAlg.h"
16 #include "GaudiAlg/GaudiCommon.h"
17 // ============================================================================
18 // forward declarations
19 // ============================================================================
20 class IDataProviderSvc ;
21 class IChronoStatSvc ;
22 class IIncidentSvc ;
23 class IHistogramSvc ;
24 class GaudiException ;
25 class INTupleSvc ;
26 class IAlgContextSvc ;
27 namespace std { class exception ; }
28 // ============================================================================
64 // ============================================================================
98 // ============================================================================
99 class GAUDI_API GaudiTool: public GaudiCommon<AlgTool>
100 {
101 public:
102  // ==========================================================================
108  virtual StatusCode initialize ();
114  virtual StatusCode finalize ();
115  // ==========================================================================
116 public: // accessors
117  // ==========================================================================
121  INTupleSvc* ntupleSvc () const;
125  INTupleSvc* evtColSvc () const;
129  IDataProviderSvc* detSvc () const ;
133  IDataProviderSvc* evtSvc () const ;
137  IIncidentSvc* incSvc () const ;
141  IChronoStatSvc* chronoSvc () const ;
145  IHistogramSvc* histoSvc () const ;
149  IAlgContextSvc* contextSvc () const ;
150  // ==========================================================================
151 public:
152  // ==========================================================================
153  // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
154  // and detDvc() ) that are not members of AlgTool.
155  // Also some methods seem which are members of the base class do not seem
156  // to be found unless forwarding methods are put here ??
157  // ==========================================================================
158 
189  inline DataObject* put ( IDataProviderSvc* svc ,
190  DataObject* object ,
191  const std::string& address ,
192  const bool useRootInTES = true ) const
193  {
194  return GaudiCommon<AlgTool>::put ( svc , object , address , useRootInTES ) ;
195  }
196 
225  inline DataObject* put ( DataObject* object ,
226  const std::string& address ,
227  const bool useRootInTES = true ) const
228  {
229  return GaudiCommon<AlgTool>::put ( evtSvc() , object , address , useRootInTES ) ;
230  }
231 
263  template < class TYPE >
266  const std::string& location ,
267  const bool useRootInTES = true ) const
268  {
269  return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , useRootInTES ) ;
270  }
271 
305  template < class TYPE >
308  const std::string& location ,
309  const bool useRootInTES = true ) const
310  {
311  return GaudiCommon<AlgTool>::getIfExists<TYPE> ( svc , location , useRootInTES ) ;
312  }
313 
339  template < class TYPE >
341  get ( const std::string& location ,
342  const bool useRootInTES = true ) const
343  {
344  return GaudiCommon<AlgTool>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
345  }
346 
379  template < class TYPE >
381  getIfExists ( const std::string& location ,
382  const bool useRootInTES = true ) const
383  {
384  return GaudiCommon<AlgTool>::getIfExists<TYPE> ( evtSvc() , location , useRootInTES ) ;
385  }
386 
405  template < class TYPE >
406  inline TYPE* getDet ( IDataProviderSvc* svc ,
407  const std::string& location ) const
408  {
409  return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , false ) ;
410  }
411 
434  template < class TYPE >
437  const std::string& location ) const
438  {
439  return GaudiCommon<AlgTool>::getIfExists<TYPE> ( svc , location , false ) ;
440  }
441 
459  template < class TYPE >
460  inline TYPE* getDet ( const std::string& location ) const
461  {
462  return GaudiCommon<AlgTool>::get<TYPE> ( detSvc() , location , false ) ;
463  }
464 
486  template < class TYPE >
488  getDetIfExists ( const std::string& location ) const
489  {
490  return GaudiCommon<AlgTool>::getIfExists<TYPE> ( detSvc() , location , false ) ;
491  }
492 
518  template < class TYPE >
519  inline bool exist ( IDataProviderSvc* svc ,
520  const std::string& location ,
521  const bool useRootInTES = true ) const
522  {
523  return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , useRootInTES ) ;
524  }
525 
548  template < class TYPE >
549  inline bool exist ( const std::string& location ,
550  const bool useRootInTES = true ) const
551  {
552  return GaudiCommon<AlgTool>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
553  }
554 
571  template < class TYPE >
572  inline bool existDet ( IDataProviderSvc* svc ,
573  const std::string& location ) const
574  {
575  return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , false ) ;
576  }
577 
593  template < class TYPE >
594  inline bool existDet ( const std::string& location ) const
595  {
596  return GaudiCommon<AlgTool>::exist<TYPE> ( detSvc() , location , false ) ;
597  }
598 
625  template < class TYPE , class TYPE2 >
628  const std::string& location ,
629  const bool useRootInTES = true ) const
630  {
631  return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
632  }
633 
659  template < class TYPE , class TYPE2 >
661  getOrCreate ( const std::string& location ,
662  const bool useRootInTES = true ) const
663  {
664  return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
665  }
666 
667  // ==========================================================================
668 public:
669  // ==========================================================================
671  static bool enableSummary ( bool ) ; // enable/disable summary
673  static bool summaryEnabled ( ) ; // is summary enabled?
674  // ==========================================================================
675 protected:
676  // ==========================================================================
683  GaudiTool ( const std::string& type ,
684  const std::string& name ,
685  const IInterface* parent );
686 
688  virtual ~GaudiTool();
689  // ==========================================================================
690 private:
691  // ==========================================================================
693  GaudiTool();
695  GaudiTool ( const GaudiTool& );
697  GaudiTool& operator = ( const GaudiTool& );
698  // ==========================================================================
699 private:
700  // ==========================================================================
715  // Pointer to the Algorithm Context Service
717  // The name of the Algorithm Context Service
718  std::string m_contextSvcName ;
719  // ==========================================================================
720 private:
721  // ==========================================================================
723  const std::string m_local ;
724  // ==========================================================================
725 private:
726  // ==========================================================================
728  static bool s_enableSummary ; // enable printout of summary?
729  // ==========================================================================
730 };
731 // ============================================================================
732 
733 // ============================================================================
734 // The END
735 // ============================================================================
736 #endif // GAUDIALG_GAUDITOOL_H
737 // ============================================================================
738 
739 
std::string m_contextSvcName
Algorithm Context Service.
Definition: GaudiTool.h:718
Define general base for Gaudi exception.
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 getDetIfExists(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:436
IChronoStatSvc * m_chronoSvc
pointer to Chrono & Stat Service
Definition: GaudiTool.h:710
GaudiCommon & operator=(const GaudiCommon &)
virtual StatusCode finalize()
standard finalization method
IDataProviderSvc * m_detSvc
pointer to Detector Data Service
Definition: GaudiTool.h:708
Helper structure for implementation of "get"-functions for GaudiCommon
Definition: GaudiCommon.h:36
TYPE * getDet(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:460
Data provider interface definition.
The IChronoStatSvc is the interface implemented by the ChronoStatService.
bool existDet(IDataProviderSvc *svc, const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Definition: GaudiTool.h:572
IAlgContextSvc * m_contextSvc
Algorithm Context Service.
Definition: GaudiTool.h:716
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.
Definition: GaudiTool.h:381
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.
Definition: GaudiTool.h:519
string type
Definition: gaudirun.py:126
IDataProviderSvc * m_evtSvc
pointer to Event Data Service
Definition: GaudiTool.h:706
TYPE * getDet(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:406
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
DataObject * 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.
Definition: GaudiTool.h:189
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.
Definition: GaudiTool.h:661
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
IHistogramSvc * m_histoSvc
pointer for histogram service
Definition: GaudiTool.h:714
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.
Definition: GaudiTool.h:627
bool existDet(const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Definition: GaudiTool.h:594
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.
Definition: GaudiTool.h:307
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:488
static bool s_enableSummary
enable printout of summary?
Definition: GaudiTool.h:728
IIncidentSvc * m_incSvc
pointer to Incident Service
Definition: GaudiTool.h:712
INTupleSvc * m_ntupleSvc
pointer to the N-Tuple service
Definition: GaudiTool.h:702
INTupleSvc * m_evtColSvc
pointer to the event tag collection service
Definition: GaudiTool.h:704
DataObject * put(DataObject *object, const std::string &address, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
Definition: GaudiTool.h:225
The useful base class for tools.
Definition: GaudiTool.h:99
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:59
An abstract interface for Algorithm Context Service.
virtual StatusCode initialize()
standard initialization method
const std::string m_local
full tool name "type/name"
Definition: GaudiTool.h:723
#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
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.
Definition: GaudiTool.h:549
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:22
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.