202 {
203
204 MsgStream log( messageService(), name() );
205 log << MSG::DEBUG << "*** Executing StepHandler *** " << FSMState() << endreq;
206
207
208
209#ifdef TIME_MEASUREMENT
210 m_timer[0]->start();
211 m_timer[1]->start();
212 m_timer[2]->start();
213 m_timer[3]->start();
214 m_timer[4]->start();
215#endif
216
217 bool StepSeq = true;
218 int StepDec = -999;
219 log << MSG::DEBUG << "point: " << m_EFResult << " " << m_evtType << " " << sequencerAlg << endreq;
222 if(!sequencerAlg) return StatusCode::FAILURE;
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 <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
295
296 if (result == "Accepted") {
297 std::string evtMark = answer.substr(separator+1);
298 log << MSG::DEBUG << " Event is Accepted as " << evtMark << endreq;
300 }
301 else if (result == "Rejected") {
302
303
304
305 std::string evtMark = "Beamgas";
307 log << MSG::DEBUG << " Event is Rejected" << endreq;
308 }
309 else {
310 log << MSG::WARNING << " Unknown Behaviour, force to Reject" << endreq;
311 result = "Rejected";
312 }
313 log << MSG::DEBUG <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
315
316#ifdef TIME_MEASUREMENT
317 m_timer[0]->stop();
318 g_StepHandlerTime=m_timer[0]->elapsed();
319 if(m_tuple){
320 StatusCode status = m_tuple->write();
321 if (!status.isSuccess()) {
322 log << MSG::ERROR << "Can't fill ntuple!" << endreq;
323 }
324 }
325#endif
326 return StatusCode::SUCCESS;
327}
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)