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