218 {
219
220 MsgStream log(
msgSvc(), name() );
221 log << MSG::DEBUG << "*** Executing StepHandler *** " << FSMState() << endmsg;
222
223
224
225#ifdef TIME_MEASUREMENT
226 m_timer[0]->start();
227 m_timer[1]->start();
228 m_timer[2]->start();
229 m_timer[3]->start();
230 m_timer[4]->start();
231#endif
232
233 bool StepSeq = true;
234 int StepDec = -999;
235 log << MSG::DEBUG << "point: " << m_EFResult << " " << m_evtType << " " << sequencerAlg
236 << endmsg;
237 m_EFResult->reset();
238 m_evtType->reset();
239 if ( !sequencerAlg ) return StatusCode::FAILURE;
240 sequencerAlg->reset();
241
242 std::string answer, result;
243 std::string::size_type separator;
244
245 std::vector<std::string>::const_iterator id = m_stepIdList.begin();
246
247 while ( id != m_stepIdList.end() )
248 {
249 log << MSG::DEBUG << "In step " << ( *id ) << endmsg;
250
251 StepSeq = sequencerAlg->execSequencer( *id );
252 if ( !StepSeq )
253 {
254 log << MSG::DEBUG << " Step Sequencer failed" << endmsg;
255 id++;
256 continue;
257 }
258
259 log << MSG::DEBUG << "+++++++++++++++++++++++++++++" << endmsg;
260
261 StepDec = decisionAlg->execDecision( *id );
262 std::string midAnswer = decisionAlg->getContinue();
263 if ( midAnswer != "" ) m_evtType->setMidAnswer( midAnswer );
264
265
266 if ( StepDec > 0 ) m_EFResult->push_back( StepDec );
267 else
268 {
269
270 m_EFResult->push_back( 0 );
271 id++;
272 continue;
273 }
274 answer = decisionAlg->getBehaviour();
275 log << MSG::DEBUG << " Matched Criteria, Behaviour = " << answer << endmsg;
276
277 separator = answer.find( '_' );
278 if ( separator == std::string::npos )
279 {
280 log << MSG::ERROR << " Unknown decision result: " << answer << endmsg;
281 return StatusCode::FAILURE;
282 }
283 std::string perform = answer.substr( 0, separator );
284
285
286
287
288 if ( perform == "reject" )
289 {
290 result = "Rejected";
291 break;
292 }
293 else if ( perform == "accept" )
294 {
295 result = "Accepted";
296 break;
297 }
298 else if ( perform == "jump" )
299 {
300 std::string nextId = answer.substr( separator + 1 );
301 do {
302 ++id;
303 } while ( ( id != m_stepIdList.end() ) && ( ( *id ) != nextId ) );
304 if ( id == m_stepIdList.end() )
305 {
306 log << MSG::ERROR << " Unknown jump target: " << nextId << endmsg;
307 return StatusCode::FAILURE;
308 }
309 }
310 else
311 {
312 log << MSG::ERROR << " Unknown decision result: " << answer << endmsg;
313 return StatusCode::FAILURE;
314 }
315
316
317
318 }
319
320 log << MSG::DEBUG << "==============" << m_evtType->getAnswerIndex() << endmsg;
321
322 if ( result == "Accepted" )
323 {
324 std::string evtMark = answer.substr( separator + 1 );
325 log << MSG::DEBUG << " Event is Accepted as " << evtMark << endmsg;
326 m_evtType->setAnswer( evtMark );
327 }
328 else if ( result == "Rejected" )
329 {
330
331
332
333 std::string evtMark = "Beamgas";
334 m_evtType->setAnswer( evtMark );
335 log << MSG::DEBUG << " Event is Rejected" << endmsg;
336 }
337 else
338 {
339 log << MSG::WARNING << " Unknown Behaviour, force to Reject" << endmsg;
340 result = "Rejected";
341 }
342 log << MSG::DEBUG << "==============" << m_evtType->getAnswerIndex() << endmsg;
343 m_EFResult->setAnswer( result );
344
345#ifdef TIME_MEASUREMENT
346 m_timer[0]->stop();
347 g_StepHandlerTime = m_timer[0]->elapsed();
348 if ( m_tuple )
349 {
350 StatusCode status = m_tuple->write();
351 if ( !status.isSuccess() ) { log << MSG::ERROR << "Can't fill ntuple!" << endmsg; }
352 }
353#endif
354 return StatusCode::SUCCESS;
355}