BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
OfflineEventLoopMgr Class Reference

#include <OfflineEventLoopMgr.h>

+ Inheritance diagram for OfflineEventLoopMgr:

Public Member Functions

 OfflineEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor.
 
virtual ~OfflineEventLoopMgr ()
 Standard Destructor.
 
StatusCode getEventRoot (IOpaqueAddress *&refpAddr)
 Create event address using event selector.
 
virtual StatusCode initialize ()
 implementation of IService::initalize
 
virtual StatusCode reinitialize ()
 implementation of IService::reinitalize
 
virtual StatusCode finalize ()
 implementation of IService::finalize
 
virtual StatusCode nextEvent (int maxevt)
 implementation of IService::nextEvent
 
virtual StatusCode executeEvent (void *par)
 implementation of IEventProcessor::executeEvent(void* par)
 
virtual StatusCode executeRun (int maxevt)
 implementation of IEventProcessor::executeRun()
 

Protected Attributes

IIncidentSvc * m_incidentSvc
 Reference to the indicent service.
 
IDataManagerSvc * m_evtDataMgrSvc
 Reference to the Event Data Service's IDataManagerSvc interface.
 
IDataProviderSvc * m_evtDataSvc
 Reference to the Event Data Service's IDataProviderSvc interface.
 
IEvtSelector * m_evtSelector
 Reference to the Event Selector.
 
IEvtSelector::Context * m_evtContext
 Event Iterator.
 
std::string m_evtsel
 Event selector.
 
IDataManagerSvc * m_histoDataMgrSvc
 Reference to the Histogram Data Service.
 
IConversionSvc * m_histoPersSvc
 Reference to the Histogram Persistency Service.
 
std::string m_histPersName
 Name of the Hist Pers type.
 
IProperty * m_appMgrProperty
 Property interface of ApplicationMgr.
 

Friends

class SvcFactory< OfflineEventLoopMgr >
 Creator friend class.
 

Detailed Description

Class definition of OfflineEventLoopMgr. This is the default processing manager of the application manager. This object handles the minimal requirements needed by the application manager. It also handles the default user configuration setup for standard event processing.

  • handling of the incidents when starting event processing
  • handling of the event loop

History:

 +---------+----------------------------------------------+---------+
 |    Date |                 Comment                      | Who     |
 +---------+----------------------------------------------+---------+
 |13/12/00 | Initial version                              | M.Frank |
 +---------+----------------------------------------------+---------+
 
Author
Markus Frank
Version
1.0

Definition at line 37 of file OfflineEventLoopMgr.h.

Constructor & Destructor Documentation

◆ OfflineEventLoopMgr()

OfflineEventLoopMgr::OfflineEventLoopMgr ( const std::string & nam,
ISvcLocator * svcLoc )

Standard Constructor.

Definition at line 30 of file OfflineEventLoopMgr.cxx.

31: MinimalEventLoopMgr(nam, svcLoc)
32{
35 m_incidentSvc = 0;
37 m_evtDataSvc = 0;
38 m_evtSelector = 0;
39 m_evtContext = 0;
40 m_runNo = -1.1;
41 // Declare properties
42 declareProperty("HistogramPersistency", m_histPersName = "");
43 declareProperty( "EvtSel", m_evtsel );
44}
IDataProviderSvc * m_evtDataSvc
Reference to the Event Data Service's IDataProviderSvc interface.
IDataManagerSvc * m_histoDataMgrSvc
Reference to the Histogram Data Service.
std::string m_evtsel
Event selector.
IConversionSvc * m_histoPersSvc
Reference to the Histogram Persistency Service.
std::string m_histPersName
Name of the Hist Pers type.
IEvtSelector::Context * m_evtContext
Event Iterator.
IDataManagerSvc * m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
IEvtSelector * m_evtSelector
Reference to the Event Selector.
IIncidentSvc * m_incidentSvc
Reference to the indicent service.

◆ ~OfflineEventLoopMgr()

OfflineEventLoopMgr::~OfflineEventLoopMgr ( )
virtual

Standard Destructor.

Definition at line 49 of file OfflineEventLoopMgr.cxx.

49 {
50 if( m_histoDataMgrSvc ) m_histoDataMgrSvc->release();
51 if( m_histoPersSvc ) m_histoPersSvc->release();
52 if( m_incidentSvc ) m_incidentSvc->release();
53 if( m_evtDataMgrSvc ) m_evtDataMgrSvc->release();
54 if( m_evtDataSvc ) m_evtDataSvc->release();
55 if( m_evtSelector ) m_evtSelector->release();
56 if( m_evtContext ) delete m_evtContext;
57}

