All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiAlgorithm.cpp
Go to the documentation of this file.
1 #define GAUDIALG_GAUDIALGORITHM_CPP 1
2 // ============================================================================
3 // include files
4 // ============================================================================
5 // GaudiKernel
6 // ============================================================================
9 // ============================================================================
10 // GaudiAlg
11 // ============================================================================
13 // ============================================================================
25 // ============================================================================
26 // templated methods
27 // ============================================================================
28 #include "GaudiCommon.icpp"
29 // ============================================================================
30 template class GaudiCommon<Algorithm>;
31 // ============================================================================
32 // Standard algorithm like constructor
33 // ============================================================================
35  ISvcLocator* pSvcLocator )
36  : GaudiCommon<Algorithm> ( name , pSvcLocator )
37 {
38  setProperty ( "RegisterForContextService" , true ).ignore() ;
39 }
40 // ============================================================================
41 // standard initialization method
42 // ============================================================================
44 {
45  // initialize the base class
47  if ( sc.isFailure() ) { return sc; }
48 
49  // Add any customisations here, that cannot go in GaudiCommon
50 
51  // return
52  return sc;
53 }
54 // ============================================================================
55 // standard finalization method
56 // ============================================================================
58 {
59  if ( msgLevel(MSG::DEBUG) )
60  debug() << "Finalize base class GaudiAlgorithm" << endmsg;
61 
62  // reset pointers
63  m_evtColSvc.reset() ;
64 
65  // finalize the base class and return
67 }
68 // ============================================================================
69 // standard execution method
70 // ============================================================================
72 {
73  return Error ( "Default GaudiAlgorithm execute method called !!" ) ;
74 }
75 // ============================================================================
76 // The standard event collection service
77 // ============================================================================
79 {
80  if ( !m_evtColSvc )
81  { m_evtColSvc = svc< INTupleSvc > ( "EvtTupleSvc" , true ) ; }
82  //
83  return m_evtColSvc ;
84 }
85 // ============================================================================
86 /* The generic actions for the execution.
87  * @see Algorithm
88  * @see IAlgorithm
89  * @see Algorithm::sysExecute
90  * @return status code
91  */
92 // ============================================================================
94 {
95  IAlgContextSvc* ctx = nullptr ;
96  if ( registerContext() ) { ctx = contextSvc() ; }
97  // Lock the context
98  Gaudi::Utils::AlgContext cnt ( ctx , this ) ;
99 
100  // Do not execute if one or more of the m_vetoObjs exist in TES
102  [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
103  if ( it != std::end(m_vetoObjs) ) {
104  if ( msgLevel(MSG::DEBUG) )
105  debug() << *it << " found, skipping event " << endmsg;
106  return StatusCode::SUCCESS;
107  }
108 
109  // Execute if m_requireObjs is empty
110  // or if one or more of the m_requireObjs exist in TES
111  bool doIt = m_requireObjs.empty() ||
113  [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
114 
115  // execute the generic method:
116  if( doIt ) return Algorithm::sysExecute() ;
117  return StatusCode::SUCCESS;
118 }
119 // ============================================================================
120 
121 // ============================================================================
122 // The END
123 // ============================================================================
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:830
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
Helper "sentry" class to automatize the safe register/unregister the algorithm&#39;s context.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
StatusCode initialize() override
standard initialization method
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.
Header file for class GaudiAlgorithm.
T end(T...args)
StatusCode finalize() override
standard finalization method
StatusCode execute() override
standard execution method
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
SmartIF< INTupleSvc > & evtColSvc() const
Access the standard event collection service.
STL class.
StatusCode sysExecute() override
the generic actions for the execution.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:494
StatusCode finalize() override
standard finalization method
StatusCode initialize() override
standard initialization method
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
T find_if(T...args)
Gaudi::Property< std::vector< std::string > > m_requireObjs
Gaudi::Property< std::vector< std::string > > m_vetoObjs
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T begin(T...args)
bool registerContext() const
register for Algorithm Context Service?
Definition: Algorithm.h:330
T any_of(T...args)
An abstract interface for Algorithm Context Service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
void ignore() const
Definition: StatusCode.h:106
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244