38 forAllAlgorithms (MsgStream&
msg,
ModuleData& data,
const char *funcName,
F&& func)
44 typedef typename std::decay<
decltype(
func(alg))>::type scType__;
45 if (!::asg::CheckHelper<scType__>::isSuccess (func (alg)))
47 msg << MSG::ERROR <<
"executing " << funcName <<
" on algorithm " <<
alg->getName() <<
endmsg;
48 return StatusCode::FAILURE;
53 msg << MSG::ERROR <<
"executing " << funcName <<
" on algorithm " <<
alg->getName() <<
endmsg;
54 return StatusCode::FAILURE;
57 return StatusCode::SUCCESS;
69 return StatusCode::FAILURE;
76 workerData.
m_wk = data.m_worker;
78 return forAllAlgorithms (
msg(), data,
"initialize", [&] (
AlgorithmData& alg) {
79 return alg->initialize (workerData);});
88 return StatusCode::SUCCESS;
90 return alg->finalize ();}).isFailure())
91 return StatusCode::FAILURE;
92 return StatusCode::SUCCESS;
100 return forAllAlgorithms (
msg(), data,
"endInputFile", [&] (
AlgorithmData& alg) {
101 return alg->endInputFile ();});
112 return StatusCode::FAILURE;
116 if (!data.m_hasInputEvents)
return StatusCode::SUCCESS;
118 if (forAllAlgorithms (
msg(), data,
"changeInput", [&] (
AlgorithmData& alg) {
119 return alg->beginInputFile ();}).isFailure())
120 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
129 return forAllAlgorithms (
msg(), data,
"fileExecute", [&] (
AlgorithmData& alg) {
130 return alg->fileExecute ();});
138 data.m_skipEvent =
false;
139 bool sequenceSkip =
false;
140 const EventContext& ctx = Gaudi::Hive::currentContext();
141 for (
auto& algData : data.m_algs)
145 if (algData.m_sequenceStart)
146 sequenceSkip =
false;
147 else if (sequenceSkip)
149 algData.m_wasSkipped =
true;
153 algData.m_executeCount += 1;
154 if (algData.m_algorithm->execute(ctx) == StatusCode::FAILURE)
156 ANA_MSG_ERROR (
"while calling execute() on algorithm " << algData.m_algorithm->getName());
157 return StatusCode::FAILURE;
160 if (data.m_skipEvent)
162 algData.m_skipCount += 1;
163 algData.m_wasSkipped =
true;
165 data.m_skipEvent =
false;
170 ANA_MSG_ERROR (
"while calling execute() on algorithm " << algData.m_algorithm->getName());
171 return StatusCode::FAILURE;
175 for (
auto& algData : data.m_algs)
182 if (algData.m_wasSkipped)
184 algData.m_wasSkipped =
false;
187 if (algData.m_algorithm->postExecute() == StatusCode::FAILURE)
189 ANA_MSG_ERROR (
"while calling postExecute() on algorithm " << algData.m_algorithm->getName());
190 return StatusCode::FAILURE;
195 ANA_MSG_ERROR (
"while calling postExecute() on algorithm " << algData.m_algorithm->getName());
196 return StatusCode::FAILURE;
200 return StatusCode::SUCCESS;
bool m_initialized
whether Algorithm::initialize has been called
void report_exception(std::exception_ptr eptr)
print out the currently evaluated exception
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
all the external components an algorithm needs before initialization (in EventLoop)
IFilterWorker * m_filterWorker
ITreeWorker * m_treeWorker
asg::SgEvent * m_evtStore
IHistogramWorker * m_histogramWorker
all the data a worker tracks for an individual algorithm
the data the EventLoop core classes are sharing with the Module implementation