Member Function Documentation

◆ executeEvent()

StatusCode OfflineEventLoopMgr::executeEvent ( void * par)
virtual

implementation of IEventProcessor::executeEvent(void* par)

Definition at line 281 of file OfflineEventLoopMgr.cxx.

281 {
282 MsgStream log(msgSvc(), name());
283 // Fire BeginEvent "Incident"
284 m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent));
285 int runNo;
286 SmartDataPtr<Event::EventHeader> evt(m_evtDataSvc,"/Event/EventHeader");
287 if( evt ){
288 runNo = evt -> runNumber();
289 log << MSG::INFO <<"The runNumber of current event is "<<runNo<<endreq;
290 }
291
292 else{
293 log << MSG::ERROR << "Error accessing Event" <<endreq;
294 return StatusCode::FAILURE;
295 }
296 if(runNo!=m_runNo) {
297 log << MSG::INFO <<"fireIncident of begin run"<<endreq;
298 m_incidentSvc->fireIncident(Incident(name(),"NewRun"));
299 if(m_runNo==-1.1){
300 ListAlg::iterator it_topAlg = m_topAlgList.begin();
301 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){
302 (*it_topAlg)->beginRun();}
303 }
304 m_runNo = runNo;
305 }
306
307 // Execute Algorithms
308 StatusCode sc = MinimalEventLoopMgr::executeEvent(par);
309 // Fire EndEvent "Incident"
310 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
311
312 // Check if there was an error processing current event
313 if( !sc.isSuccess() ){
314 MsgStream log( msgSvc(), name() );
315 log << MSG::ERROR << "Terminating event processing loop due to errors" << endreq;
316 }
317
318 return sc;
319}
int runNo
Definition DQA_TO_DB.cxx:12
IMessageSvc * msgSvc()

Referenced by nextEvent().

◆ executeRun()

StatusCode OfflineEventLoopMgr::executeRun ( int maxevt)
virtual

implementation of IEventProcessor::executeRun()

Definition at line 324 of file OfflineEventLoopMgr.cxx.

324 {
325 StatusCode sc;
326 // initialize the base class
327 sc = MinimalEventLoopMgr::executeRun(maxevt);
328 return sc;
329}

◆ finalize()

StatusCode OfflineEventLoopMgr::finalize ( )
virtual

implementation of IService::finalize

Definition at line 213 of file OfflineEventLoopMgr.cxx.

213 {
214 StatusCode sc;
215 MsgStream log(msgSvc(), name());
216
217 // Finalize base class
218 MinimalEventLoopMgr::finalize();
219
220 // Save Histograms Now
221 if ( 0 != m_histoPersSvc ) {
222 HistogramAgent agent;
223 sc = m_histoDataMgrSvc->traverseTree( &agent );
224 if( sc.isSuccess() ) {
225 IDataSelector* objects = agent.selectedObjects();
226 // skip /stat entry!
227 if ( objects->size() > 0 ) {
228 IDataSelector::iterator i;
229 for ( i = objects->begin(); i != objects->end(); i++ ) {
230 IOpaqueAddress* pAddr = 0;
231 StatusCode iret = m_histoPersSvc->createRep(*i, pAddr);
232 if ( iret.isSuccess() ) {
233 (*i)->registry()->setAddress(pAddr);
234 }
235 else {
236 sc = iret;
237 }
238 }
239 for ( i = objects->begin(); i != objects->end(); i++ ) {
240 IRegistry* reg = (*i)->registry();
241 StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), *i);
242 if ( !iret.isSuccess() ) {
243 sc = iret;
244 }
245 }
246 }
247 if ( sc.isSuccess() ) {
248 log << MSG::INFO << "Histograms converted successfully according to request." << endreq;
249 }
250 else {
251 log << MSG::ERROR << "Error while saving Histograms." << endreq;
252 }
253 }
254 else {
255 log << MSG::ERROR << "Error while traversing Histogram data store" << endreq;
256 }
257 }
258
259 // Release evemt selector context
260 if ( m_evtSelector && m_evtContext ) {
261 m_evtSelector->releaseContext(m_evtContext);
262 m_evtContext = 0;
263 }
264
265 // Release all interfaces...
266 m_histoDataMgrSvc = releaseInterface(m_histoDataMgrSvc);
267 m_histoPersSvc = releaseInterface(m_histoPersSvc);
268
269 m_evtSelector = releaseInterface(m_evtSelector);
270 m_incidentSvc = releaseInterface(m_incidentSvc);
271 m_evtDataSvc = releaseInterface(m_evtDataSvc);
272 m_evtDataMgrSvc = releaseInterface(m_evtDataMgrSvc);
273
274 return StatusCode::SUCCESS;
275}

