| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# EventLoopMgr Class Reference

Class definition of EventLoopMgr. More...

`#include <EventLoopMgr.h>`

Inheritance diagram for EventLoopMgr:
[legend]
Collaboration diagram for EventLoopMgr:
[legend]

List of all members.

## Public Member Functions
| EventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
| Standard Constructor.
virtual | ~EventLoopMgr ()
| Standard Destructor.
StatusCode | getEventRoot (IOpaqueAddress *&refpAddr)
| Create event address using event selector.
virtual StatusCode | initialize ()
| implementation of IService::initialize
virtual StatusCode | reinitialize ()
| implementation of IService::reinitialize
virtual StatusCode | stop ()
| implementation of IService::stop
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
SmartIF< IDataManagerSvc > | m_evtDataMgrSvc
| Reference to the Event Data Service's IDataManagerSvc interface.
SmartIF< IDataProviderSvc > | m_evtDataSvc
| Reference to the Event Data Service's IDataProviderSvc interface.
SmartIF< IEvtSelector > | m_evtSelector
| Reference to the Event Selector.
IEvtSelector::Context * | m_evtContext
| Event Iterator.
std::string | m_evtsel
| Event selector.
SmartIF< IDataManagerSvc > | m_histoDataMgrSvc
| Reference to the Histogram Data Service.
SmartIF< IConversionSvc > | m_histoPersSvc
| Reference to the Histogram Persistency Service.
std::string | m_histPersName
| Name of the Hist Pers type.
SmartIF< IProperty > | m_appMgrProperty
| Property interface of ApplicationMgr.
bool | m_endEventFired
| Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event).
bool | m_warnings
| Flag to disable warning messages when using external input.

## Detailed Description

Class definition of EventLoopMgr.

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 39 of file EventLoopMgr.h.

## Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 26 of file EventLoopMgr.cpp.

    00027 : MinimalEventLoopMgr(nam, svcLoc)
    00028 {
    00029   m_histoDataMgrSvc   = 0;
    00030   m_histoPersSvc      = 0;
    00031   m_evtDataMgrSvc     = 0;
    00032   m_evtDataSvc        = 0;
    00033   m_evtSelector       = 0;
    00034   m_evtContext        = 0;
    00035   m_endEventFired     = true;
    00036
    00037   // Declare properties
    00038   declareProperty("HistogramPersistency", m_histPersName = "");
    00039   declareProperty("EvtSel", m_evtsel );
    00040   declareProperty("Warnings",m_warnings=true,
    00041                   "Set this property to false to suppress warning messages");
    00042 }

EventLoopMgr::~EventLoopMgr | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 47 of file EventLoopMgr.cpp.

    00047                               {
    00048   if( m_histoDataMgrSvc ) m_histoDataMgrSvc->release();
    00049   if( m_histoPersSvc ) m_histoPersSvc->release();
    00050   if( m_evtDataMgrSvc ) m_evtDataMgrSvc->release();
    00051   if( m_evtDataSvc ) m_evtDataSvc->release();
    00052   if( m_evtSelector ) m_evtSelector->release();
    00053   if( m_evtContext ) delete m_evtContext;
    00054 }

## Member Function Documentation

StatusCode EventLoopMgr::getEventRoot | ( | IOpaqueAddress *& | refpAddr | ) |

Create event address using event selector.

Definition at line 396 of file EventLoopMgr.cpp.

    00396                                                                 {
    00397   refpAddr = 0;
    00398   StatusCode sc = m_evtSelector->next(*m_evtContext);
    00399   if ( !sc.isSuccess() )  {
    00400     return sc;
    00401   }
    00402   // Create root address and assign address to data service
    00403   sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
    00404   if( !sc.isSuccess() )  {
    00405     sc = m_evtSelector->next(*m_evtContext);
    00406     if ( sc.isSuccess() )  {
    00407       sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
    00408       if ( !sc.isSuccess() )  {
    00409         MsgStream log( msgSvc(), name() );
    00410         log << MSG::WARNING << "Error creating IOpaqueAddress." << endmsg;
    00411       }
    00412     }
    00413   }
    00414   return sc;
    00415 }

