RootIoSvc Class Reference

Service that implements the IRunable interface, to control the event loop. Based on RootIoSvc of Glast. More...

Inheritance diagram for RootIoSvc:

IRootIoSvc List of all members.

Public Member Functions

virtual StatusCode run ()
 for the IRunnable interfce
virtual StatusCode initialize ()
 perform initializations for this service.
virtual StatusCode finalize ()
 perform the finalization, as required for a service.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 Query interface.
virtual void handle (const Incident &inc)
 Handles incidents, implementing IIncidentListener interface.
virtual int getEvtMax ()
virtual void setRootEvtMax (unsigned int max)
virtual void setRootTimeMax (unsigned int max)
virtual void registerRootTree (TChain *ch)
virtual bool setIndex (int i)
virtual int index ()
virtual bool setRunEventPair (std::pair< int, int > ids)
virtual std::pair< int, int > runEventPair ()
virtual int getAutoSaveInterval ()

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Protected Member Functions

 RootIoSvc (const std::string &name, ISvcLocator *al)
 Standard Constructor.
virtual ~RootIoSvc ()
 destructor

Private Member Functions

void beginEvent ()
void endEvent ()

Private Attributes

IAppMgrUI * m_appMgrUI
 Reference to application manager UI.
IntegerProperty m_evtMax
IntegerProperty m_autoSaveInterval
DoubleProperty m_startTime
DoubleProperty m_endTime
unsigned int m_rootEvtMax
int m_index
std::pair< int, int > m_runEventPair
std::vector< TChain * > m_chainCol

Friends

class SvcFactory< RootIoSvc >
 Allow SvcFactory to instantiate the service.

Detailed Description

Service that implements the IRunable interface, to control the event loop. Based on RootIoSvc of Glast.

Definition at line 44 of file RootIoSvc.cxx.


Constructor & Destructor Documentation

RootIoSvc::RootIoSvc ( const std::string name,
ISvcLocator *  al 
) [protected]

Standard Constructor.

Definition at line 127 of file RootIoSvc.cxx.

References m_autoSaveInterval, m_chainCol, m_endTime, m_evtMax, m_index, m_rootEvtMax, m_runEventPair, and m_startTime.

00128 : Service(name,svc)
00129 {
00130     
00131     declareProperty("EvtMax"     , m_evtMax=0);
00132     declareProperty("StartTime"   , m_startTime=0);
00133     declareProperty("EndTime",      m_endTime=0);
00134     declareProperty("AutoSaveInterval", m_autoSaveInterval=1000);
00135     declareProperty("StartingIndex", m_index=-1);
00136     m_rootEvtMax = 0;
00137     //m_index = -1;
00138     m_runEventPair = std::pair<int,int>(-1,-1);
00139     m_chainCol.clear();
00140 }

RootIoSvc::~RootIoSvc (  )  [protected, virtual]

destructor

Definition at line 144 of file RootIoSvc.cxx.

References m_chainCol.

00145 {
00146     m_chainCol.clear();
00147 }


Member Function Documentation

void RootIoSvc::beginEvent (  )  [private]

Definition at line 257 of file RootIoSvc.cxx.

Referenced by handle().

00258 { 
00259 }

void RootIoSvc::endEvent (  )  [private]

Definition at line 261 of file RootIoSvc.cxx.

References m_index, and m_runEventPair.

Referenced by handle().

00262 {        
00263     m_index = -1;
00264     m_runEventPair = std::pair<int, int>(-1,-1);
00265 }

StatusCode RootIoSvc::finalize (  )  [virtual]

perform the finalization, as required for a service.

Definition at line 183 of file RootIoSvc.cxx.

00184 {
00185     StatusCode  status = StatusCode::SUCCESS;
00186     return status;
00187 }

virtual int RootIoSvc::getAutoSaveInterval (  )  [inline, virtual]

Implements IRootIoSvc.

Definition at line 85 of file RootIoSvc.cxx.

References m_autoSaveInterval.

00085 { return m_autoSaveInterval; };

