All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgoExecutionTask.cpp
Go to the documentation of this file.
1 // local includes
2 #include "AlgoExecutionTask.h"
3 #include "RetCodeGuard.h"
4 
5 // Framework
11 
12 #include <functional>
13 
15 
16  IAlgorithm *ialg = m_algorithm.get();
17  Algorithm* this_algo = dynamic_cast<Algorithm*>(ialg);
18  if (!this_algo){
19  throw GaudiException ("Cast to Algorithm failed!","AlgoExecutionTask",
21  }
22 
23  bool eventfailed=false;
25 
26  // TODO reproduce the commented out functionality in a different service
27  //m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
28 
29  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
31 
33  MsgStream log(messageSvc, "AlgoExecutionTask");
34 
35  // select the appropriate store
36  this_algo->whiteboard()->selectStore(m_evtCtx->valid() ?
37  m_evtCtx->slot() : 0).ignore();
38 
40  try {
43  if (UNLIKELY(!sc.isSuccess())) {
44  log << MSG::WARNING << "Execution of algorithm "
45  << m_algorithm->name() << " failed" << endmsg;
46  eventfailed = true;
47  }
48  rcg.ignore(); // disarm the guard
49  } catch ( const GaudiException& Exception ) {
50  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
51  << " thrown by " << m_algorithm->name() << endmsg;
52  log << MSG::ERROR << Exception << endmsg;
53  eventfailed = true;
54  } catch ( const std::exception& Exception ) {
55  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
56  << m_algorithm->name() << endmsg;
57  log << MSG::ERROR << Exception.what() << endmsg;
58  eventfailed = true;
59  } catch(...) {
60  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
61  << m_algorithm->name() << endmsg;
62  eventfailed = true;
63  }
64 
65  // Commit all DataHandles
66  this_algo->commitHandles();
67 
68  // DP it is important to propagate the failure of an event.
69  // We need to stop execution when this happens so that execute run can
70  // then receive the FAILURE
73  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
74 
75  // TODO reproduce the commented out functionality in a different service
76  //m_schedSvc->delAlg(this_algo);
77 
79 
80  return nullptr;
81 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
void commitHandles() override
Definition: Algorithm.cpp:937
ContextID_t slot() const
Definition: EventContext.h:41
IAlgExecStateSvc * m_aess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
SmartIF< ISvcLocator > m_serviceLocator
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< IAlgorithm > m_algorithm
tbb::task * execute() override
constexpr int UnhandledException
Definition: AppReturnCode.h:29
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given &#39;slot&#39; for all subsequent calls within the same thread id.
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
virtual const std::string & tag() const
name tag for the exception, or exception type
void setExecuted(bool e=true)
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
GAUDI_API void setCurrentContext(const EventContext *ctx)
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:785
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
GAUDI_API void setCurrentContextEvt(long int evtN)
EventContext * m_evtCtx
void ignore()
Definition: RetCodeGuard.h:13
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool valid() const
Definition: EventContext.h:42