StatusCode EventLoopMgr::initialize | ( |  | ) | `[virtual]`

implementation of IService::initialize

Reimplemented from MinimalEventLoopMgr.

Definition at line 59 of file EventLoopMgr.cpp.

    00059                                        {
    00060   // Initialize the base class
    00061   StatusCode sc = MinimalEventLoopMgr::initialize();
    00062   MsgStream log(msgSvc(), name());
    00063   if( !sc.isSuccess() ) {
    00064     log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
    00065     return sc;
    00066   }
    00067
    00068   // Setup access to event data services
    00069   m_evtDataMgrSvc = serviceLocator()->service("EventDataSvc");
    00070   if( !m_evtDataMgrSvc.isValid() )  {
    00071     log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
    00072     return StatusCode::FAILURE;
    00073   }
    00074   m_evtDataSvc = serviceLocator()->service("EventDataSvc");
    00075   if( !m_evtDataSvc.isValid() )  {
    00076     log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endmsg;
    00077     return StatusCode::FAILURE;
    00078   }
    00079
    00080   // Obtain the IProperty of the ApplicationMgr
    00081   m_appMgrProperty = serviceLocator();
    00082   if ( ! m_appMgrProperty.isValid() )   {
    00083     log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
    00084     return StatusCode::FAILURE;
    00085   }
    00086
    00087   // We do not expect a Event Selector necessarily being declared
    00088   setProperty(m_appMgrProperty->getProperty("EvtSel")).ignore();
    00089
    00090   if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
    00091     m_evtSelector = serviceLocator()->service("EventSelector");
    00092     if( m_evtSelector.isValid() ) {
    00093       // Setup Event Selector
    00094       sc=m_evtSelector->createContext(m_evtContext);
    00095       if( !sc.isSuccess() )   {
    00096         log << MSG::FATAL << "Can not create the event selector Context." << endmsg;
    00097         return sc;
    00098       }
    00099     }
    00100     else {
    00101       log << MSG::FATAL << "EventSelector not found." << endmsg;
    00102       return sc;
    00103     }
    00104   }
    00105   else {
    00106     m_evtSelector = 0;
    00107     m_evtContext = 0;
    00108     if ( m_warnings ) {
    00109       log << MSG::WARNING << "Unable to locate service \"EventSelector\" " << endmsg;
    00110       log << MSG::WARNING << "No events will be processed from external input." << endmsg;
    00111     }
    00112   }
    00113
    00114   // Setup access to histogramming services
    00115   m_histoDataMgrSvc = serviceLocator()->service("HistogramDataSvc");
    00116   if( !m_histoDataMgrSvc.isValid() )  {
    00117     log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endmsg;
    00118     return sc;
    00119   }
    00120   // Setup histogram persistency
    00121   m_histoPersSvc = serviceLocator()->service("HistogramPersistencySvc");
    00122   if( !m_histoPersSvc.isValid() ) {
    00123     log << MSG::WARNING << "Histograms cannot not be saved - though required." << endmsg;
    00124     return sc;
    00125   }
    00126
    00127   return StatusCode::SUCCESS;
    00128 }

StatusCode EventLoopMgr::reinitialize | ( |  | ) | `[virtual]`

implementation of IService::reinitialize

Reimplemented from MinimalEventLoopMgr.

