#include <OfflineEventLoopMgr.h>
Public Member Functions | |
virtual StatusCode | executeEvent (void *par) |
implementation of IEventProcessor::executeEvent(void* par) | |
virtual StatusCode | executeEvent (void *par) |
implementation of IEventProcessor::executeEvent(void* par) | |
virtual StatusCode | executeRun (int maxevt) |
implementation of IEventProcessor::executeRun() | |
virtual StatusCode | executeRun (int maxevt) |
implementation of IEventProcessor::executeRun() | |
virtual StatusCode | finalize () |
implementation of IService::finalize | |
virtual StatusCode | finalize () |
implementation of IService::finalize | |
virtual StatusCode | initialize () |
implementation of IService::initalize | |
virtual StatusCode | initialize () |
implementation of IService::initalize | |
virtual StatusCode | nextEvent (int maxevt) |
implementation of IService::nextEvent | |
virtual StatusCode | nextEvent (int maxevt) |
implementation of IService::nextEvent | |
virtual StatusCode | reinitialize () |
implementation of IService::reinitalize | |
virtual StatusCode | reinitialize () |
implementation of IService::reinitalize | |
Protected Member Functions | |
StatusCode | getEventRoot (IOpaqueAddress *&refpAddr) |
Create event address using event selector. | |
StatusCode | getEventRoot (IOpaqueAddress *&refpAddr) |
Create event address using event selector. | |
OfflineEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc) | |
Standard Constructor. | |
OfflineEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc) | |
Standard Constructor. | |
virtual | ~OfflineEventLoopMgr () |
Standard Destructor. | |
virtual | ~OfflineEventLoopMgr () |
Standard Destructor. | |
Protected Attributes | |
IProperty * | m_appMgrProperty |
Property interface of ApplicationMgr. | |
IProperty * | m_appMgrProperty |
Property interface of ApplicationMgr. | |
IEvtSelector::Context * | m_evtContext |
Event Iterator. | |
IEvtSelector::Context * | m_evtContext |
Event Iterator. | |
IDataManagerSvc * | m_evtDataMgrSvc |
Reference to the Event Data Service's IDataManagerSvc interface. | |
IDataManagerSvc * | m_evtDataMgrSvc |
Reference to the Event Data Service's IDataManagerSvc interface. | |
IDataProviderSvc * | m_evtDataSvc |
Reference to the Event Data Service's IDataProviderSvc interface. | |
IDataProviderSvc * | m_evtDataSvc |
Reference to the Event Data Service's IDataProviderSvc interface. | |
std::string | m_evtsel |
Event selector. | |
IEvtSelector * | m_evtSelector |
Reference to the Event Selector. | |
IEvtSelector * | m_evtSelector |
Reference to the Event Selector. | |
IDataManagerSvc * | m_histoDataMgrSvc |
Reference to the Histogram Data Service. | |
IDataManagerSvc * | m_histoDataMgrSvc |
Reference to the Histogram Data Service. | |
IConversionSvc * | m_histoPersSvc |
Reference to the Histogram Persistency Service. | |
IConversionSvc * | m_histoPersSvc |
Reference to the Histogram Persistency Service. | |
std::string | m_histPersName |
Name of the Hist Pers type. | |
IIncidentSvc * | m_incidentSvc |
Reference to the indicent service. | |
IIncidentSvc * | m_incidentSvc |
Reference to the indicent service. | |
Private Attributes | |
double | m_runNo |
Friends | |
class | SvcFactory<OfflineEventLoopMgr> |
Creator friend class. |
History:
+---------+----------------------------------------------+---------+ | Date | Comment | Who | +---------+----------------------------------------------+---------+ |13/12/00 | Initial version | M.Frank | +---------+----------------------------------------------+---------+
|
Standard Constructor.
00031 : MinimalEventLoopMgr(nam, svcLoc) 00032 { 00033 m_histoDataMgrSvc = 0; 00034 m_histoPersSvc = 0; 00035 m_incidentSvc = 0; 00036 m_evtDataMgrSvc = 0; 00037 m_evtDataSvc = 0; 00038 m_evtSelector = 0; 00039 m_evtContext = 0; 00040 m_runNo = -1.1; 00041 // Declare properties 00042 declareProperty("HistogramPersistency", m_histPersName = ""); 00043 declareProperty( "EvtSel", m_evtsel ); 00044 }
|
|
Standard Destructor.
00049 { 00050 if( m_histoDataMgrSvc ) m_histoDataMgrSvc->release(); 00051 if( m_histoPersSvc ) m_histoPersSvc->release(); 00052 if( m_incidentSvc ) m_incidentSvc->release(); 00053 if( m_evtDataMgrSvc ) m_evtDataMgrSvc->release(); 00054 if( m_evtDataSvc ) m_evtDataSvc->release(); 00055 if( m_evtSelector ) m_evtSelector->release(); 00056 if( m_evtContext ) delete m_evtContext; 00057 }
|
|
Standard Constructor.
|
|
Standard Destructor.
|
|
implementation of IEventProcessor::executeEvent(void* par)
|
|
implementation of IEventProcessor::executeEvent(void* par)
00279 { 00280 MsgStream log(msgSvc(), name()); 00281 // Fire BeginEvent "Incident" 00282 m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent)); 00283 int runNo; 00284 SmartDataPtr<Event::EventHeader> evt(m_evtDataSvc,"/Event/EventHeader"); 00285 if( evt ){ 00286 runNo = evt -> runNumber(); 00287 log << MSG::INFO <<"The runNumber of current event is "<<runNo<<endreq; 00288 } 00289 00290 else{ 00291 log << MSG::ERROR << "Error accessing Event" <<endreq; 00292 return StatusCode::FAILURE; 00293 } 00294 if(runNo!=m_runNo) { 00295 log << MSG::INFO <<"fireIncident of begin run"<<endreq; 00296 m_incidentSvc->fireIncident(Incident(name(),"NewRun")); 00297 if(m_runNo==-1.1){ 00298 ListAlg::iterator it_topAlg = m_topAlgList.begin(); 00299 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){ 00300 (*it_topAlg)->beginRun();} 00301 } 00302 m_runNo = runNo; 00303 } 00304 00305 // Execute Algorithms 00306 StatusCode sc = MinimalEventLoopMgr::executeEvent(par); 00307 // Fire EndEvent "Incident" 00308 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent)); 00309 00310 // Check if there was an error processing current event 00311 if( !sc.isSuccess() ){ 00312 MsgStream log( msgSvc(), name() ); 00313 log << MSG::ERROR << "Terminating event processing loop due to errors" << endreq; 00314 } 00315 00316 return sc; 00317 }
|
|
implementation of IEventProcessor::executeRun()
|
|
implementation of IEventProcessor::executeRun()
00322 { 00323 StatusCode sc; 00324 // initialize the base class 00325 sc = MinimalEventLoopMgr::executeRun(maxevt); 00326 return sc; 00327 }
|
|
implementation of IService::finalize
|
|
implementation of IService::finalize
00211 { 00212 StatusCode sc; 00213 MsgStream log(msgSvc(), name()); 00214 00215 // Finalize base class 00216 MinimalEventLoopMgr::finalize(); 00217 00218 // Save Histograms Now 00219 if ( 0 != m_histoPersSvc ) { 00220 HistogramAgent agent; 00221 sc = m_histoDataMgrSvc->traverseTree( &agent ); 00222 if( sc.isSuccess() ) { 00223 IDataSelector* objects = agent.selectedObjects(); 00224 // skip /stat entry! 00225 if ( objects->size() > 0 ) { 00226 IDataSelector::iterator i; 00227 for ( i = objects->begin(); i != objects->end(); i++ ) { 00228 IOpaqueAddress* pAddr = 0; 00229 StatusCode iret = m_histoPersSvc->createRep(*i, pAddr); 00230 if ( iret.isSuccess() ) { 00231 (*i)->registry()->setAddress(pAddr); 00232 } 00233 else { 00234 sc = iret; 00235 } 00236 } 00237 for ( i = objects->begin(); i != objects->end(); i++ ) { 00238 IRegistry* reg = (*i)->registry(); 00239 StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), *i); 00240 if ( !iret.isSuccess() ) { 00241 sc = iret; 00242 } 00243 } 00244 } 00245 if ( sc.isSuccess() ) { 00246 log << MSG::INFO << "Histograms converted successfully according to request." << endreq; 00247 } 00248 else { 00249 log << MSG::ERROR << "Error while saving Histograms." << endreq; 00250 } 00251 } 00252 else { 00253 log << MSG::ERROR << "Error while traversing Histogram data store" << endreq; 00254 } 00255 } 00256 00257 // Release evemt selector context 00258 if ( m_evtSelector && m_evtContext ) { 00259 m_evtSelector->releaseContext(m_evtContext); 00260 m_evtContext = 0; 00261 } 00262 00263 // Release all interfaces... 00264 m_histoDataMgrSvc = releaseInterface(m_histoDataMgrSvc); 00265 m_histoPersSvc = releaseInterface(m_histoPersSvc); 00266 00267 m_evtSelector = releaseInterface(m_evtSelector); 00268 m_incidentSvc = releaseInterface(m_incidentSvc); 00269 m_evtDataSvc = releaseInterface(m_evtDataSvc); 00270 m_evtDataMgrSvc = releaseInterface(m_evtDataMgrSvc); 00271 00272 return StatusCode::SUCCESS; 00273 }
|
|
Create event address using event selector.
|
|
Create event address using event selector.
00418 { 00419 refpAddr = 0; 00420 StatusCode sc = m_evtSelector->next(*m_evtContext); 00421 if ( !sc.isSuccess() ) { 00422 return sc; 00423 } 00424 // Create root address and assign address to data service 00425 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr); 00426 if( !sc.isSuccess() ) { 00427 sc = m_evtSelector->next(*m_evtContext); 00428 if ( sc.isSuccess() ) { 00429 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr); 00430 if ( !sc.isSuccess() ) { 00431 MsgStream log( msgSvc(), name() ); 00432 log << MSG::WARNING << "Error creating IOpaqueAddress." << endreq; 00433 } 00434 } 00435 } 00436 return sc; 00437 }
|
|
implementation of IService::initalize
|
|
implementation of IService::initalize
00062 { 00063 MsgStream log(msgSvc(), name()); 00064 00065 // initilaize the base class 00066 StatusCode sc = MinimalEventLoopMgr::initialize(); 00067 if( !sc.isSuccess() ) { 00068 log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endreq; 00069 return sc; 00070 } 00071 00072 // Setup access to event data services 00073 sc = serviceLocator()->service("EventDataSvc", m_evtDataMgrSvc, true); 00074 if( !sc.isSuccess() ) { 00075 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endreq; 00076 return sc; 00077 } 00078 sc = serviceLocator()->service("EventDataSvc", m_evtDataSvc, true); 00079 if( !sc.isSuccess() ) { 00080 log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endreq; 00081 return sc; 00082 } 00083 00084 // Get the references to the services that are needed by the ApplicationMgr itself 00085 sc = serviceLocator()->service("IncidentSvc", m_incidentSvc, true); 00086 if( !sc.isSuccess() ) { 00087 log << MSG::FATAL << "Error retrieving IncidentSvc." << endreq; 00088 return sc; 00089 } 00090 00091 // Obtain the IProperty of the ApplicationMgr 00092 SmartIF<IProperty> prpMgr(IID_IProperty, serviceLocator()); 00093 if ( ! prpMgr.isValid() ) { 00094 log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endreq; 00095 return StatusCode::FAILURE; 00096 } 00097 else { 00098 m_appMgrProperty = prpMgr; 00099 } 00100 00101 // We do not expect a Event Selector necessarily being declared 00102 setProperty(m_appMgrProperty->getProperty("EvtSel")); 00103 00104 if( m_evtsel != "NONE" || m_evtsel.length() == 0) { 00105 sc = serviceLocator()->service( "EventSelector", m_evtSelector, true ); 00106 if( sc.isSuccess() ) { 00107 // Setup Event Selector 00108 sc=m_evtSelector->createContext(m_evtContext); 00109 if( !sc.isSuccess() ) { 00110 log << MSG::FATAL << "Can not create the event selector Context." << endreq; 00111 return sc; 00112 } 00113 } 00114 else { 00115 log << MSG::FATAL << "EventSelector not found." << endreq; 00116 return sc; 00117 } 00118 } 00119 else { 00120 m_evtSelector = 0; 00121 m_evtContext = 0; 00122 log << MSG::WARNING << "Unable to locate service \"EventSelector\" " << endreq; 00123 log << MSG::WARNING << "No events will be processed from external input." << endreq; 00124 } 00125 00126 // Setup access to histogramming services 00127 sc = serviceLocator()->service("HistogramDataSvc", m_histoDataMgrSvc, true); 00128 if( !sc.isSuccess() ) { 00129 log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endreq; 00130 return sc; 00131 } 00132 // Setup histogram persistency 00133 sc = serviceLocator()->service("HistogramPersistencySvc", m_histoPersSvc, true ); 00134 if( !sc.isSuccess() ) { 00135 log << MSG::WARNING << "Histograms cannot not be saved - though required." << endreq; 00136 return sc; 00137 } 00138 00139 return StatusCode::SUCCESS; 00140 }
|
|
implementation of IService::nextEvent
|
|
implementation of IService::nextEvent
00332 { 00333 static int total_nevt = 0; 00334 DataObject* pObject = 0; 00335 StatusCode sc; 00336 MsgStream log( msgSvc(), name() ); 00337 00338 //yzhang add 00339 //begin run 00340 /* ListAlg::iterator it_topAlg = m_topAlgList.begin(); 00341 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){ 00342 (*it_topAlg)->beginRun(); 00343 }*/ 00344 //zhangy add 00345 // loop over events if the maxevt (received as input) if different from -1. 00346 // if evtmax is -1 it means infinite loop 00347 for( int nevt = 0; (maxevt == -1 ? true : nevt < maxevt); nevt++, total_nevt++) { 00348 // Check if there is a scheduled stop issued by some algorithm/sevice 00349 if ( m_scheduledStop ) { 00350 m_scheduledStop = false; 00351 log << MSG::ALWAYS << "Terminating event processing loop due to scheduled stop" << endreq; 00352 break; 00353 } 00354 // Clear the event store, if used in the event loop 00355 if( 0 != total_nevt ) { 00356 sc = m_evtDataMgrSvc->clearStore(); 00357 if( !sc.isSuccess() ) { 00358 log << MSG::DEBUG << "Clear of Event data store failed" << endreq; 00359 } 00360 } 00361 00362 // Setup event in the event store 00363 if( m_evtContext ) { 00364 IOpaqueAddress* addr = 0; 00365 // Only if there is a EventSelector 00366 sc = getEventRoot(addr); 00367 if( !sc.isSuccess() ) { 00368 log << MSG::INFO << "No more events in event selection " << endreq; 00369 break; 00370 } 00371 // Set root clears the event data store first 00372 sc = m_evtDataMgrSvc->setRoot ("/Event", addr); 00373 if( !sc.isSuccess() ) { 00374 log << MSG::WARNING << "Error declaring event root address." << endreq; 00375 continue; 00376 } 00377 // register event header for mc 00378 SmartDataPtr<Event::EventHeader> evt(m_evtDataSvc,"/Event/EventHeader"); 00379 if(!evt) { 00380 sc = m_evtDataMgrSvc->registerAddress ("/Event/EventHeader", addr); 00381 if( !sc.isSuccess() ) { 00382 log << MSG::WARNING << "Error register EventHeader address." << endreq; 00383 } 00384 } 00385 sc = m_evtDataSvc->retrieveObject("/Event", pObject); 00386 if( !sc.isSuccess() ) { 00387 log << MSG::WARNING << "Unable to retrieve Event root object" << endreq; 00388 break; 00389 } 00390 } 00391 else { 00392 sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject()); 00393 if( !sc.isSuccess() ) { 00394 log << MSG::WARNING << "Error declaring event root DataObject" << endreq; 00395 } 00396 } 00397 00398 00399 00400 // Execute event for all required algorithms 00401 sc = executeEvent(NULL); 00402 if( !sc.isSuccess() ){ 00403 log << MSG::ERROR << "Terminating event processing loop due to errors" << endreq; 00404 break; 00405 } 00406 } 00407 //yzhang add 00408 //end run 00409 ListAlg::iterator it_topAlg = m_topAlgList.begin(); 00410 for (;it_topAlg!=m_topAlgList.end();it_topAlg++){ 00411 (*it_topAlg)->endRun(); 00412 } 00413 //zhangy add 00414 return StatusCode::SUCCESS; 00415 }
|
|
implementation of IService::reinitalize
|
|
implementation of IService::reinitalize
00144 { 00145 MsgStream log(msgSvc(), name()); 00146 00147 // initilaize the base class 00148 StatusCode sc = MinimalEventLoopMgr::reinitialize(); 00149 if( !sc.isSuccess() ) { 00150 log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endreq; 00151 return sc; 00152 } 00153 00154 // Check to see whether a new Event Selector has been specified 00155 setProperty(m_appMgrProperty->getProperty("EvtSel")); 00156 if( m_evtsel != "NONE" || m_evtsel.length() == 0) { 00157 IEvtSelector* theEvtSel; 00158 IService* theSvc; 00159 sc = serviceLocator()->service( "EventSelector", theEvtSel ); 00160 sc = serviceLocator()->service( "EventSelector", theSvc ); 00161 if( sc.isSuccess() && ( theEvtSel != m_evtSelector ) ) { 00162 // Setup Event Selector 00163 m_evtSelector = theEvtSel; 00164 if (theSvc->state() == IService::INITIALIZED) { 00165 sc = theSvc->reinitialize(); 00166 if( !sc.isSuccess() ) { 00167 log << MSG::ERROR << "Failure Reinitializing EventSelector " 00168 << theSvc->name( ) << endreq; 00169 return sc; 00170 } 00171 } 00172 else { 00173 sc = theSvc->initialize(); 00174 if( !sc.isSuccess() ) { 00175 log << MSG::ERROR << "Failure Initializing EventSelector " 00176 << theSvc->name( ) << endreq; 00177 return sc; 00178 } 00179 } 00180 sc = m_evtSelector->createContext(m_evtContext); 00181 if( !sc.isSuccess() ) { 00182 log << MSG::ERROR << "Can not create Context " 00183 << theSvc->name( ) << endreq; 00184 return sc; 00185 } 00186 log << MSG::INFO << "EventSelector service changed to " 00187 << theSvc->name( ) << endreq; 00188 } 00189 else if ( m_evtSelector && m_evtContext ) { 00190 m_evtSelector->releaseContext(m_evtContext); 00191 m_evtContext = 0; 00192 sc = m_evtSelector->createContext(m_evtContext); 00193 if( !sc.isSuccess() ) { 00194 log << MSG::ERROR << "Can not create Context " 00195 << theSvc->name( ) << endreq; 00196 return sc; 00197 } 00198 } 00199 } 00200 else if ( m_evtSelector && m_evtContext ) { 00201 m_evtSelector->releaseContext(m_evtContext); 00202 m_evtSelector = 0; 00203 m_evtContext = 0; 00204 } 00205 return StatusCode::SUCCESS; 00206 }
|
|
Creator friend class.
|
|
Property interface of ApplicationMgr.
|
|
Property interface of ApplicationMgr.
|
|
Event Iterator.
|
|
Event Iterator.
|
|
Reference to the Event Data Service's IDataManagerSvc interface.
|
|
Reference to the Event Data Service's IDataManagerSvc interface.
|
|
Reference to the Event Data Service's IDataProviderSvc interface.
|
|
Reference to the Event Data Service's IDataProviderSvc interface.
|
|
Event selector.
|
|
Reference to the Event Selector.
|
|
Reference to the Event Selector.
|
|
Reference to the Histogram Data Service.
|
|
Reference to the Histogram Data Service.
|
|
Reference to the Histogram Persistency Service.
|
|
Reference to the Histogram Persistency Service.
|
|
Name of the Hist Pers type.
|
|
Reference to the indicent service.
|
|
Reference to the indicent service.
|
|
|