◆ getEventRoot()

StatusCode OfflineEventLoopMgr::getEventRoot ( IOpaqueAddress *& refpAddr)

Create event address using event selector.

Definition at line 420 of file OfflineEventLoopMgr.cxx.

420 {
421 refpAddr = 0;
422 StatusCode sc = m_evtSelector->next(*m_evtContext);
423 if ( !sc.isSuccess() ) {
424 return sc;
425 }
426 // Create root address and assign address to data service
427 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
428 if( !sc.isSuccess() ) {
429 sc = m_evtSelector->next(*m_evtContext);
430 if ( sc.isSuccess() ) {
431 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
432 if ( !sc.isSuccess() ) {
433 MsgStream log( msgSvc(), name() );
434 log << MSG::WARNING << "Error creating IOpaqueAddress." << endreq;
435 }
436 }
437 }
438 return sc;
439}

Referenced by nextEvent().

◆ initialize()

StatusCode OfflineEventLoopMgr::initialize ( )
virtual

implementation of IService::initalize

Definition at line 62 of file OfflineEventLoopMgr.cxx.

62 {
63 MsgStream log(msgSvc(), name());
64
65 // initilaize the base class
66 StatusCode sc = MinimalEventLoopMgr::initialize();
67 if( !sc.isSuccess() ) {
68 log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endreq;
69 return sc;
70 }
71
72 // Setup access to event data services
73 sc = serviceLocator()->service("EventDataSvc", m_evtDataMgrSvc, true);
74 if( !sc.isSuccess() ) {
75 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endreq;
76 return sc;
77 }
78 sc = serviceLocator()->service("EventDataSvc", m_evtDataSvc, true);
79 if( !sc.isSuccess() ) {
80 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endreq;
81 return sc;
82 }
83
84 // Get the references to the services that are needed by the ApplicationMgr itself
85 sc = serviceLocator()->service("IncidentSvc", m_incidentSvc, true);
86 if( !sc.isSuccess() ) {
87 log << MSG::FATAL << "Error retrieving IncidentSvc." << endreq;
88 return sc;
89 }
90
91 // Obtain the IProperty of the ApplicationMgr
92 // SmartIF<IProperty> prpMgr(IID_IProperty, serviceLocator());
93 SmartIF<IProperty> prpMgr(serviceLocator());
94 if ( ! prpMgr.isValid() ) {
95 log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endreq;
96 return StatusCode::FAILURE;
97 }
98 else {
99 m_appMgrProperty = prpMgr;
100 }
101
102 // We do not expect a Event Selector necessarily being declared
103 setProperty(m_appMgrProperty->getProperty("EvtSel"));
104
105 if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
106 sc = serviceLocator()->service( "EventSelector", m_evtSelector, true );
107 if( sc.isSuccess() ) {
108 // Setup Event Selector
109 sc=m_evtSelector->createContext(m_evtContext);
110 if( !sc.isSuccess() ) {
111 log << MSG::FATAL << "Can not create the event selector Context." << endreq;
112 return sc;
113 }
114 }
115 else {
116 log << MSG::FATAL << "EventSelector not found." << endreq;
117 return sc;
118 }
119 }
120 else {
121 m_evtSelector = 0;
122 m_evtContext = 0;
123 log << MSG::WARNING << "Unable to locate service \"EventSelector\" " << endreq;
124 log << MSG::WARNING << "No events will be processed from external input." << endreq;
125 }
126
127 // Setup access to histogramming services
128 sc = serviceLocator()->service("HistogramDataSvc", m_histoDataMgrSvc, true);
129 if( !sc.isSuccess() ) {
130 log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endreq;
131 return sc;
132 }
133 // Setup histogram persistency
134 sc = serviceLocator()->service("HistogramPersistencySvc", m_histoPersSvc, true );
135 if( !sc.isSuccess() ) {
136 log << MSG::WARNING << "Histograms cannot not be saved - though required." << endreq;
137 return sc;
138 }
139
140 return StatusCode::SUCCESS;
141}
IProperty * m_appMgrProperty
Property interface of ApplicationMgr.

