| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

GaudiTool.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_GAUDITOOL_H
2 #define GAUDIALG_GAUDITOOL_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // GaudiKernel
7 // ============================================================================
8 #include "GaudiKernel/AlgTool.h"
9 #include "GaudiKernel/DataObject.h"
10 // ============================================================================
11 // GaudiAlg
12 // ============================================================================
13 #include "GaudiAlg/GaudiAlg.h"
14 #include "GaudiAlg/GaudiCommon.h"
15 #include "GaudiKernel/DataObjectHandle.h"
16 // ============================================================================
17 // forward declarations
18 // ============================================================================
19 class IDataProviderSvc;
20 class IChronoStatSvc;
21 class IIncidentSvc;
22 class IHistogramSvc;
23 class GaudiException;
24 class INTupleSvc;
25 class IAlgContextSvc;
26 namespace std
27 {
28 class exception;
29 }
30 // ============================================================================
66 // ============================================================================
100 // ============================================================================
101 class GAUDI_API GaudiTool : public GaudiCommon<AlgTool>
102 {
103 public:
104 // ==========================================================================
110 StatusCode initialize() override;
116 StatusCode finalize() override;
117 // ==========================================================================
118 public: // accessors
119 // ==========================================================================
123 INTupleSvc* ntupleSvc() const;
127 INTupleSvc* evtColSvc() const;
131 IDataProviderSvc* detSvc() const;
132
136 IIncidentSvc* incSvc() const;
140 IChronoStatSvc* chronoSvc() const;
144 IHistogramSvc* histoSvc() const;
148 IAlgContextSvc* contextSvc() const;
149 // ==========================================================================
150 public:
151 // ==========================================================================
152 // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
153 // and detSvc() ) that are not members of AlgTool.
154 // Also some methods seem which are members of the base class do not seem
155 // to be found unless forwarding methods are put here ??
156 // ==========================================================================
157
188 inline DataObject* put( IDataProviderSvc* svc, DataObject* object, const std::string& address,
189 const bool useRootInTES = true ) const
190 {
191 return GaudiCommon<AlgTool>::put( svc, object, address, useRootInTES );
192 }
193
222 inline DataObject* put( DataObject* object, const std::string& address, const bool useRootInTES = true ) const
223 {
224 return GaudiCommon<AlgTool>::put( evtSvc(), object, address, useRootInTES );
225 }
226
258 template <class TYPE>
259 inline typename Gaudi::Utils::GetData<TYPE>::return_type get( IDataProviderSvc* svc, const std::string& location,
260 const bool useRootInTES = true ) const
261 {
262 return GaudiCommon<AlgTool>::get<TYPE>( svc, location, useRootInTES );
263 }
264
298 template <class TYPE>
299 inline typename Gaudi::Utils::GetData<TYPE>::return_type
300 getIfExists( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
301 {
302 return GaudiCommon<AlgTool>::getIfExists<TYPE>( svc, location, useRootInTES );
303 }
304
330 template <class TYPE>
331 inline typename Gaudi::Utils::GetData<TYPE>::return_type get( const std::string& location,
332 const bool useRootInTES = true ) const
333 {
334 return GaudiCommon<AlgTool>::get<TYPE>( evtSvc(), location, useRootInTES );
335 }
336
369 template <class TYPE>
370 inline typename Gaudi::Utils::GetData<TYPE>::return_type getIfExists( const std::string& location,
371 const bool useRootInTES = true ) const
372 {
373 return GaudiCommon<AlgTool>::getIfExists<TYPE>( evtSvc(), location, useRootInTES );
374 }
375
394 template <class TYPE>
395 inline TYPE* getDet( IDataProviderSvc* svc, const std::string& location ) const
396 {
397 return GaudiCommon<AlgTool>::get<TYPE>( svc, location, false );
398 }
399
422 template <class TYPE>
423 inline typename Gaudi::Utils::GetData<TYPE>::return_type getDetIfExists( IDataProviderSvc* svc,
424 const std::string& location ) const
425 {
426 return GaudiCommon<AlgTool>::getIfExists<TYPE>( svc, location, false );
427 }
428
446 template <class TYPE>
447 inline TYPE* getDet( const std::string& location ) const
448 {
449 return GaudiCommon<AlgTool>::get<TYPE>( detSvc(), location, false );
450 }
451
473 template <class TYPE>
474 inline typename Gaudi::Utils::GetData<TYPE>::return_type getDetIfExists( const std::string& location ) const
475 {
476 return GaudiCommon<AlgTool>::getIfExists<TYPE>( detSvc(), location, false );
477 }
478
504 template <class TYPE>
505 inline bool exist( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
506 {
507 return GaudiCommon<AlgTool>::exist<TYPE>( svc, location, useRootInTES );
508 }
509
532 template <class TYPE>
533 inline bool exist( const std::string& location, const bool useRootInTES = true ) const
534 {
535 return GaudiCommon<AlgTool>::exist<TYPE>( evtSvc(), location, useRootInTES );
536 }
537
554 template <class TYPE>
555 inline bool existDet( IDataProviderSvc* svc, const std::string& location ) const
556 {
557 return GaudiCommon<AlgTool>::exist<TYPE>( svc, location, false );
558 }
559
575 template <class TYPE>
576 inline bool existDet( const std::string& location ) const
577 {
578 return GaudiCommon<AlgTool>::exist<TYPE>( detSvc(), location, false );
579 }
580
607 template <class TYPE, class TYPE2>
608 inline typename Gaudi::Utils::GetData<TYPE>::return_type
609 getOrCreate( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
610 {
611 return GaudiCommon<AlgTool>::getOrCreate<TYPE, TYPE2>( svc, location, useRootInTES );
612 }
613
639 template <class TYPE, class TYPE2>
640 inline typename Gaudi::Utils::GetData<TYPE>::return_type getOrCreate( const std::string& location,
641 const bool useRootInTES = true ) const
642 {
643 return GaudiCommon<AlgTool>::getOrCreate<TYPE, TYPE2>( evtSvc(), location, useRootInTES );
644 }
645 // ==========================================================================
646 public:
647 // ==========================================================================
671 inline StatusCode Error( const std::string& msg, const StatusCode st = StatusCode::FAILURE,
672 const size_t mx = 10 ) const
673 {
674 return GaudiCommon<AlgTool>::Error( m_isPublic ? msg + getCurrentAlgName() : msg, st, mx );
675 }
699 inline StatusCode Warning( const std::string& msg, const StatusCode st = StatusCode::FAILURE,
700 const size_t mx = 10 ) const
701 {
702 return GaudiCommon<AlgTool>::Warning( m_isPublic ? msg + getCurrentAlgName() : msg, st, mx );
703 }
719 inline StatusCode Info( const std::string& msg, const StatusCode st = StatusCode::SUCCESS,
720 const size_t mx = 10 ) const
721 {
722 return GaudiCommon<AlgTool>::Info( m_isPublic ? msg + getCurrentAlgName() : msg, st, mx );
723 }
724 // ==========================================================================
725 public:
726 // ==========================================================================
728 static bool enableSummary( bool );
730 static bool summaryEnabled();
731
732 // ==========================================================================
739 GaudiTool( const std::string& type, const std::string& name, const IInterface* parent );
740
742 ~GaudiTool() override;
743 // ==========================================================================
744 private:
745 // ==========================================================================
747 GaudiTool() = delete;
748 GaudiTool( const GaudiTool& ) = delete;
749 GaudiTool& operator=( const GaudiTool& ) = delete;
750 // ==========================================================================
751 private:
752 // ==========================================================================
754 bool isPublic() const;
756 inline std::string getCurrentAlgName() const
757 {
758 const IAlgContextSvc* asvc = this->contextSvc();
759 const IAlgorithm* current = ( asvc ? asvc->currentAlg() : NULL );
760 return ( current ? " [" + current->name() + "]" : "" );
761 }
762 // ==========================================================================
763 private:
764 // ==========================================================================
766 mutable SmartIF<INTupleSvc> m_ntupleSvc;
768 mutable SmartIF<INTupleSvc> m_evtColSvc;
770 mutable SmartIF<IDataProviderSvc> m_detSvc;
772 mutable SmartIF<IChronoStatSvc> m_chronoSvc;
774 mutable SmartIF<IIncidentSvc> m_incSvc;
776 mutable SmartIF<IHistogramSvc> m_histoSvc;
777 // Pointer to the Algorithm Context Service
778 mutable SmartIF<IAlgContextSvc> m_contextSvc;
779
780 Gaudi::Property<std::string> m_contextSvcName{this, "ContextService", "AlgContextSvc",
781 "the name of Algorithm Context Service"};
782 // ==========================================================================
783 private:
784 // ==========================================================================
786 bool m_isPublic = false;
787 // ==========================================================================
788 private:
789 // ==========================================================================
791 const std::string m_local;
792 // ==========================================================================
793 private:
794 // ==========================================================================
796 static bool s_enableSummary;
797 // ==========================================================================
798 };
799 // ============================================================================
800
801 // ============================================================================
802 // The END
803 // ============================================================================
804 #endif // GAUDIALG_GAUDITOOL_H
805 // ============================================================================
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< INTupleSvc >
GaudiTool::Warning
StatusCode Warning(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the warning message and return with the given StatusCode.
Definition: GaudiTool.h:699
IAlgContextSvc::currentAlg
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
GaudiTool::m_ntupleSvc
SmartIF< INTupleSvc > m_ntupleSvc
pointer to the N-Tuple service
Definition: GaudiTool.h:766
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
GaudiCommon::put
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.
Definition: GaudiCommon.icpp:596
GaudiTool::getDetIfExists
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:423
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
AlgTool.h
GaudiCommon::Error
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Definition: GaudiCommon.icpp:382
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:774
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:41
GaudiTool::m_contextSvc
SmartIF< IAlgContextSvc > m_contextSvc
Algorithm Context Service.
Definition: GaudiTool.h:778
std
STL namespace.
GaudiTool::getDet
TYPE * getDet(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:447
GaudiTool::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
pointer to Incident Service
Definition: GaudiTool.h:774
GaudiTool::getCurrentAlgName
std::string getCurrentAlgName() const
Returns the current active algorithm name via the context service.
Definition: GaudiTool.h:756
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
GaudiTool::Info
StatusCode Info(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
Print the info message and return with the given StatusCode.
Definition: GaudiTool.h:719
GaudiCommon.h
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
INTupleSvc
Definition: INTupleSvc.h:37
IChronoStatSvc
The IChronoStatSvc is the interface implemented by the ChronoStatService.
Definition: IChronoStatSvc.h:33
GaudiTool::existDet
bool existDet(IDataProviderSvc *svc, const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Definition: GaudiTool.h:555
GaudiTool::getIfExists
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:370
GaudiTool::exist
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:505
GaudiTool::getDet
TYPE * getDet(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:395
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
gaudirun.type
type
Definition: gaudirun.py:125
GaudiTool::put
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:188
GaudiCommon::Warning
StatusCode Warning(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the warning message and return with the given StatusCode.
Definition: GaudiCommon.icpp:402
GaudiTool::getOrCreate
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:640
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
GaudiTool::getOrCreate
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:609
GaudiTool::existDet
bool existDet(const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Definition: GaudiTool.h:576
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
GaudiTool::getIfExists
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:300
GaudiAlg.h
GaudiTool::getDetIfExists
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:474
GaudiTool::s_enableSummary
static bool s_enableSummary
enable printout of summary?
Definition: GaudiTool.h:796
GaudiTool::m_chronoSvc
SmartIF< IChronoStatSvc > m_chronoSvc
pointer to Chrono & Stat Service
Definition: GaudiTool.h:772
GaudiTool::Error
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Definition: GaudiTool.h:671
GaudiTool::m_histoSvc
SmartIF< IHistogramSvc > m_histoSvc
pointer for histogram service
Definition: GaudiTool.h:776
GaudiTool::put
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:222
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiTool::m_detSvc
SmartIF< IDataProviderSvc > m_detSvc
pointer to Detector Data Service
Definition: GaudiTool.h:770
GaudiTool
The useful base class for tools.
Definition: GaudiTool.h:101
GaudiCommon
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:80
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition: IAlgContextSvc.h:23
GaudiCommon::Info
StatusCode Info(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
Print the info message and return with the given StatusCode.
Definition: GaudiCommon.icpp:422
GaudiTool::m_local
const std::string m_local
full tool name "type/name"
Definition: GaudiTool.h:791
GaudiTool::m_evtColSvc
SmartIF< INTupleSvc > m_evtColSvc
pointer to the event tag collection service
Definition: GaudiTool.h:768
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
GaudiTool::exist
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:533
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
DataObject.h
DataObjectHandle.h