virtual int RootIoSvc::getEvtMax (  )  [inline, virtual]

Implements IRootIoSvc.

Definition at line 71 of file RootIoSvc.cxx.

References m_evtMax.

00071 { return m_evtMax; };

void RootIoSvc::handle ( const Incident &  inc  )  [virtual]

Handles incidents, implementing IIncidentListener interface.

Definition at line 250 of file RootIoSvc.cxx.

References beginEvent(), and endEvent().

00251 {
00252     if( inc.type()=="BeginEvent")beginEvent();
00253     else if(inc.type()=="EndEvent")endEvent();
00254 }

virtual int RootIoSvc::index (  )  [inline, virtual]

Implements IRootIoSvc.

Definition at line 80 of file RootIoSvc.cxx.

References m_index.

00080 { return m_index; };

StatusCode RootIoSvc::initialize (  )  [virtual]

perform initializations for this service.

Definition at line 151 of file RootIoSvc.cxx.

References m_appMgrUI, and msgSvc().

00152 {   
00153     StatusCode  status =  Service::initialize ();
00154     
00155     // bind all of the properties for this service
00156     setProperties ();
00157     
00158     // open the message log
00159     MsgStream log( msgSvc(), name() );
00160     
00161     status = serviceLocator()->queryInterface(IAppMgrUI::interfaceID(), (void**)&m_appMgrUI);
00162     
00163     // use the incident service to register begin, end events
00164     IIncidentSvc* incsvc = 0;
00165     status = service ("IncidentSvc", incsvc, true);
00166 
00167     if( status.isFailure() ) return status;
00168 
00169     incsvc->addListener(this, "BeginEvent", 100);
00170     incsvc->addListener(this, "EndEvent", 0);
00171 
00172     // Tell ROOT to reset signals to their default behavior
00173     gSystem->ResetSignal(kSigBus); 
00174     gSystem->ResetSignal(kSigSegmentationViolation); 
00175     gSystem->ResetSignal(kSigIllegalInstruction); 
00176     gSystem->ResetSignal(kSigFloatingException);  
00177 
00178     return StatusCode::SUCCESS;
00179 }

static const InterfaceID& IRootIoSvc::interfaceID (  )  [inline, static, inherited]

Retrieve interface ID.

Definition at line 40 of file IRootIoSvc.h.

References IID_IRootIoSvc().

00040 { return IID_IRootIoSvc; }

StatusCode RootIoSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
) [virtual]

Query interface.

Definition at line 190 of file RootIoSvc.cxx.

References IID_IRootIoSvc().

00190                                                                                   {
00191     if ( IID_IRootIoSvc.versionMatch(riid) )  {
00192         *ppvInterface = (IRootIoSvc*)this;
00193     }else if (IRunable::interfaceID().versionMatch(riid) ) {
00194       *ppvInterface = (IRunable*)this;
00195         } else if (IIncidentListener::interfaceID().versionMatch(riid) ) {
00196                 *ppvInterface = (IIncidentListener*)this;
00197         } else  {
00198         return Service::queryInterface(riid, ppvInterface);
00199     }
00200 
00201     addRef();
00202     return SUCCESS;
00203 }

void RootIoSvc::registerRootTree ( TChain *  ch  )  [virtual]

Implements IRootIoSvc.

Definition at line 222 of file RootIoSvc.cxx.

References m_chainCol.

00222                                            {
00223     m_chainCol.push_back(ch);
00224 }

StatusCode RootIoSvc::run (  )  [virtual]

for the IRunnable interfce

Definition at line 267 of file RootIoSvc.cxx.

References boss::Algorithm, calibUtil::ERROR, Bes_Common::INFO, m_appMgrUI, m_endTime, m_evtMax, m_rootEvtMax, m_startTime, msgSvc(), and Bes_Common::WARNING.