◆ nextEvent()

StatusCode OfflineEventLoopMgr::nextEvent ( int maxevt)
virtual

implementation of IService::nextEvent

Definition at line 334 of file OfflineEventLoopMgr.cxx.

334 {
335 static int total_nevt = 0;
336 DataObject* pObject = 0;
337 StatusCode sc;
338 MsgStream log( msgSvc(), name() );
339
340 //yzhang add
341 //begin run
342/* ListAlg::iterator it_topAlg = m_topAlgList.begin();
343 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){
344 (*it_topAlg)->beginRun();
345 }*/
346 //zhangy add
347 // loop over events if the maxevt (received as input) if different from -1.
348 // if evtmax is -1 it means infinite loop
349 for( int nevt = 0; (maxevt == -1 ? true : nevt < maxevt); nevt++, total_nevt++) {
350 // Check if there is a scheduled stop issued by some algorithm/sevice
351 if ( m_scheduledStop ) {
352 m_scheduledStop = false;
353 log << MSG::ALWAYS << "Terminating event processing loop due to scheduled stop" << endreq;
354 break;
355 }
356 // Clear the event store, if used in the event loop
357 if( 0 != total_nevt ) {
358 sc = m_evtDataMgrSvc->clearStore();
359 if( !sc.isSuccess() ) {
360 log << MSG::DEBUG << "Clear of Event data store failed" << endreq;
361 }
362 }
363
364 // Setup event in the event store
365 if( m_evtContext ) {
366 IOpaqueAddress* addr = 0;
367 // Only if there is a EventSelector
368 sc = getEventRoot(addr);
369 if( !sc.isSuccess() ) {
370 log << MSG::INFO << "No more events in event selection " << endreq;
371 break;
372 }
373 // Set root clears the event data store first
374 sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
375 if( !sc.isSuccess() ) {
376 log << MSG::WARNING << "Error declaring event root address." << endreq;
377 continue;
378 }
379 // register event header for mc
380 SmartDataPtr<Event::EventHeader> evt(m_evtDataSvc,"/Event/EventHeader");
381 if(!evt) {
382 sc = m_evtDataMgrSvc->registerAddress ("/Event/EventHeader", addr);
383 if( !sc.isSuccess() ) {
384 log << MSG::WARNING << "Error register EventHeader address." << endreq;
385 }
386 }
387 sc = m_evtDataSvc->retrieveObject("/Event", pObject);
388 if( !sc.isSuccess() ) {
389 log << MSG::WARNING << "Unable to retrieve Event root object" << endreq;
390 break;
391 }
392 }
393 else {
394 sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
395 if( !sc.isSuccess() ) {
396 log << MSG::WARNING << "Error declaring event root DataObject" << endreq;
397 }
398 }
399
400
401
402 // Execute event for all required algorithms
403 sc = executeEvent(NULL);
404 if( !sc.isSuccess() ){
405 log << MSG::ERROR << "Terminating event processing loop due to errors" << endreq;
406 break;
407 }
408 }
409 //yzhang add
410 //end run
411 ListAlg::iterator it_topAlg = m_topAlgList.begin();
412 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){
413 (*it_topAlg)->endRun();
414 }
415 //zhangy add
416 return StatusCode::SUCCESS;
417}
Int_t nevt[10]
#define NULL
virtual StatusCode executeEvent(void *par)
implementation of IEventProcessor::executeEvent(void* par)
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.

◆ reinitialize()

StatusCode OfflineEventLoopMgr::reinitialize ( )
virtual

implementation of IService::reinitalize

Definition at line 145 of file OfflineEventLoopMgr.cxx.

