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 // ============================================================================
10 // ============================================================================
11 // GaudiAlg
12 // ============================================================================
14 // ============================================================================
26 // ============================================================================
27 // templated methods
28 // ============================================================================
29 #include "GaudiCommon.icpp"
30 // ============================================================================
31 template class GaudiCommon<Algorithm>;
32 // ============================================================================
33 // Standard algorithm like constructor
34 // ============================================================================
36  ISvcLocator* pSvcLocator )
37  : GaudiCommon<Algorithm> ( name , pSvcLocator )
38 {
39  setProperty ( "RegisterForContextService" , true ).ignore() ;
40 }
41 // ============================================================================
42 // standard initialization method
43 // ============================================================================
45 {
46  // initialize the base class
48  if ( sc.isFailure() ) { return sc; }
49 
50  // Add any customisations here, that cannot go in GaudiCommon
51 
52  // return
53  return sc;
54 }
55 // ============================================================================
56 // standard finalization method
57 // ============================================================================
59 {
60  if ( msgLevel(MSG::DEBUG) )
61  debug() << "Finalize base class GaudiAlgorithm" << endmsg;
62 
63  // reset pointers
64  m_evtColSvc.reset() ;
65 
66  // finalize the base class and return
68 }
69 // ============================================================================
70 // standard execution method
71 // ============================================================================
73 {
74  return Error ( "Default GaudiAlgorithm execute method called !!" ) ;
75 }
76 // ============================================================================
77 // The standard event collection service
78 // ============================================================================
80 {
81  if ( !m_evtColSvc )
82  { m_evtColSvc = svc< INTupleSvc > ( "EvtTupleSvc" , true ) ; }
83  //
84  return m_evtColSvc ;
85 }
86 // ============================================================================
87 /* The generic actions for the execution.
88  * @see Algorithm
89  * @see IAlgorithm
90  * @see Algorithm::sysExecute
91  * @return status code
92  */
93 // ============================================================================
95 {
96  IAlgContextSvc* ctx = nullptr ;
97  if ( registerContext() ) { ctx = contextSvc() ; }
98  // Lock the context
99  Gaudi::Utils::AlgContext cnt ( ctx , this ) ;
100 
101  // Do not execute if one or more of the m_vetoObjs exist in TES
103  [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
104  if ( it != std::end(m_vetoObjs) ) {
105  if ( msgLevel(MSG::DEBUG) )
106  debug() << *it << " found, skipping event " << endmsg;
107  return StatusCode::SUCCESS;
108  }
109 
110  // Execute if m_requireObjs is empty
111  // or if one or more of the m_requireObjs exist in TES
112  bool doIt = m_requireObjs.empty() ||
114  [&](const std::string& loc) { return this->exist<DataObject>(loc); } );
115 
116  // execute the generic method:
117  if( doIt ) return Algorithm::sysExecute(evtCtx) ;
118  return StatusCode::SUCCESS;
119 }
120 // ============================================================================
121 
122 // ============================================================================
123 // The END
124 // ============================================================================
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:783
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
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
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.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode sysExecute(const EventContext &ctx) override
the generic actions for the execution.
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
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:484