267 {
268
269
270 StatusCode status = StatusCode::FAILURE;
271 MsgStream log(
msgSvc(), name() );
272
273 if ( 0 == m_appMgrUI ) return status;
274
275 IProperty* propMgr=0;
276 status = serviceLocator()->service("ApplicationMgr", propMgr );
277 if( status.isFailure()) {
278 log << MSG::ERROR << "Unable to locate PropertyManager Service" << endreq;
279 return status;
280 }
281
282 IntegerProperty evtMax("EvtMax",0);
283 status = propMgr->getProperty( &evtMax );
284 if (status.isFailure()) return status;
285
286
287
288 IntegerProperty rootEvtMax("EvtMax", m_rootEvtMax);
289 if (rootEvtMax < evtMax) setProperty(rootEvtMax);
290 else setProperty(evtMax);
291
292
293
294 IAlgManager* theAlgMgr;
295 status = serviceLocator( )->getService( "ApplicationMgr",
296 IAlgManager::interfaceID(),
297 (IInterface*&)theAlgMgr );
298 IAlgorithm* theIAlg;
299 Algorithm* theAlgorithm=0;
300 IntegerProperty errorProperty("ErrorCount",0);
301
302 status = theAlgMgr->getAlgorithm( "Top", theIAlg );
303 if ( status.isSuccess( ) ) {
304 try{
305 theAlgorithm = dynamic_cast<Algorithm*>(theIAlg);
306 } catch(...){
307 status = StatusCode::FAILURE;
308 }
309 }
310 if ( status.isFailure( ) ) {
311 log << MSG::WARNING << "Could not find algorithm 'Top'; will not monitor errors" << endreq;
312 }
313
314
315
316
317 int eventNumber= 0;
318 double currentTime=m_startTime;
319
320 { bool noend=true;
321 log << MSG::INFO << "Runable interface starting event loop as :" ;
322 if( m_evtMax>0) { log << " MaxEvt = " << m_evtMax; noend=false; }
323 if( m_endTime>0) { log << " EndTime= " << m_endTime; noend=false; }
324 log << endreq;
325
326 if(noend) {
327 log << MSG::WARNING << "No end condition specified: will not process any events!" << endreq;
328 }
329 }
330
331 while( m_evtMax>0 && eventNumber < m_evtMax
332 || m_endTime>0 && currentTime< m_endTime ) {
333
334 status = m_appMgrUI->nextEvent(1);
335
336
337 if( theAlgorithm !=0) theAlgorithm->getProperty(&errorProperty);
338 if( status.isFailure() || errorProperty.value() > 0){
339 status = StatusCode::FAILURE;
340 }
341
342 if( status.isFailure()) break;
343
344
345
346 eventNumber ++;
347 }
348 if( status.isFailure()){
349 log << MSG::ERROR << "Terminating RootIoSvc loop due to error" << endreq;
350
351 }else if( m_endTime>0 && currentTime >= m_endTime ) {
352 log << MSG::INFO << "Loop terminated by time " << endreq;
353 }else {
354 log << MSG::INFO << "Processing loop terminated by event count" << endreq;
355 }
356 return status;
357}