145 {
146 MsgStream log(msgSvc(), name());
147
148 // initilaize the base class
149 StatusCode sc = MinimalEventLoopMgr::reinitialize();
150 if( !sc.isSuccess() ) {
151 log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endreq;
152 return sc;
153 }
154
155 // Check to see whether a new Event Selector has been specified
156 setProperty(m_appMgrProperty->getProperty("EvtSel"));
157 if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
158 IEvtSelector* theEvtSel;
159 IService* theSvc;
160 sc = serviceLocator()->service( "EventSelector", theEvtSel );
161 sc = serviceLocator()->service( "EventSelector", theSvc );
162 if( sc.isSuccess() && ( theEvtSel != m_evtSelector ) ) {
163 // Setup Event Selector
164 m_evtSelector = theEvtSel;
165 // if (theSvc->state() == IService::INITIALIZED) {
166 if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
167 sc = theSvc->reinitialize();
168 if( !sc.isSuccess() ) {
169 log << MSG::ERROR << "Failure Reinitializing EventSelector "
170 << theSvc->name( ) << endreq;
171 return sc;
172 }
173 }
174 else {
175 sc = theSvc->initialize();
176 if( !sc.isSuccess() ) {
177 log << MSG::ERROR << "Failure Initializing EventSelector "
178 << theSvc->name( ) << endreq;
179 return sc;
180 }
181 }
182 sc = m_evtSelector->createContext(m_evtContext);
183 if( !sc.isSuccess() ) {
184 log << MSG::ERROR << "Can not create Context "
185 << theSvc->name( ) << endreq;
186 return sc;
187 }
188 log << MSG::INFO << "EventSelector service changed to "
189 << theSvc->name( ) << endreq;
190 }
191 else if ( m_evtSelector && m_evtContext ) {
192 m_evtSelector->releaseContext(m_evtContext);
193 m_evtContext = 0;
194 sc = m_evtSelector->createContext(m_evtContext);
195 if( !sc.isSuccess() ) {
196 log << MSG::ERROR << "Can not create Context "
197 << theSvc->name( ) << endreq;
198 return sc;
199 }
200 }
201 }
202 else if ( m_evtSelector && m_evtContext ) {
203 m_evtSelector->releaseContext(m_evtContext);
204 m_evtSelector = 0;
205 m_evtContext = 0;
206 }
207 return StatusCode::SUCCESS;
208}

Friends And Related Symbol Documentation

◆ SvcFactory< OfflineEventLoopMgr >

friend class SvcFactory< OfflineEventLoopMgr >
friend

Creator friend class.

Definition at line 1 of file OfflineEventLoopMgr.h.

Member Data Documentation

◆ m_appMgrProperty

IProperty* OfflineEventLoopMgr::m_appMgrProperty
protected

Property interface of ApplicationMgr.

Definition at line 62 of file OfflineEventLoopMgr.h.

Referenced by initialize(), and reinitialize().

◆ m_evtContext

IEvtSelector::Context* OfflineEventLoopMgr::m_evtContext
protected

◆ m_evtDataMgrSvc

IDataManagerSvc* OfflineEventLoopMgr::m_evtDataMgrSvc
protected

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 46 of file OfflineEventLoopMgr.h.

Referenced by finalize(), initialize(), nextEvent(), and ~OfflineEventLoopMgr().

◆ m_evtDataSvc

IDataProviderSvc* OfflineEventLoopMgr::m_evtDataSvc
protected

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 48 of file OfflineEventLoopMgr.h.

Referenced by executeEvent(), finalize(), initialize(), nextEvent(), and ~OfflineEventLoopMgr().

◆ m_evtsel

std::string OfflineEventLoopMgr::m_evtsel
protected

Event selector.

Definition at line 54 of file OfflineEventLoopMgr.h.

Referenced by initialize(), and reinitialize().

◆ m_evtSelector

IEvtSelector* OfflineEventLoopMgr::m_evtSelector
protected

Reference to the Event Selector.

Definition at line 50 of file OfflineEventLoopMgr.h.

Referenced by finalize(), getEventRoot(), initialize(), reinitialize(), and ~OfflineEventLoopMgr().

◆ m_histoDataMgrSvc

IDataManagerSvc* OfflineEventLoopMgr::m_histoDataMgrSvc
protected

Reference to the Histogram Data Service.

Definition at line 56 of file OfflineEventLoopMgr.h.

Referenced by finalize(), initialize(), and ~OfflineEventLoopMgr().

◆ m_histoPersSvc

IConversionSvc* OfflineEventLoopMgr::m_histoPersSvc
protected

Reference to the Histogram Persistency Service.

Definition at line 58 of file OfflineEventLoopMgr.h.

Referenced by finalize(), initialize(), and ~OfflineEventLoopMgr().

◆ m_histPersName

std::string OfflineEventLoopMgr::m_histPersName
protected

Name of the Hist Pers type.

Definition at line 60 of file OfflineEventLoopMgr.h.

◆ m_incidentSvc

IIncidentSvc* OfflineEventLoopMgr::m_incidentSvc
protected

Reference to the indicent service.

Definition at line 44 of file OfflineEventLoopMgr.h.

Referenced by executeEvent(), finalize(), initialize(), and ~OfflineEventLoopMgr().


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