204 {
205
206 MsgStream log( messageService(), name() );
207 log << MSG::DEBUG << "*** Executing StepHandler *** " << FSMState() << endreq;
208
209
210
211#ifdef TIME_MEASUREMENT
212 m_timer[0]->start();
213 m_timer[1]->start();
214 m_timer[2]->start();
215 m_timer[3]->start();
216 m_timer[4]->start();
217#endif
218
219 bool StepSeq = true;
220 int StepDec = -999;
223 sequencerAlg->
reset();
224
225 std::string answer, result;
226 std::string::size_type separator;
227
228 std::vector<std::string>::const_iterator id = m_stepIdList.begin();
229
230 while (id != m_stepIdList.end()) {
231 log << MSG::DEBUG << "In step " << (*id) << endreq;
232
234 if (!StepSeq) {
235 log << MSG::DEBUG << " Step Sequencer failed" << endreq;
236 id++;
237 continue;
238 }
239
240 log << MSG::DEBUG << "+++++++++++++++++++++++++++++" << endreq;
241
243 std::string midAnswer = decisionAlg->
getContinue();
245
246
247 if (StepDec>0) m_EFResult->
push_back(StepDec);
248 else {
249
251 id++;
252 continue;
253 }
255 log << MSG::DEBUG << " Matched Criteria, Behaviour = " << answer << endreq;
256
257 separator = answer.find('_');
258 if (separator == std::string::npos) {
259 log << MSG::ERROR << " Unknown decision result: "<< answer << endreq;
260 return StatusCode::FAILURE;
261 }
262 std::string perform = answer.substr(0, separator);
263
264
265
266
267 if (perform == "reject") {
268 result = "Rejected";
269 break;
270 }
271 else if (perform == "accept") {
272 result = "Accepted";
273 break;
274 }
275 else if (perform == "jump") {
276 std::string nextId = answer.substr(separator+1);
277 do {
278 ++id;
279 } while ((id != m_stepIdList.end()) && ((*id) != nextId));
280 if (id == m_stepIdList.end()) {
281 log << MSG::ERROR << " Unknown jump target: "<< nextId << endreq;
282 return StatusCode::FAILURE;
283 }
284 }
285 else {
286 log << MSG::ERROR << " Unknown decision result: "<< answer << endreq;
287 return StatusCode::FAILURE;
288 }
289
290
291
292 }
293
294 log << MSG::DEBUG << "============================="
296
297 if (result == "Accepted") {
298 std::string evtMark = answer.substr(separator+1);
299 log << MSG::DEBUG << " Event is Accepted as " << evtMark << endreq;
301 }
302 else if (result == "Rejected") {
303
304
305
306 std::string evtMark = "Beamgas";
308 log << MSG::DEBUG << " Event is Rejected" << endreq;
309 }
310 else {
311 log << MSG::WARNING << " Unknown Behaviour, force to Reject" << endreq;
312 result = "Rejected";
313 }
314 log << MSG::DEBUG << "============================="
317
318#ifdef TIME_MEASUREMENT
319 m_timer[0]->stop();
320 g_StepHandlerTime=m_timer[0]->elapsed();
321 if(m_tuple){
322 StatusCode status = m_tuple->write();
323 if (!status.isSuccess()) {
324 log << MSG::ERROR << "Can't fill ntuple!" << endreq;
325 }
326 }
327#endif
328 return StatusCode::SUCCESS;
329}
void setAnswer(std::string &answer)
const int getAnswerIndex() const
void setMidAnswer(std::string &answer)
bool push_back(uint32_t val)
int execDecision(const std::string &sigID)
const std::string & getBehaviour() const
const std::string & getContinue() const
bool execSequencer(const std::string &seqID)