Definition at line 132 of file EventLoopMgr.cpp.

    00132                                       {
    00133   MsgStream log(msgSvc(), name());
    00134
    00135   // Initialize the base class
    00136   StatusCode sc = MinimalEventLoopMgr::reinitialize();
    00137   if( !sc.isSuccess() ) {
    00138     log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
    00139     return sc;
    00140   }
    00141
    00142   // Check to see whether a new Event Selector has been specified
    00143   setProperty(m_appMgrProperty->getProperty("EvtSel"));
    00144   if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
    00145     SmartIF<IService> theSvc(serviceLocator()->service("EventSelector"));
    00146     SmartIF<IEvtSelector> theEvtSel(theSvc);
    00147     if( theEvtSel.isValid() && ( theEvtSel.get() != m_evtSelector.get() ) ) {
    00148       // Setup Event Selector
    00149       if ( m_evtSelector.get() && m_evtContext ) {
    00150         // Need to release context before switching to new event selector
    00151         m_evtSelector->releaseContext(m_evtContext);
    00152         m_evtContext = 0;
    00153       }
    00154       m_evtSelector = theEvtSel;
    00155       if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
    00156         sc = theSvc->reinitialize();
    00157         if( !sc.isSuccess() ) {
    00158           log << MSG::ERROR << "Failure Reinitializing EventSelector "
    00159               << theSvc->name( ) << endmsg;
    00160           return sc;
    00161         }
    00162       }
    00163       else {
    00164         sc = theSvc->sysInitialize();
    00165         if( !sc.isSuccess() ) {
    00166           log << MSG::ERROR << "Failure Initializing EventSelector "
    00167               << theSvc->name( ) << endmsg;
    00168           return sc;
    00169         }
    00170       }
    00171       sc = m_evtSelector->createContext(m_evtContext);
    00172       if( !sc.isSuccess() ) {
    00173         log << MSG::ERROR << "Can not create Context "
    00174             << theSvc->name( ) << endmsg;
    00175         return sc;
    00176       }
    00177       log << MSG::INFO << "EventSelector service changed to "
    00178           << theSvc->name( ) << endmsg;
    00179     }
    00180     else if ( m_evtSelector.isValid() ) {
    00181       if ( m_evtContext ) {
    00182         m_evtSelector->releaseContext(m_evtContext);
    00183         m_evtContext = 0;
    00184       }
    00185       sc = m_evtSelector->createContext(m_evtContext);
    00186       if( !sc.isSuccess() ) {
    00187         log << MSG::ERROR << "Can not create Context "
    00188             << theSvc->name( ) << endmsg;
    00189         return sc;
    00190       }
    00191     }
    00192   }
    00193   else if ( m_evtSelector.isValid() && m_evtContext ) {
    00194     m_evtSelector->releaseContext(m_evtContext);
    00195     m_evtSelector = 0;
    00196     m_evtContext = 0;
    00197   }
    00198   return StatusCode::SUCCESS;
    00199 }

StatusCode EventLoopMgr::stop | ( |  | ) | `[virtual]`

implementation of IService::stop

Reimplemented from MinimalEventLoopMgr.

Definition at line 205 of file EventLoopMgr.cpp.

    00205                                  {
    00206   if ( ! m_endEventFired ) {
    00207     // Fire pending EndEvent incident
    00208     m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
    00209     m_endEventFired = true;
    00210   }
    00211   return MinimalEventLoopMgr::stop();
    00212 }

StatusCode EventLoopMgr::finalize | ( |  | ) | `[virtual]`

