CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
RootIoSvc Class Reference

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

+ Inheritance diagram for RootIoSvc:

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 ()
 
- Public Member Functions inherited from IRootIoSvc

Protected Member Functions

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

Friends

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

Additional Inherited Members

- Static Public Member Functions inherited from IRootIoSvc
static const InterfaceID & interfaceID ()
 Retrieve interface ID.
 

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::RootIoSvc ( const std::string & name,
ISvcLocator * al )
protected

Standard Constructor.

Definition at line 127 of file RootIoSvc.cxx.

128: Service(name,svc)
129{
130
131 declareProperty("EvtMax" , m_evtMax=0);
132 declareProperty("StartTime" , m_startTime=0);
133 declareProperty("EndTime", m_endTime=0);
134 declareProperty("AutoSaveInterval", m_autoSaveInterval=1000);
135 declareProperty("StartingIndex", m_index=-1);
136 m_rootEvtMax = 0;
137 //m_index = -1;
138 m_runEventPair = std::pair<int,int>(-1,-1);
139 m_chainCol.clear();
140}

◆ ~RootIoSvc()

RootIoSvc::~RootIoSvc ( )
protectedvirtual

destructor

Standard Destructor.

Definition at line 144 of file RootIoSvc.cxx.

145{
146 m_chainCol.clear();
147}

Member Function Documentation

◆ finalize()

StatusCode RootIoSvc::finalize ( )
virtual

perform the finalization, as required for a service.

Definition at line 183 of file RootIoSvc.cxx.

184{
185 StatusCode status = StatusCode::SUCCESS;
186 return status;
187}

◆ getAutoSaveInterval()

virtual int RootIoSvc::getAutoSaveInterval ( )
inlinevirtual

Implements IRootIoSvc.

Definition at line 85 of file RootIoSvc.cxx.

85{ return m_autoSaveInterval; };

◆ getEvtMax()

virtual int RootIoSvc::getEvtMax ( )
inlinevirtual

Implements IRootIoSvc.

Definition at line 71 of file RootIoSvc.cxx.

71{ return m_evtMax; };

◆ handle()

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

Handles incidents, implementing IIncidentListener interface.

Definition at line 250 of file RootIoSvc.cxx.

251{
252 if( inc.type()=="BeginEvent")beginEvent();
253 else if(inc.type()=="EndEvent")endEvent();
254}

◆ index()

virtual int RootIoSvc::index ( )
inlinevirtual

Implements IRootIoSvc.

Definition at line 80 of file RootIoSvc.cxx.

80{ return m_index; };

◆ initialize()

StatusCode RootIoSvc::initialize ( )
virtual

perform initializations for this service.

Definition at line 151 of file RootIoSvc.cxx.

152{
153 StatusCode status = Service::initialize ();
154
155 // bind all of the properties for this service
156 setProperties ();
157
158 // open the message log
159 MsgStream log( msgSvc(), name() );
160
161 status = serviceLocator()->queryInterface(IAppMgrUI::interfaceID(), (void**)&m_appMgrUI);
162
163 // use the incident service to register begin, end events
164 IIncidentSvc* incsvc = 0;
165 status = service ("IncidentSvc", incsvc, true);
166
167 if( status.isFailure() ) return status;
168
169 incsvc->addListener(this, "BeginEvent", 100);
170 incsvc->addListener(this, "EndEvent", 0);
171
172 // Tell ROOT to reset signals to their default behavior
173 gSystem->ResetSignal(kSigBus);
174 gSystem->ResetSignal(kSigSegmentationViolation);
175 gSystem->ResetSignal(kSigIllegalInstruction);
176 gSystem->ResetSignal(kSigFloatingException);
177
178 return StatusCode::SUCCESS;
179}
IMessageSvc * msgSvc()

◆ queryInterface()

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

Query interface.

Definition at line 190 of file RootIoSvc.cxx.

