The Gaudi Framework  v30r3 (a5ef0a68)
GaudiAlgorithm.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_GaudiAlgorithm_H
2 #define GAUDIALG_GaudiAlgorithm_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include <string>
7 #include <vector>
8 // ============================================================================
9 // GaudiKernel
10 // ============================================================================
11 #include "GaudiKernel/Algorithm.h"
12 // ============================================================================
13 // GaudiAlg
14 // ============================================================================
15 #include "GaudiAlg/GaudiAlg.h"
16 #include "GaudiAlg/GaudiCommon.h"
18 // ============================================================================
19 // forward declarations:
20 // ============================================================================
21 class INTupleSvc;
22 
23 // ============================================================================
59 // ============================================================================
93 // ============================================================================
94 class GAUDI_API GaudiAlgorithm : public GaudiCommon<Algorithm>
95 {
96 public:
97  // ==========================================================================
103  StatusCode initialize() override;
104  // ==========================================================================
110  StatusCode execute() override;
111  // ==========================================================================
117  StatusCode finalize() override;
118  // ==========================================================================
125  StatusCode sysExecute( const EventContext& ctx ) override;
126  // ==========================================================================
127 public:
128  // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
129  // and detDvc() ) that are not members of AlgTool.
130  // Also some methods seem which are members of the base class do not seem
131  // to be found unless forwarding methods are put here ??
132 
165  // [[deprecated( "please pass a std::unique_ptr as 2nd argument" )]]
166  inline void put( IDataProviderSvc* svc, DataObject* object, const std::string& address,
167  const bool useRootInTES = true ) const
168  {
169  put( svc, std::unique_ptr<DataObject>( object ), address, useRootInTES );
170  }
171  inline void put( IDataProviderSvc* svc, std::unique_ptr<DataObject> object, const std::string& address,
172  const bool useRootInTES = true ) const
173  {
174  GaudiCommon<Algorithm>::put( svc, std::move( object ), address, useRootInTES );
175  }
176 
208  inline const DataObject* put( DataObject* object, const std::string& address, const bool useRootInTES = true ) const
209  {
210  return put( std::unique_ptr<DataObject>( object ), address, useRootInTES );
211  }
212  inline const DataObject* put( std::unique_ptr<DataObject> object, const std::string& address,
213  const bool useRootInTES = true ) const
214  {
215  return GaudiCommon<Algorithm>::put( evtSvc(), std::move( object ), address, useRootInTES );
216  }
217 
250  template <class TYPE>
252  const bool useRootInTES = true ) const
253  {
254  return GaudiCommon<Algorithm>::get<TYPE>( svc, location, useRootInTES );
255  }
256 
290  template <class TYPE>
292  getIfExists( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
293  {
294  return GaudiCommon<Algorithm>::getIfExists<TYPE>( svc, location, useRootInTES );
295  }
296 
323  template <class TYPE>
325  const bool useRootInTES = true ) const
326  {
327  return GaudiCommon<Algorithm>::get<TYPE>( evtSvc(), location, useRootInTES );
328  }
329 
362  template <class TYPE>
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, const std::string& location ) const
389  {
390  return GaudiCommon<Algorithm>::get<TYPE>( svc, location, false );
391  }
392 
415  template <class TYPE>
417  const std::string& location ) const
418  {
419  return GaudiCommon<Algorithm>::getIfExists<TYPE>( svc, location, false );
420  }
421 
439  template <class TYPE>
440  inline TYPE* getDet( const std::string& location ) const
441  {
442  return GaudiCommon<Algorithm>::get<TYPE>( detSvc(), location, false );
443  }
444 
466  template <class TYPE>
467  inline typename Gaudi::Utils::GetData<TYPE>::return_type getDetIfExists( const std::string& location ) const
468  {
469  return GaudiCommon<Algorithm>::getIfExists<TYPE>( detSvc(), location, false );
470  }
471 
498  template <class TYPE>
499  inline bool exist( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
500  {
501  return GaudiCommon<Algorithm>::exist<TYPE>( svc, location, useRootInTES );
502  }
503 
529  template <class TYPE>
530  inline bool exist( const std::string& location, const bool useRootInTES = true ) const
531  {
532  return GaudiCommon<Algorithm>::exist<TYPE>( evtSvc(), location, useRootInTES );
533  }
534 
551  template <class TYPE>
552  inline bool existDet( IDataProviderSvc* svc, const std::string& location ) const
553  {
554  return GaudiCommon<Algorithm>::exist<TYPE>( svc, location, false );
555  }
556 
572  template <class TYPE>
573  inline bool existDet( const std::string& location ) const
574  {
575  return GaudiCommon<Algorithm>::exist<TYPE>( detSvc(), location, false );
576  }
577 
605  template <class TYPE, class TYPE2>
607  getOrCreate( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const
608  {
609  return GaudiCommon<Algorithm>::getOrCreate<TYPE, TYPE2>( svc, location, useRootInTES );
610  }
611 
638  template <class TYPE, class TYPE2>
640  const bool useRootInTES = true ) const
641  {
642  return GaudiCommon<Algorithm>::getOrCreate<TYPE, TYPE2>( evtSvc(), location, useRootInTES );
643  }
644 
645  // ==========================================================================
651  GaudiAlgorithm( const std::string& name, ISvcLocator* pSvcLocator );
652  // ==========================================================================
653  //
654  // no default/copy constructor, no assignment -- except that ROOT really
655  // wants a default constructor declared. So we define it, and don't implement
656  // it...
657  GaudiAlgorithm( const GaudiAlgorithm& ) = delete;
658  GaudiAlgorithm& operator=( const GaudiAlgorithm& ) = delete;
659  // ==========================================================================
660 public:
661  // ==========================================================================
665  SmartIF<INTupleSvc>& evtColSvc() const;
666 
667  // ==========================================================================
668 private:
669  // ==========================================================================
670  // Pointer to the Event Tag Collection Service
672 
674  this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist"};
676  this, "RequireObjects", {}, "execute only if one or more of these TES objects exist"};
677  // ==========================================================================
678 };
679 // ============================================================================
680 // The END
681 // ============================================================================
682 #endif // GAUDIALG_GaudiAlgorithm_H
683 // ============================================================================
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:25
Implementation of property with value of concrete type.
Definition: Property.h:381
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.
StatusCode execute() override final
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<BASE>
Definition: GaudiCommon.h:54
StatusCode finalize() override
standard finalization method
Data provider interface definition.
bool existDet(const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
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.
STL class.
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:51
DataObject * put(IDataProviderSvc *svc, std::unique_ptr< 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 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.
const DataObject * put(std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
T move(T...args)
StatusCode initialize() override
standard initialization method
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.
STL class.
GaudiCommon & operator=(const GaudiCommon &)=delete
void put(IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:93
const DataObject * put(DataObject *object, const std::string &address, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
#define GAUDI_API
Definition: Kernel.h:104
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.