53 MsgStream log( messageService(), name() );
55 Algorithm::initialize();
57 StatusCode sc = service(
"HltConfigSvc", m_HltConfigSvc);
59 log << MSG::FATAL << name() <<
": Unable to locate HltConfigSvc" << endreq;
62 sc = service(
"HltStoreSvc", m_HltStoreSvc);
64 log << MSG::FATAL << name() <<
": Unable to locate HltStoreSvc" << endreq;
100 m_HltStoreSvc->
put(
"EFResult", m_EFResult);
102 log << MSG::ERROR <<
"Unvalid m_EFResult" << endreq;
103 return StatusCode::FAILURE;
106 m_evtType =
new EFResult(m_tmp_evtType);
108 m_HltStoreSvc->
put(
"EventType", m_evtType);
110 log << MSG::ERROR <<
"Unvalid m_evtType" << endreq;
111 return StatusCode::FAILURE;
113#ifdef TIME_MEASUREMENT
114 sc = service(
"BesTimerSvc", m_timersvc);
115 if (sc.isFailure()) {
116 log << MSG::WARNING << name() <<
": Unable to locate BesTimer Service" << endreq;
117 return StatusCode::FAILURE;
119 m_timer[0] = m_timersvc->addItem(
"Step Handler Time");
120 m_timer[1] = m_timersvc->addItem(
"1stStep exec Time");
121 m_timer[2] = m_timersvc->addItem(
"1stStep deci Time");
122 m_timer[3] = m_timersvc->addItem(
"2ndStep exec Time");
123 m_timer[4] = m_timersvc->addItem(
"2ndStep deci Time");
128 m_tuple->addItem(
"total", g_StepHandlerTime);
129 m_tuple->addItem(
"mdc", g_1stStepExecTime);
130 m_tuple->addItem(
"mdcd", g_1stStepDeciTime);
131 m_tuple->addItem(
"emc", g_2ndStepExecTime);
132 m_tuple->addItem(
"emcd", g_2ndStepDeciTime);
134 m_tuple =
ntupleSvc()->book(
"FILE444/nt",CLID_ColumnWiseTuple,
"StepCnt");
136 m_tuple->addItem(
"total", g_StepHandlerTime);
137 m_tuple->addItem(
"mdc", g_1stStepExecTime);
138 m_tuple->addItem(
"mdcd", g_1stStepDeciTime);
139 m_tuple->addItem(
"emc", g_2ndStepExecTime);
140 m_tuple->addItem(
"emcd", g_2ndStepDeciTime);
142 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_tuple) << endmsg;
143 return StatusCode::FAILURE;
149 log << MSG::INFO <<
"Initialization " << name() <<
" completed successfully" << endreq;
150 return StatusCode::SUCCESS;
162 MsgStream log( messageService(), name() );
164 Algorithm::beginRun();
169 StatusCode sc = createSubAlgorithm(
"StepSequencer",
"StepSequencer", p_seqAlg);
170 if( sc.isFailure() ) {
171 log << MSG::FATAL <<
"Unable to create StepSequencer SubAlgorithm " << endreq;
175 log << MSG::DEBUG <<
"created SubAlgorithm StepSequencer/StepSequencer" << endreq;
178 sc = createSubAlgorithm(
"StepDecision",
"StepDecision", p_decAlg);
179 if( sc.isFailure() ) {
180 log << MSG::FATAL <<
"Unable to create StepDecision SubAlgorithm " << endreq;
184 log << MSG::DEBUG <<
"created SubAlgorithm StepDecision/StepDecision" << endreq;
187 const std::vector<std::pair<Signature*,Sequence*> >& m_TableVector = m_HltConfigSvc->
retrieve();
188 std::vector<std::pair<Signature*,Sequence*> >::const_iterator It;
190 for (It = m_TableVector.begin(); It != m_TableVector.end(); ++It) {
193 m_stepIdList.push_back(It->second->getSeqID());
196 log << MSG::DEBUG <<
"finish initializing sub-algorithms" << endreq;
197 return StatusCode::SUCCESS;
204 MsgStream log( messageService(), name() );
205 log << MSG::DEBUG <<
"*** Executing StepHandler *** " << FSMState() << endreq;
209#ifdef TIME_MEASUREMENT
219 log << MSG::DEBUG <<
"point: " << m_EFResult <<
" " << m_evtType <<
" " << sequencerAlg << endreq;
222 if(!sequencerAlg)
return StatusCode::FAILURE;
223 sequencerAlg->
reset();
225 std::string answer, result;
226 std::string::size_type separator;
228 std::vector<std::string>::const_iterator
id = m_stepIdList.begin();
230 while (
id != m_stepIdList.end()) {
231 log << MSG::DEBUG <<
"In step " << (*id) << endreq;
235 log << MSG::DEBUG <<
" Step Sequencer failed" << endreq;
240 log << MSG::DEBUG <<
"+++++++++++++++++++++++++++++" << endreq;
243 std::string midAnswer = decisionAlg->
getContinue();
247 if (StepDec>0) m_EFResult->
push_back(StepDec);
255 log << MSG::DEBUG <<
" Matched Criteria, Behaviour = " << answer << endreq;
257 separator = answer.find(
'_');
258 if (separator == std::string::npos) {
259 log << MSG::ERROR <<
" Unknown decision result: "<< answer << endreq;
260 return StatusCode::FAILURE;
262 std::string perform = answer.substr(0, separator);
267 if (perform ==
"reject") {
271 else if (perform ==
"accept") {
275 else if (perform ==
"jump") {
276 std::string nextId = answer.substr(separator+1);
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;
286 log << MSG::ERROR <<
" Unknown decision result: "<< answer << endreq;
287 return StatusCode::FAILURE;
294 log << MSG::DEBUG <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
296 if (result ==
"Accepted") {
297 std::string evtMark = answer.substr(separator+1);
298 log << MSG::DEBUG <<
" Event is Accepted as " << evtMark << endreq;
301 else if (result ==
"Rejected") {
305 std::string evtMark =
"Beamgas";
307 log << MSG::DEBUG <<
" Event is Rejected" << endreq;
310 log << MSG::WARNING <<
" Unknown Behaviour, force to Reject" << endreq;
313 log << MSG::DEBUG <<
"==============" <<m_evtType->
getAnswerIndex()<< endreq;
316#ifdef TIME_MEASUREMENT
318 g_StepHandlerTime=m_timer[0]->elapsed();
320 StatusCode status = m_tuple->write();
321 if (!status.isSuccess()) {
322 log << MSG::ERROR <<
"Can't fill ntuple!" << endreq;
326 return StatusCode::SUCCESS;