implementation of IService::finalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 217 of file EventLoopMgr.cpp.

    00217                                      {
    00218   StatusCode sc;
    00219   MsgStream log(msgSvc(), name());
    00220
    00221   // Finalize base class
    00222   sc = MinimalEventLoopMgr::finalize();
    00223   if (! sc.isSuccess()) {
    00224     log << MSG::ERROR << "Error finalizing base class" << endmsg;
    00225     return sc;
    00226   }
    00227
    00228   // Save Histograms Now
    00229   if ( m_histoPersSvc != 0 )    {
    00230     HistogramAgent agent;
    00231     sc = m_histoDataMgrSvc->traverseTree( &agent );
    00232     if( sc.isSuccess() )   {
    00233       IDataSelector* objects = agent.selectedObjects();
    00234       // skip /stat entry!
    00235       if ( objects->size() > 0 )    {
    00236         IDataSelector::iterator i;
    00237         for ( i = objects->begin(); i != objects->end(); i++ )    {
    00238           IOpaqueAddress* pAddr = 0;
    00239           StatusCode iret = m_histoPersSvc->createRep(*i, pAddr);
    00240           if ( iret.isSuccess() )     {
    00241             (*i)->registry()->setAddress(pAddr);
    00242           }
    00243           else  {
    00244             sc = iret;
    00245           }
    00246         }
    00247         for ( i = objects->begin(); i != objects->end(); i++ )    {
    00248           IRegistry* reg = (*i)->registry();
    00249           StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), *i);
    00250           if ( !iret.isSuccess() )    {
    00251             sc = iret;
    00252           }
    00253         }
    00254       }
    00255       if ( sc.isSuccess() )    {
    00256         log << MSG::INFO << "Histograms converted successfully according to request." << endmsg;
    00257       }
    00258       else  {
    00259         log << MSG::ERROR << "Error while saving Histograms." << endmsg;
    00260       }
    00261     }
    00262     else {
    00263       log << MSG::ERROR << "Error while traversing Histogram data store" << endmsg;
    00264     }
    00265   }
    00266
    00267   // Release event selector context
    00268   if ( m_evtSelector && m_evtContext )   {
    00269     m_evtSelector->releaseContext(m_evtContext).ignore();
    00270     m_evtContext = 0;
    00271   }
    00272
    00273   // Release all interfaces...
    00274   m_histoDataMgrSvc = 0;
    00275   m_histoPersSvc    = 0;
    00276
    00277   m_evtSelector     = 0;
    00278   m_evtDataSvc      = 0;
    00279   m_evtDataMgrSvc   = 0;
    00280
    00281   return StatusCode::SUCCESS;
    00282 }

StatusCode EventLoopMgr::nextEvent | ( | int | maxevt | ) | `[virtual]`

implementation of IService::nextEvent

Reimplemented from MinimalEventLoopMgr.

Definition at line 323 of file EventLoopMgr.cpp.

    00323                                                {
    00324   static int        total_nevt = 0;
    00325   DataObject*       pObject = 0;
    00326   StatusCode        sc(StatusCode::SUCCESS, true);
    00327   MsgStream         log( msgSvc(), name() );
    00328
    00329   // Reset the application return code.
    00330   Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::Success, true).ignore();
    00331
    00332   // loop over events if the maxevt (received as input) if different from -1.
    00333   // if evtmax is -1 it means infinite loop
    00334   for( int nevt = 0; (maxevt == -1 ? true : nevt < maxevt);  nevt++, total_nevt++) {
    00335
    00336     // Check if there is a scheduled stop issued by some algorithm/service
    00337     if ( m_scheduledStop ) {
    00338       m_scheduledStop = false;
    00339       log << MSG::ALWAYS << "Terminating event processing loop due to scheduled stop" << endmsg;
    00340       break;
    00341     }
    00342     // Clear the event store, if used in the event loop
    00343     if( 0 != total_nevt ) {
    00344
    00345       if ( ! m_endEventFired ) {
    00346         // Fire EndEvent "Incident" (it is considered part of the clearing of the TS)
    00347         m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
    00348         m_endEventFired = true;
    00349       }
    00350       sc = m_evtDataMgrSvc->clearStore();
    00351       if( !sc.isSuccess() )  {
    00352         log << MSG::DEBUG << "Clear of Event data store failed" << endmsg;
    00353       }
    00354     }
    00355
    00356     // Setup event in the event store
    00357     if( m_evtContext ) {
    00358       IOpaqueAddress* addr = 0;
    00359       // Only if there is a EventSelector
    00360       sc = getEventRoot(addr);
    00361       if( !sc.isSuccess() )  {
    00362         log << MSG::INFO << "No more events in event selection " << endmsg;
    00363         break;
    00364       }
    00365       // Set root clears the event data store first
    00366       sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
    00367       if( !sc.isSuccess() )  {
    00368         log << MSG::WARNING << "Error declaring event root address." << endmsg;
    00369         continue;
    00370       }
    00371       sc = m_evtDataSvc->retrieveObject("/Event", pObject);
    00372       if( !sc.isSuccess() ) {
    00373         log << MSG::WARNING << "Unable to retrieve Event root object" << endmsg;
    00374         break;
    00375       }
    00376     }
    00377     else {
    00378       sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
    00379       if( !sc.isSuccess() )  {
    00380         log << MSG::WARNING << "Error declaring event root DataObject" << endmsg;
    00381       }
    00382     }
    00383     // Execute event for all required algorithms
    00384     sc = executeEvent(NULL);
    00385     m_endEventFired = false;
    00386     if( !sc.isSuccess() ){
    00387       log << MSG::ERROR << "Terminating event processing loop due to errors" << endmsg;
    00388       Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::AlgorithmFailure).ignore();
    00389       return sc;
    00390     }
    00391   }
    00392   return StatusCode::SUCCESS;
    00393 }

