The Gaudi Framework  v33r1 (b1225454)
GaudiAlgorithm.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIALG_GaudiAlgorithm_H
12 #define GAUDIALG_GaudiAlgorithm_H 1
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 #include <string>
17 #include <vector>
18 // ============================================================================
19 // GaudiKernel
20 // ============================================================================
21 #include "GaudiKernel/Algorithm.h"
22 // ============================================================================
23 // GaudiAlg
24 // ============================================================================
25 #include "GaudiAlg/GaudiAlg.h"
26 #include "GaudiAlg/GaudiCommon.h"
28 // ============================================================================
29 // forward declarations:
30 // ============================================================================
31 class INTupleSvc;
32 
33 // ============================================================================
69 // ============================================================================
103 // ============================================================================
104 class GAUDI_API GaudiAlgorithm : public GaudiCommon<Algorithm> {
105 public:
106  // ==========================================================================
112  StatusCode initialize() override;
113  // ==========================================================================
119  StatusCode execute() override;
120  // ==========================================================================
126  StatusCode finalize() override;
127  // ==========================================================================
134  StatusCode sysExecute( const EventContext& ctx ) override;
135  // ==========================================================================
136 public:
137  // following methods cannot go in GaudiCommon since they use methods ( evtSvc()
138  // and detDvc() ) that are not members of AlgTool.
139  // Also some methods seem which are members of the base class do not seem
140  // to be found unless forwarding methods are put here ??
141 
174  // [[deprecated( "please pass a std::unique_ptr as 2nd argument" )]]
175  void put( IDataProviderSvc* svc, DataObject* object, const std::string& address,
176  const bool useRootInTES = true ) const {
177  put( svc, std::unique_ptr<DataObject>( object ), address, useRootInTES );
178  }
179  void put( IDataProviderSvc* svc, std::unique_ptr<DataObject> object, const std::string& address,
180  const bool useRootInTES = true ) const {
181  GaudiCommon<Algorithm>::put( svc, std::move( object ), address, useRootInTES );
182  }
183 
215  const DataObject* put( DataObject* object, const std::string& address, const bool useRootInTES = true ) const {
216  return put( std::unique_ptr<DataObject>( object ), address, useRootInTES );
217  }
218  const DataObject* put( std::unique_ptr<DataObject> object, const std::string& address,
219  const bool useRootInTES = true ) const {
220  return GaudiCommon<Algorithm>::put( evtSvc(), std::move( object ), address, useRootInTES );
221  }
222 
255  template <class TYPE>
257  const bool useRootInTES = true ) const {
258  return GaudiCommon<Algorithm>::get<TYPE>( svc, location, useRootInTES );
259  }
260 
294  template <class TYPE>
296  const bool useRootInTES = true ) const {
297  return GaudiCommon<Algorithm>::getIfExists<TYPE>( svc, location, useRootInTES );
298  }
299 
326  template <class TYPE>
328  const bool useRootInTES = true ) const {
329  return GaudiCommon<Algorithm>::get<TYPE>( evtSvc(), location, useRootInTES );
330  }
331 
364  template <class TYPE>
366  const bool useRootInTES = true ) const {
367  return GaudiCommon<Algorithm>::getIfExists<TYPE>( evtSvc(), location, useRootInTES );
368  }
369 
388  template <class TYPE>
389  TYPE* getDet( IDataProviderSvc* svc, const std::string& location ) const {
390  return GaudiCommon<Algorithm>::get<TYPE>( svc, location, false );
391  }
392 
415  template <class TYPE>
417  const std::string& location ) const {
419  }
420 
438  template <class TYPE>
439  TYPE* getDet( const std::string& location ) const {
440  return GaudiCommon<Algorithm>::get<TYPE>( detSvc(), location, false );
441  }
442 
464  template <class TYPE>
466  return GaudiCommon<Algorithm>::getIfExists<TYPE>( detSvc(), location, false );
467  }
468 
495  template <class TYPE>
496  bool exist( IDataProviderSvc* svc, const std::string& location, const bool useRootInTES = true ) const {
497  return GaudiCommon<Algorithm>::exist<TYPE>( svc, location, useRootInTES );
498  }
499 
525  template <class TYPE>
526  bool exist( const std::string& location, const bool useRootInTES = true ) const {
527  return GaudiCommon<Algorithm>::exist<TYPE>( evtSvc(), location, useRootInTES );
528  }
529 
546  template <class TYPE>
547  bool existDet( IDataProviderSvc* svc, const std::string& location ) const {
548  return GaudiCommon<Algorithm>::exist<TYPE>( svc, location, false );
549  }
550 
566  template <class TYPE>
567  bool existDet( const std::string& location ) const {
568  return GaudiCommon<Algorithm>::exist<TYPE>( detSvc(), location, false );
569  }
570 
598  template <class TYPE, class TYPE2>
600  const bool useRootInTES = true ) const {
601  return GaudiCommon<Algorithm>::getOrCreate<TYPE, TYPE2>( svc, location, useRootInTES );
602  }
603 
630  template <class TYPE, class TYPE2>
632  const bool useRootInTES = true ) const {
633  return GaudiCommon<Algorithm>::getOrCreate<TYPE, TYPE2>( evtSvc(), location, useRootInTES );
634  }
635 
636  // ==========================================================================
642  GaudiAlgorithm( std::string name, ISvcLocator* pSvcLocator );
643  // ==========================================================================
644  //
645  // no default/copy constructor, no assignment -- except that ROOT really
646  // wants a default constructor declared. So we define it, and don't implement
647  // it...
648  GaudiAlgorithm( const GaudiAlgorithm& ) = delete;
649  GaudiAlgorithm& operator=( const GaudiAlgorithm& ) = delete;
650  // ==========================================================================
651 public:
652  // ==========================================================================
656  SmartIF<INTupleSvc>& evtColSvc() const;
657 
658  // ==========================================================================
659 private:
660  // ==========================================================================
661  // Pointer to the Event Tag Collection Service
663 
665  this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist"};
667  this, "RequireObjects", {}, "execute only if one or more of these TES objects exist"};
668  // ==========================================================================
669 };
670 // ============================================================================
671 // The END
672 // ============================================================================
673 #endif // GAUDIALG_GaudiAlgorithm_H
void put(IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE >::return_type get(const std::string &location, const bool useRootInTES=true) const
Templated access to the data from 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:35
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate(IDataProviderSvc *svc, std::string_view location, const bool useRootInTES=true) const
Get the existing data object from Gaudi Event Transient store.
Implementation of property with value of concrete type.
Definition: Property.h:370
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists(const std::string &location) const
Templated access to the detector data from the Gaudi Detector 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.
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.
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:57
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.
StatusCode finalize() override
standard finalization method
Data provider interface definition.
This class represents an entry point to all the event specific data.
Definition: EventContext.h:34
STL class.
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.
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 getOrCreate(const std::string &location, const bool useRootInTES=true) const
Get the existing data object from Gaudi Event Transient store.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool existDet(IDataProviderSvc *svc, const std::string &location) const
Check the existence of detector objects in the Gaudi Transient Detector Store.
The useful base class for data processing algorithms.
T move(T... args)
StatusCode initialize() override
standard initialization method
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.
STL class.
GaudiCommon & operator=(const GaudiCommon &)=delete
Gaudi::Utils::GetData< TYPE >::return_type get(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
TYPE * getDet(IDataProviderSvc *svc, const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:95
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.
#define GAUDI_API
Definition: Kernel.h:81
DataObject * put(IDataProviderSvc *svc, std::unique_ptr< DataObject > object, std::string_view location, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
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.
const DataObject * put(std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
TYPE * getDet(const std::string &location) const
Templated access to the detector data from the Gaudi Detector Transient Store.