190 {
191 if ( IID_IRootIoSvc.versionMatch(riid) ) {
192 *ppvInterface = (IRootIoSvc*)this;
193 }else if (IRunable::interfaceID().versionMatch(riid) ) {
194 *ppvInterface = (IRunable*)this;
195 } else if (IIncidentListener::interfaceID().versionMatch(riid) ) {
196 *ppvInterface = (IIncidentListener*)this;
197 } else {
198 return Service::queryInterface(riid, ppvInterface);
199 }
200
201 addRef();
202 return SUCCESS;
203}
The RootIoSvc gaudi service interface.
Definition IRootIoSvc.h:23

◆ registerRootTree()

void RootIoSvc::registerRootTree ( TChain * ch)
virtual

Implements IRootIoSvc.

Definition at line 222 of file RootIoSvc.cxx.

222 {
223 m_chainCol.push_back(ch);
224}
TChain ch("t1")

◆ run()

StatusCode RootIoSvc::run ( )
virtual

for the IRunnable interfce

Definition at line 267 of file RootIoSvc.cxx.

267 {
268 // Purpose and Method: Control the event loop
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 // Determine if the min number of ROOT events is less than the
287 // requested number of events in the jobOptions file
288 IntegerProperty rootEvtMax("EvtMax", m_rootEvtMax);
289 if (rootEvtMax < evtMax) setProperty(rootEvtMax);
290 else setProperty(evtMax);
291
292 // now find the top alg so we can monitor its error count
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 // loop over the events
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 // Not yet using time as a control on the event loop for ROOT
331 while( m_evtMax>0 && eventNumber < m_evtMax
332 || m_endTime>0 && currentTime< m_endTime ) {
333
334 status = m_appMgrUI->nextEvent(1); // currently, always success
335
336 // the single event may have created a failure. Check the ErrorCount propery of the Top alg.
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 //if(flux!=0){
344 // currentTime = flux->gpsTime();
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}

◆ runEventPair()

virtual std::pair< int, int > RootIoSvc::runEventPair ( )
inlinevirtual

Implements IRootIoSvc.

Definition at line 83 of file RootIoSvc.cxx.

83{ return m_runEventPair; };

◆ setIndex()

bool RootIoSvc::setIndex ( int i)
virtual

Implements IRootIoSvc.

Definition at line 226 of file RootIoSvc.cxx.

226 {
227 if (i < 0) return false;
228 std::vector<TChain*>::iterator it;
229 for(it = m_chainCol.begin(); it != m_chainCol.end(); it++) {
230 if (i >= (*it)->GetEntries()) return false;
231 }
232 m_index = i;
233 m_runEventPair = std::pair<int, int>(-1,-1);
234 return true;
235}

◆ setRootEvtMax()

void RootIoSvc::setRootEvtMax ( unsigned int max)
virtual

Implements IRootIoSvc.

Definition at line 206 of file RootIoSvc.cxx.

206 {
207 // Purpose and Method: Allow users of the RootIoSvc to specify the number
208 // of events found in their ROOT files
209 if (m_rootEvtMax == 0) {
210 m_rootEvtMax = max;
211 return;
212 }
213
214 if (m_rootEvtMax > max) m_rootEvtMax = max;
215}

◆ setRootTimeMax()

void RootIoSvc::setRootTimeMax ( unsigned int max)
virtual

Implements IRootIoSvc.

Definition at line 217 of file RootIoSvc.cxx.

217 {
218 // Not yet used
219 return;
220}

◆ setRunEventPair()

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

Implements IRootIoSvc.

Definition at line 238 of file RootIoSvc.cxx.

238 {
239 std::vector<TChain*>::iterator it;
240 for(it = m_chainCol.begin(); it != m_chainCol.end(); it++) {
241 int readInd = (*it)->GetEntryNumberWithIndex(ids.first, ids.second);
242 if ( (readInd < 0) || (readInd >= (*it)->GetEntries()) ) return false;
243 }
244 m_runEventPair = ids;
245 m_index=-1;
246 return true;
247}

Friends And Related Symbol Documentation

◆ SvcFactory< RootIoSvc >

friend class SvcFactory< RootIoSvc >
friend

Allow SvcFactory to instantiate the service.

Definition at line 98 of file RootIoSvc.cxx.


The documentation for this class was generated from the following file: