The Gaudi Framework  v30r3 (a5ef0a68)
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 {
38  setProperty( "RegisterForContextService", true ).ignore();
39 }
40 // ============================================================================
41 // standard initialization method
42 // ============================================================================
44 {
45  // initialize the base class
47  if ( sc.isFailure() ) {
48  return sc;
49  }
50 
51  // Add any customisations here, that cannot go in GaudiCommon
52 
53  // return
54  return sc;
55 }
56 // ============================================================================
57 // standard finalization method
58 // ============================================================================
60 {
61  if ( msgLevel( MSG::DEBUG ) ) debug() << "Finalize base class GaudiAlgorithm" << endmsg;
62 
63  // reset pointers
65 
66  // finalize the base class and return
68 }
69 // ============================================================================
70 // standard execution method
71 // ============================================================================
72 StatusCode GaudiAlgorithm::execute() { return Error( "Default GaudiAlgorithm execute method called !!" ); }
73 // ============================================================================
74 // The standard event collection service
75 // ============================================================================
77 {
78  if ( !m_evtColSvc ) {
79  m_evtColSvc = svc<INTupleSvc>( "EvtTupleSvc", true );
80  }
81  //
82  return m_evtColSvc;
83 }
84 // ============================================================================
85 /* The generic actions for the execution.
86  * @see Algorithm
87  * @see IAlgorithm
88  * @see Algorithm::sysExecute
89  * @return status code
90  */
91 // ============================================================================
93 {
94  IAlgContextSvc* ctx = nullptr;
95  if ( registerContext() ) {
96  ctx = contextSvc();
97  }
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 ) ) 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 =
113  [&]( const std::string& loc ) { return this->exist<DataObject>( loc ); } );
114 
115  // execute the generic method:
116  if ( doIt ) return Algorithm::sysExecute( evtCtx );
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
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.
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:24
bool isFailure() const
Definition: StatusCode.h:139
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:51
StatusCode sysExecute(const EventContext &ctx) override
the generic actions for the execution.
StatusCode finalize() override
standard finalization method
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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:334
T any_of(T...args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
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:92
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:545
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
GaudiAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.