00267                          {
00268     // Purpose and Method:  Control the event loop
00269 
00270     StatusCode status = StatusCode::FAILURE;
00271     MsgStream log( msgSvc(), name() );
00272 
00273     if ( 0 == m_appMgrUI )  return status; 
00274 
00275     IProperty* propMgr=0;
00276     status = serviceLocator()->service("ApplicationMgr", propMgr );
00277     if( status.isFailure()) {
00278         log << MSG::ERROR << "Unable to locate PropertyManager Service" << endreq;
00279         return status;
00280     }
00281     
00282     IntegerProperty evtMax("EvtMax",0);
00283     status = propMgr->getProperty( &evtMax );
00284     if (status.isFailure()) return status;
00285  
00286     // Determine if the min number of ROOT events is less than the
00287     // requested number of events in the jobOptions file
00288     IntegerProperty rootEvtMax("EvtMax", m_rootEvtMax);
00289     if (rootEvtMax < evtMax) setProperty(rootEvtMax);
00290     else setProperty(evtMax);
00291 
00292     // now find the top alg so we can monitor its error count
00293     //
00294     IAlgManager* theAlgMgr;
00295     status = serviceLocator( )->getService( "ApplicationMgr",
00296         IAlgManager::interfaceID(),
00297         (IInterface*&)theAlgMgr );
00298     IAlgorithm* theIAlg;
00299     Algorithm*  theAlgorithm=0;
00300     IntegerProperty errorProperty("ErrorCount",0);
00301     
00302     status = theAlgMgr->getAlgorithm( "Top", theIAlg );
00303     if ( status.isSuccess( ) ) {
00304         try{
00305             theAlgorithm = dynamic_cast<Algorithm*>(theIAlg);
00306         } catch(...){
00307             status = StatusCode::FAILURE;
00308         }
00309     }
00310     if ( status.isFailure( ) ) {
00311         log << MSG::WARNING << "Could not find algorithm 'Top'; will not monitor errors" << endreq;
00312     }
00313     
00314     
00315     // loop over the events
00316 
00317     int eventNumber= 0;
00318     double currentTime=m_startTime;
00319     
00320     { bool noend=true;
00321     log << MSG::INFO << "Runable interface starting event loop as :" ; 
00322     if( m_evtMax>0)  { log << " MaxEvt = " << m_evtMax; noend=false;  }
00323     if( m_endTime>0) { log << " EndTime= " << m_endTime; noend=false; }
00324     log << endreq;
00325     
00326     if(noend) { 
00327         log << MSG::WARNING << "No end condition specified: will not process any events!" << endreq; 
00328     }
00329     }
00330     // Not yet using time as a control on the event loop for ROOT
00331     while( m_evtMax>0 && eventNumber < m_evtMax
00332         || m_endTime>0 && currentTime< m_endTime ) {
00333         
00334         status =  m_appMgrUI->nextEvent(1); // currently, always success
00335         
00336         // the single event may have created a failure. Check the ErrorCount propery of the Top alg.
00337         if( theAlgorithm !=0) theAlgorithm->getProperty(&errorProperty);
00338         if( status.isFailure() || errorProperty.value() > 0){
00339             status = StatusCode::FAILURE;
00340         }
00341         
00342         if( status.isFailure()) break;
00343         //if(flux!=0){
00344          //   currentTime = flux->gpsTime();
00345        // }
00346         eventNumber ++;
00347     }
00348     if( status.isFailure()){
00349         log << MSG::ERROR << "Terminating RootIoSvc loop due to error" << endreq;
00350         
00351     }else if( m_endTime>0 && currentTime >= m_endTime ) {
00352         log << MSG::INFO << "Loop terminated by time " << endreq;
00353     }else {
00354         log << MSG::INFO << "Processing loop terminated by event count" << endreq;
00355     }
00356     return status;
00357 }

virtual std::pair<int,int> RootIoSvc::runEventPair (  )  [inline, virtual]

Implements IRootIoSvc.

Definition at line 83 of file RootIoSvc.cxx.

References m_runEventPair.

00083 { return m_runEventPair; };

bool RootIoSvc::setIndex ( int  i  )  [virtual]

Implements IRootIoSvc.

Definition at line 226 of file RootIoSvc.cxx.