StatusCode EventLoopMgr::executeEvent | ( | void * | par | ) | `[virtual]`

implementation of IEventProcessor::executeEvent(void* par)

Reimplemented from MinimalEventLoopMgr.

Definition at line 288 of file EventLoopMgr.cpp.

    00288                                                   {
    00289
    00290   // Fire BeginEvent "Incident"
    00291   m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent));
    00292   // An incident may schedule a stop, in which case is better to exit before the actual execution.
    00293   if ( m_scheduledStop ) {
    00294     MsgStream  log( msgSvc(), name() );
    00295     log << MSG::ALWAYS << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
    00296     return StatusCode::SUCCESS;
    00297   }
    00298
    00299   // Execute Algorithms
    00300   StatusCode sc = MinimalEventLoopMgr::executeEvent(par);
    00301
    00302   // Check if there was an error processing current event
    00303   if( !sc.isSuccess() ){
    00304     MsgStream log( msgSvc(), name() );
    00305     log << MSG::ERROR << "Terminating event processing loop due to errors" << endmsg;
    00306   }
    00307   return sc;
    00308 }

StatusCode EventLoopMgr::executeRun | ( | int | maxevt | ) | `[virtual]`

implementation of IEventProcessor::executeRun()

Reimplemented from MinimalEventLoopMgr.

Definition at line 313 of file EventLoopMgr.cpp.

    00313                                                    {
    00314   StatusCode  sc;
    00315   // initialize the base class
    00316   sc = MinimalEventLoopMgr::executeRun(maxevt);
    00317   return sc;
    00318 }

## Member Data Documentation

SmartIF<IDataManagerSvc> EventLoopMgr::m_evtDataMgrSvc`[protected]`

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 44 of file EventLoopMgr.h.

SmartIF<IDataProviderSvc> EventLoopMgr::m_evtDataSvc`[protected]`

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 46 of file EventLoopMgr.h.

SmartIF<IEvtSelector> EventLoopMgr::m_evtSelector`[protected]`

Reference to the Event Selector.

Definition at line 48 of file EventLoopMgr.h.

IEvtSelector::Context* EventLoopMgr::m_evtContext`[protected]`

Event Iterator.

Definition at line 50 of file EventLoopMgr.h.

std::string EventLoopMgr::m_evtsel`[protected]`

Event selector.

Definition at line 52 of file EventLoopMgr.h.

SmartIF<IDataManagerSvc> EventLoopMgr::m_histoDataMgrSvc`[protected]`

Reference to the Histogram Data Service.

Definition at line 54 of file EventLoopMgr.h.

SmartIF<IConversionSvc> EventLoopMgr::m_histoPersSvc`[protected]`

Reference to the Histogram Persistency Service.

Definition at line 56 of file EventLoopMgr.h.

std::string EventLoopMgr::m_histPersName`[protected]`

Name of the Hist Pers type.

Definition at line 58 of file EventLoopMgr.h.

SmartIF<IProperty> EventLoopMgr::m_appMgrProperty`[protected]`

Property interface of ApplicationMgr.

Definition at line 60 of file EventLoopMgr.h.

bool EventLoopMgr::m_endEventFired`[protected]`

Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event).

Definition at line 63 of file EventLoopMgr.h.

bool EventLoopMgr::m_warnings`[protected]`

Flag to disable warning messages when using external input.

Definition at line 65 of file EventLoopMgr.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiSvc/src/ApplicationMgr/EventLoopMgr.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiSvc/src/ApplicationMgr/EventLoopMgr.cpp