| The Gaudi Framework v27r1

- 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 { class exception ; }
27 // ============================================================================
63 // ============================================================================
97 // ============================================================================
98 class GAUDI_API GaudiTool: public GaudiCommon<AlgTool>
99 {
100 public:
101 // ==========================================================================
107 StatusCode initialize () override;
113 StatusCode finalize () override;
114 // ==========================================================================
115 public: // accessors
116 // ==========================================================================
120 INTupleSvc* ntupleSvc () const;
124 INTupleSvc* evtColSvc () const;
128 IDataProviderSvc* detSvc () const ;
129
133 IIncidentSvc* incSvc () const ;
137 IChronoStatSvc* chronoSvc () const ;
141 IHistogramSvc* histoSvc () const ;
145 IAlgContextSvc* contextSvc () const ;
146 // ==========================================================================
147 public:
148 // ==========================================================================
149 // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
150 // and detDvc() ) that are not members of AlgTool.
151 // Also some methods seem which are members of the base class do not seem
152 // to be found unless forwarding methods are put here ??
153 // ==========================================================================
154
185 inline DataObject* put ( IDataProviderSvc* svc ,
186 DataObject* object ,
187 const std::string& address ,
188 const bool useRootInTES = true ) const
189 {
190 return GaudiCommon<AlgTool>::put ( svc , object , address , useRootInTES ) ;
191 }
192
221 inline DataObject* put ( DataObject* object ,
222 const std::string& address ,
223 const bool useRootInTES = true ) const
224 {
225 return GaudiCommon<AlgTool>::put ( evtSvc() , object , address , useRootInTES ) ;
226 }
227
259 template < class TYPE >
260 inline typename Gaudi::Utils::GetData<TYPE>::return_type
261 get ( IDataProviderSvc* svc ,
262 const std::string& location ,
263 const bool useRootInTES = true ) const
264 {
265 return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , useRootInTES ) ;
266 }
267
301 template < class TYPE >
302 inline typename Gaudi::Utils::GetData<TYPE>::return_type
303 getIfExists ( IDataProviderSvc* svc ,
304 const std::string& location ,
305 const bool useRootInTES = true ) const
306 {
307 return GaudiCommon<AlgTool>::getIfExists<TYPE> ( svc , location , useRootInTES ) ;
308 }
309
335 template < class TYPE >
336 inline typename Gaudi::Utils::GetData<TYPE>::return_type
337 get ( const std::string& location ,
338 const bool useRootInTES = true ) const
339 {
340 return GaudiCommon<AlgTool>::get<TYPE> ( evtSvc() , location , useRootInTES ) ;
341 }
342
375 template < class TYPE >
376 inline typename Gaudi::Utils::GetData<TYPE>::return_type
377 getIfExists ( const std::string& location ,
378 const bool useRootInTES = true ) const
379 {
380 return GaudiCommon<AlgTool>::getIfExists<TYPE> ( evtSvc() , location , useRootInTES ) ;
381 }
382
401 template < class TYPE >
402 inline TYPE* getDet ( IDataProviderSvc* svc ,
403 const std::string& location ) const
404 {
405 return GaudiCommon<AlgTool>::get<TYPE> ( svc , location , false ) ;
406 }
407
430 template < class TYPE >
431 inline typename Gaudi::Utils::GetData<TYPE>::return_type
432 getDetIfExists ( IDataProviderSvc* svc ,
433 const std::string& location ) const
434 {
435 return GaudiCommon<AlgTool>::getIfExists<TYPE> ( svc , location , false ) ;
436 }
437
455 template < class TYPE >
456 inline TYPE* getDet ( const std::string& location ) const
457 {
458 return GaudiCommon<AlgTool>::get<TYPE> ( detSvc() , location , false ) ;
459 }
460
482 template < class TYPE >
483 inline typename Gaudi::Utils::GetData<TYPE>::return_type
484 getDetIfExists ( const std::string& location ) const
485 {
486 return GaudiCommon<AlgTool>::getIfExists<TYPE> ( detSvc() , location , false ) ;
487 }
488
514 template < class TYPE >
515 inline bool exist ( IDataProviderSvc* svc ,
516 const std::string& location ,
517 const bool useRootInTES = true ) const
518 {
519 return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , useRootInTES ) ;
520 }
521
544 template < class TYPE >
545 inline bool exist ( const std::string& location ,
546 const bool useRootInTES = true ) const
547 {
548 return GaudiCommon<AlgTool>::exist<TYPE> ( evtSvc() , location , useRootInTES ) ;
549 }
550
567 template < class TYPE >
568 inline bool existDet ( IDataProviderSvc* svc ,
569 const std::string& location ) const
570 {
571 return GaudiCommon<AlgTool>::exist<TYPE> ( svc , location , false ) ;
572 }
573
589 template < class TYPE >
590 inline bool existDet ( const std::string& location ) const
591 {
592 return GaudiCommon<AlgTool>::exist<TYPE> ( detSvc() , location , false ) ;
593 }
594
621 template < class TYPE , class TYPE2 >
622 inline typename Gaudi::Utils::GetData<TYPE>::return_type
623 getOrCreate ( IDataProviderSvc* svc ,
624 const std::string& location ,
625 const bool useRootInTES = true ) const
626 {
627 return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( svc , location , useRootInTES ) ;
628 }
629
655 template < class TYPE , class TYPE2 >
656 inline typename Gaudi::Utils::GetData<TYPE>::return_type
657 getOrCreate ( const std::string& location ,
658 const bool useRootInTES = true ) const
659 {
660 return GaudiCommon<AlgTool>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location , useRootInTES ) ;
661 }
662 // ==========================================================================
663 public:
664 // ==========================================================================
688 inline StatusCode Error
689 ( const std::string& msg ,
690 const StatusCode st = StatusCode::FAILURE ,
691 const size_t mx = 10 ) const
692 {
693 return GaudiCommon<AlgTool>::Error( m_isPublic ?
694 msg + getCurrentAlgName() : msg,
695 st, mx );
696 }
720 inline StatusCode Warning
721 ( const std::string& msg ,
722 const StatusCode st = StatusCode::FAILURE ,
723 const size_t mx = 10 ) const
724 {
725 return GaudiCommon<AlgTool>::Warning( m_isPublic ?
726 msg + getCurrentAlgName() : msg,
727 st, mx );
728 }
744 inline StatusCode Info
745 ( const std::string& msg ,
746 const StatusCode st = StatusCode::SUCCESS ,
747 const size_t mx = 10 ) const
748 {
749 return GaudiCommon<AlgTool>::Info( m_isPublic ?
750 msg + getCurrentAlgName() : msg,
751 st, mx );
752 }
753 // ==========================================================================
754 public:
755 // ==========================================================================
757 static bool enableSummary ( bool ) ; // enable/disable summary
759 static bool summaryEnabled ( ) ; // is summary enabled?
760 // ==========================================================================
761 protected:
762 // ==========================================================================
769 GaudiTool ( const std::string& type ,
770 const std::string& name ,
771 const IInterface* parent );
772
774 ~GaudiTool() override;
775 // ==========================================================================
776 private:
777 // ==========================================================================
779 GaudiTool() = delete;
780 GaudiTool ( const GaudiTool& ) = delete;
781 GaudiTool& operator = ( const GaudiTool& ) = delete;
782 // ==========================================================================
783 private:
784 // ==========================================================================
786 bool isPublic() const;
788 inline std::string getCurrentAlgName() const
789 {
790 const IAlgContextSvc * asvc = this->contextSvc();
791 const IAlgorithm * current = ( asvc ? asvc->currentAlg() : NULL );
792 return ( current ? " [" + current->name() + "]" : "" );
793 }
794 // ==========================================================================
795 private:
796 // ==========================================================================
798 mutable INTupleSvc* m_ntupleSvc = nullptr;
800 mutable INTupleSvc* m_evtColSvc = nullptr;
802 mutable IDataProviderSvc* m_detSvc = nullptr;
804 mutable IChronoStatSvc* m_chronoSvc = nullptr;
806 mutable IIncidentSvc* m_incSvc = nullptr;
808 mutable IHistogramSvc * m_histoSvc = nullptr;
809 // Pointer to the Algorithm Context Service
810 mutable IAlgContextSvc* m_contextSvc = nullptr;
811 // The name of the Algorithm Context Service
812 std::string m_contextSvcName = "AlgContextSvc";
813 // ==========================================================================
814 private:
815 // ==========================================================================
817 bool m_isPublic = false;
818 // ==========================================================================
819 private:
820 // ==========================================================================
822 const std::string m_local ;
823 // ==========================================================================
824 private:
825 // ==========================================================================
827 static bool s_enableSummary ; // enable printout of summary?
828 // ==========================================================================
829
830 public:
831 using AlgTool::declareProperty;
832 template <class T>
833 Property* declareProperty
834 ( const std::string& name,
835 DataObjectHandle<T>& hndl,
836 const std::string& doc = "none" ) const
837 {
838
839 if ( hndl.mode() & Gaudi::DataHandle::Reader ) {
840 (const_cast<GaudiTool*>(this))->AlgTool::declareInput(&hndl);
841 }
842
843 if ( hndl.mode() & Gaudi::DataHandle::Writer ) {
844 (const_cast<GaudiTool*>(this))->AlgTool::declareOutput(&hndl);
845 }
846
847 if (hndl.owner() == 0) {
848 hndl.setOwner((const_cast<GaudiTool*>(this)));
849 }
850
851 return m_propertyMgr->declareProperty(name, hndl, doc);
852 }
853
854
855 };
856 // ============================================================================
857
858 // ============================================================================
859 // The END
860 // ============================================================================
861 #endif // GAUDIALG_GAUDITOOL_H
862 // ============================================================================
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Gaudi::DataHandle::setOwner
virtual void setOwner(IDataHandleHolder *o)
Definition: DataHandle.h:44
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
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:686
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:432
GaudiMP.FdsRegistry.msg
tuple msg
Definition: FdsRegistry.py:8
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:459
Gaudi::DataHandle::mode
virtual Mode mode() const
Definition: DataHandle.h:47
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon
Definition: GaudiCommon.h:36
std
STL namespace.
GaudiCommon::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiCommon.icpp:280
GaudiTool::getDet
TYPE * getDet(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Definition: GaudiTool.h:456
GaudiTool::getCurrentAlgName
std::string getCurrentAlgName() const
Returns the current active algorithm name via the context service.
Definition: GaudiTool.h:788
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
Gaudi::DataHandle::Reader
Definition: DataHandle.h:31
GaudiCommon.h
std::string
STL class.
INTupleSvc
Definition: INTupleSvc.h:37
IChronoStatSvc
The IChronoStatSvc is the interface implemented by the ChronoStatService.
Definition: IChronoStatSvc.h:33
DataObjectHandle
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Definition: AlgTool.h:24
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:568
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:377
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:515
gaudirun.type
string type
Definition: gaudirun.py:151
StatusCode::FAILURE
Definition: StatusCode.h:29
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:402
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AlgTool::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: AlgTool.h:249
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
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:185
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:480
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:657
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:623
GaudiTool::existDet
bool existDet(const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
Definition: GaudiTool.h:590
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
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:303
GaudiAlg.h
GaudiCommon::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiCommon.icpp:186
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:484
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
GaudiTool::s_enableSummary
static bool s_enableSummary
enable printout of summary?
Definition: GaudiTool.h:827
GaudiCommon::operator=
GaudiCommon & operator=(const GaudiCommon &)=delete
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:221
Gaudi::DataHandle::Writer
Definition: DataHandle.h:32
GaudiTool
The useful base class for tools.
Definition: GaudiTool.h:98
GaudiCommon
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:73
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:501
GaudiTool::m_local
const std::string m_local
full tool name "type/name"
Definition: GaudiTool.h:822
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
IAlgContextSvc::currentAlg
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
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:545
Gaudi::DataHandle::owner
virtual IDataHandleHolder * owner() const
Definition: DataHandle.h:45
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:181
DataObject.h
DataObjectHandle.h