References m_chainCol, m_index, and m_runEventPair.

00226                               {
00227      if (i < 0) return false;
00228      std::vector<TChain*>::iterator it;
00229      for(it = m_chainCol.begin(); it != m_chainCol.end(); it++) {
00230        if (i >= (*it)->GetEntries()) return false;
00231      }
00232      m_index = i;
00233      m_runEventPair = std::pair<int, int>(-1,-1);
00234      return true;
00235 }

void RootIoSvc::setRootEvtMax ( unsigned int  max  )  [virtual]

Implements IRootIoSvc.

Definition at line 206 of file RootIoSvc.cxx.

References m_rootEvtMax.

00206                                               {
00207     // Purpose and Method:  Allow users of the RootIoSvc to specify the number
00208     //  of events found in their ROOT files
00209     if (m_rootEvtMax == 0) {
00210         m_rootEvtMax = max;
00211         return;
00212     } 
00213     
00214     if (m_rootEvtMax > max) m_rootEvtMax = max;
00215 }

void RootIoSvc::setRootTimeMax ( unsigned int  max  )  [virtual]

Implements IRootIoSvc.

Definition at line 217 of file RootIoSvc.cxx.

00217                                                {
00218     // Not yet used
00219     return;
00220 }

bool RootIoSvc::setRunEventPair ( std::pair< int, int >  ids  )  [virtual]

Implements IRootIoSvc.

Definition at line 238 of file RootIoSvc.cxx.

References m_chainCol, m_index, and m_runEventPair.

00238                                                      {
00239     std::vector<TChain*>::iterator it;
00240     for(it = m_chainCol.begin(); it != m_chainCol.end(); it++) {
00241         int readInd = (*it)->GetEntryNumberWithIndex(ids.first, ids.second);
00242         if ( (readInd < 0) || (readInd >= (*it)->GetEntries()) ) return false;
00243     }
00244     m_runEventPair = ids;
00245     m_index=-1;
00246     return true;
00247 }


Friends And Related Function Documentation

friend class SvcFactory< RootIoSvc > [friend]

Allow SvcFactory to instantiate the service.

Definition at line 101 of file RootIoSvc.cxx.


Member Data Documentation

IAppMgrUI* RootIoSvc::m_appMgrUI [private]

Reference to application manager UI.

Definition at line 104 of file RootIoSvc.cxx.

Referenced by initialize(), and run().

IntegerProperty RootIoSvc::m_autoSaveInterval [private]

Definition at line 106 of file RootIoSvc.cxx.

Referenced by getAutoSaveInterval(), and RootIoSvc().

std::vector<TChain *> RootIoSvc::m_chainCol [private]

Definition at line 115 of file RootIoSvc.cxx.

Referenced by registerRootTree(), RootIoSvc(), setIndex(), setRunEventPair(), and ~RootIoSvc().

DoubleProperty RootIoSvc::m_endTime [private]

Definition at line 110 of file RootIoSvc.cxx.

Referenced by RootIoSvc(), and run().

IntegerProperty RootIoSvc::m_evtMax [private]

Definition at line 105 of file RootIoSvc.cxx.

Referenced by getEvtMax(), RootIoSvc(), and run().

int RootIoSvc::m_index [private]

Definition at line 113 of file RootIoSvc.cxx.

Referenced by endEvent(), index(), RootIoSvc(), setIndex(), and setRunEventPair().

unsigned int RootIoSvc::m_rootEvtMax [private]

Definition at line 112 of file RootIoSvc.cxx.

Referenced by RootIoSvc(), run(), and setRootEvtMax().

std::pair<int, int> RootIoSvc::m_runEventPair [private]

Definition at line 114 of file RootIoSvc.cxx.

Referenced by endEvent(), RootIoSvc(), runEventPair(), setIndex(), and setRunEventPair().

DoubleProperty RootIoSvc::m_startTime [private]

Definition at line 109 of file RootIoSvc.cxx.

Referenced by RootIoSvc(), and run().


Generated on Tue Nov 29 23:35:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7