Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

Static Public Member Functions

const InterfaceID & interfaceID ()
 Retrieve interface ID.
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_autoSaveInterval
std::vector< TChain * > m_chainCol
DoubleProperty m_endTime
IntegerProperty m_evtMax
int m_index
unsigned int m_rootEvtMax
std::pair< int, int > m_runEventPair
DoubleProperty m_startTime

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.


Constructor & Destructor Documentation

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

Standard Constructor.

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

00145 {
00146     m_chainCol.clear();
00147 }


Member Function Documentation

void RootIoSvc::beginEvent  )  [private]
 

00258 { 
00259 }

void RootIoSvc::endEvent  )  [private]
 

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.

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

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

Implements IRootIoSvc.

00085 { return m_autoSaveInterval; };

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

Implements IRootIoSvc.

00071 { return m_evtMax; };

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

Handles incidents, implementing IIncidentListener interface.

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

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

Implements IRootIoSvc.

00080 { return m_index; };

StatusCode RootIoSvc::initialize  )  [virtual]
 

perform initializations for this service.

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(IID_IAppMgrUI, (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 }

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

Retrieve interface ID.

00040 { return IID_IRootIoSvc; }

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

Retrieve interface ID.

00040 { return IID_IRootIoSvc; }

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

Query interface.

00190                                                                                   {
00191     if ( IID_IRootIoSvc.versionMatch(riid) )  {
00192         *ppvInterface = (IRootIoSvc*)this;
00193     }else if (IID_IRunable.versionMatch(riid) ) {
00194       *ppvInterface = (IRunable*)this;
00195         } else if (IID_IIncidentListener.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.

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

StatusCode RootIoSvc::run  )  [virtual]
 

for the IRunnable interfce

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         IID_IAlgManager,
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.

00083 { return m_runEventPair; };

bool RootIoSvc::setIndex int  i  )  [virtual]
 

Implements IRootIoSvc.

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.

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.

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

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

Implements IRootIoSvc.

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.


Member Data Documentation

IAppMgrUI* RootIoSvc::m_appMgrUI [private]
 

Reference to application manager UI.

IntegerProperty RootIoSvc::m_autoSaveInterval [private]
 

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

DoubleProperty RootIoSvc::m_endTime [private]
 

IntegerProperty RootIoSvc::m_evtMax [private]
 

int RootIoSvc::m_index [private]
 

unsigned int RootIoSvc::m_rootEvtMax [private]
 

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

DoubleProperty RootIoSvc::m_startTime [private]
 


The documentation for this class was generated from the following file:
Generated on Wed Feb 2 18:48:53 2011 for BOSS6.5.5 by  doxygen 1.3.9.1