52 MsgStream log( messageService(), name() );
54 Algorithm::initialize();
56 StatusCode sc = service(
"HltConfigSvc", m_HltConfigSvc);
58 log << MSG::FATAL << name() <<
": Unable to locate HltConfigSvc" << endreq;
61 sc = service(
"HltStoreSvc", m_HltStoreSvc);
63 log << MSG::FATAL << name() <<
": Unable to locate HltStoreSvc" << endreq;
99 m_HltStoreSvc->
put(
"EFResult", m_EFResult);
101 log << MSG::ERROR <<
"Unvalid m_EFResult" << endreq;
102 return StatusCode::FAILURE;
105 m_evtType =
new EFResult(m_tmp_evtType);
107 m_HltStoreSvc->
put(
"EventType", m_evtType);
109 log << MSG::ERROR <<
"Unvalid m_evtType" << endreq;
110 return StatusCode::FAILURE;
112#ifdef TIME_MEASUREMENT
113 sc = service(
"BesTimerSvc", m_timersvc);
114 if (sc.isFailure()) {
115 log << MSG::WARNING << name() <<
": Unable to locate BesTimer Service" << endreq;
116 return StatusCode::FAILURE;
118 m_timer[0] = m_timersvc->addItem(
"Step Handler Time");
119 m_timer[1] = m_timersvc->addItem(
"1stStep exec Time");
120 m_timer[2] = m_timersvc->addItem(
"1stStep deci Time");
121 m_timer[3] = m_timersvc->addItem(
"2ndStep exec Time");
122 m_timer[4] = m_timersvc->addItem(
"2ndStep deci Time");
127 m_tuple->addItem(
"total", g_StepHandlerTime);
128 m_tuple->addItem(
"mdc", g_1stStepExecTime);
129 m_tuple->addItem(
"mdcd", g_1stStepDeciTime);
130 m_tuple->addItem(
"emc", g_2ndStepExecTime);
131 m_tuple->addItem(
"emcd", g_2ndStepDeciTime);
133 m_tuple =
ntupleSvc()->book(
"FILE444/nt",CLID_ColumnWiseTuple,
"StepCnt");
135 m_tuple->addItem(
"total", g_StepHandlerTime);
136 m_tuple->addItem(
"mdc", g_1stStepExecTime);
137 m_tuple->addItem(
"mdcd", g_1stStepDeciTime);
138 m_tuple->addItem(
"emc", g_2ndStepExecTime);
139 m_tuple->addItem(
"emcd", g_2ndStepDeciTime);
141 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple) << endmsg;
142 return StatusCode::FAILURE;
148 log << MSG::INFO <<
"Initialization " << name() <<
" completed successfully" << endreq;
149 return StatusCode::SUCCESS;
161 MsgStream log( messageService(), name() );
163 Algorithm::beginRun();
168 StatusCode sc = createSubAlgorithm(
"StepSequencer",
"StepSequencer", p_seqAlg);
169 if( sc.isFailure() ) {
170 log << MSG::FATAL <<
"Unable to create StepSequencer SubAlgorithm " << endreq;
174 log << MSG::DEBUG <<
"created SubAlgorithm StepSequencer/StepSequencer" << endreq;
177 sc = createSubAlgorithm(
"StepDecision",
"StepDecision", p_decAlg);
178 if( sc.isFailure() ) {
179 log << MSG::FATAL <<
"Unable to create StepDecision SubAlgorithm " << endreq;
183 log << MSG::DEBUG <<
"created SubAlgorithm StepDecision/StepDecision" << endreq;
186 const std::vector<std::pair<Signature*,Sequence*> >& m_TableVector = m_HltConfigSvc->
retrieve();
187 std::vector<std::pair<Signature*,Sequence*> >::const_iterator It;
189 for (It = m_TableVector.begin(); It != m_TableVector.end(); ++It) {
192 m_stepIdList.push_back(It->second->getSeqID());
195 log << MSG::DEBUG <<
"finish initializing sub-algorithms" << endreq;
196 return StatusCode::SUCCESS;
203 MsgStream log( messageService(), name() );
204 log << MSG::DEBUG <<
"*** Executing StepHandler *** " << FSMState() << endreq;
208#ifdef TIME_MEASUREMENT
218 log << MSG::DEBUG <<
"point: " << m_EFResult <<
" " << m_evtType <<
" " << sequencerAlg << endreq;
221 if(!sequencerAlg)
return StatusCode::FAILURE;
222 sequencerAlg->
reset();
224 std::string answer, result;
225 std::string::size_type separator;
227 std::vector<std::string>::const_iterator
id = m_stepIdList.begin();
229 while (
id != m_stepIdList.end()) {
230 log << MSG::DEBUG <<
"In step " << (*id) << endreq;
234 log << MSG::DEBUG <<
" Step Sequencer failed" << endreq;
239 log << MSG::DEBUG <<
"+++++++++++++++++++++++++++++" << endreq;
242 std::string midAnswer = decisionAlg->
getContinue();
246 if (StepDec>0) m_EFResult->
push_back(StepDec);
254 log << MSG::DEBUG <<
" Matched Criteria, Behaviour = " << answer << endreq;
256 separator = answer.find(
'_');
257 if (separator == std::string::npos) {
258 log << MSG::ERROR <<
" Unknown decision result: "<< answer << endreq;
259 return StatusCode::FAILURE;
261 std::string perform = answer.substr(0, separator);
266 if (perform ==
"reject") {
270 else if (perform ==
"accept") {
274 else if (perform ==
"jump") {
275 std::string nextId = answer.substr(separator+1);
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;
285 log << MSG::ERROR <<
" Unknown decision result: "<< answer << endreq;
286 return StatusCode::FAILURE;
293 log << MSG::DEBUG <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
295 if (result ==
"Accepted") {
296 std::string evtMark = answer.substr(separator+1);
297 log << MSG::DEBUG <<
" Event is Accepted as " << evtMark << endreq;
300 else if (result ==
"Rejected") {
304 std::string evtMark =
"Beamgas";
306 log << MSG::DEBUG <<
" Event is Rejected" << endreq;
309 log << MSG::WARNING <<
" Unknown Behaviour, force to Reject" << endreq;
312 log << MSG::DEBUG <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
315#ifdef TIME_MEASUREMENT
317 g_StepHandlerTime=m_timer[0]->elapsed();
319 StatusCode status = m_tuple->write();
320 if (!status.isSuccess()) {
321 log << MSG::ERROR <<
"Can't fill ntuple!" << endreq;
325 return StatusCode::SUCCESS;