Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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  : GaudiCommon<Algorithm>( name, pSvcLocator ) {
37  setProperty( "RegisterForContextService", true ).ignore();
38 }
39 // ============================================================================
40 // standard initialization method
41 // ============================================================================
43  // initialize the base class
45  if ( sc.isFailure() ) { return sc; }
46 
47  // Add any customisations here, that cannot go in GaudiCommon
48 
49  // return
50  return sc;
51 }
52 // ============================================================================
53 // standard finalization method
54 // ============================================================================
56  if ( msgLevel( MSG::DEBUG ) ) debug() << "Finalize base class GaudiAlgorithm" << endmsg;
57 
58  // reset pointers
60 
61  // finalize the base class and return
63 }
64 // ============================================================================
65 // standard execution method
66 // ============================================================================
67 StatusCode GaudiAlgorithm::execute() { return Error( "Default GaudiAlgorithm execute method called !!" ); }
68 // ============================================================================
69 // The standard event collection service
70 // ============================================================================
72  if ( !m_evtColSvc ) { m_evtColSvc = svc<INTupleSvc>( "EvtTupleSvc", true ); }
73  //
74  return m_evtColSvc;
75 }
76 // ============================================================================
77 /* The generic actions for the execution.
78  * @see Algorithm
79  * @see IAlgorithm
80  * @see Algorithm::sysExecute
81  * @return status code
82  */
83 // ============================================================================
86 
87  IAlgContextSvc* algCtx = nullptr;
88  if ( registerContext() ) { algCtx = contextSvc(); }
89  // Lock the context
90  Gaudi::Utils::AlgContext cnt( this, algCtx, ctx );
91 
92  // Do not execute if one or more of the m_vetoObjs exist in TES
93  const auto it = find_if( begin( m_vetoObjs ), end( m_vetoObjs ),
94  [&]( const std::string& loc ) { return this->exist<DataObject>( loc ); } );
95  if ( it != end( m_vetoObjs ) ) {
96  if ( msgLevel( MSG::DEBUG ) ) debug() << *it << " found, skipping event " << endmsg;
97  return sc;
98  }
99 
100  // Execute if m_requireObjs is empty
101  // or if one or more of the m_requireObjs exist in TES
102  bool doIt =
103  m_requireObjs.empty() || any_of( begin( m_requireObjs ), end( m_requireObjs ),
104  [&]( const std::string& loc ) { return this->exist<DataObject>( loc ); } );
105 
106  // execute the generic method:
107  if ( doIt ) sc = Algorithm::sysExecute( ctx );
108  return sc;
109 }
110 // ============================================================================
111 
112 // ============================================================================
113 // The END
114 // ============================================================================
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
WARN_UNUSED 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.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:675
StatusCode finalize() override
standard finalization method
StatusCode execute() override
standard execution method
bool registerContext() const
register for Algorithm Context Service?
Definition: Algorithm.h:322
This class represents an entry point to all the event specific data.
Definition: EventContext.h:31
bool isFailure() const
Definition: StatusCode.h:130
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:50
StatusCode sysExecute(const EventContext &ctx) override
the generic actions for the execution.
StatusCode finalize() override
standard finalization method
StatusCode initialize() override
standard initialization method
Alias for backward compatibility.
Definition: Algorithm.h:56
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)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
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:86
AttribStringParser::Iterator begin(const AttribStringParser &parser)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:438
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
GaudiAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.