| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# EventLoopMgr Class Reference

`#include <EventLoopMgr.h>`

Inheritance diagram for EventLoopMgr:

[legend]
Collaboration diagram for EventLoopMgr:

[legend]

List of all members.

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

## 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::initalize
virtual StatusCode | reinitialize ()
| implementation of IService::reinitalize
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
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.
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.

## Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 24 of file EventLoopMgr.cpp.

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

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

Standard Destructor.

Definition at line 45 of file EventLoopMgr.cpp.

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

## Member Function Documentation

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

Create event address using event selector.

Definition at line 386 of file EventLoopMgr.cpp.

    00386                                                                 {
    00387   refpAddr = 0;
    00388   StatusCode sc = m_evtSelector->next(*m_evtContext);
    00389   if ( !sc.isSuccess() )  {
    00390     return sc;
    00391   }
    00392   // Create root address and assign address to data service
    00393   sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
    00394   if( !sc.isSuccess() )  {
    00395     sc = m_evtSelector->next(*m_evtContext);
    00396     if ( sc.isSuccess() )  {
    00397       sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
    00398       if ( !sc.isSuccess() )  {
    00399         MsgStream log( msgSvc(), name() );
    00400         log << MSG::WARNING << "Error creating IOpaqueAddress." << endreq;
    00401       }
    00402     }
    00403   }
    00404   return sc;
    00405 }

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

implementation of IService::initalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 57 of file EventLoopMgr.cpp.

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

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

implementation of IService::reinitalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 132 of file EventLoopMgr.cpp.

    00132                                       {
    00133   MsgStream log(msgSvc(), name());
    00134
    00135   // initilaize the base class
    00136   StatusCode sc = MinimalEventLoopMgr::reinitialize();
    00137   if( !sc.isSuccess() ) {
    00138     log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endreq;
    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     IEvtSelector* theEvtSel;
    00146     IService*     theSvc;
    00147     sc = serviceLocator()->service( "EventSelector", theEvtSel );
    00148     sc = serviceLocator()->service( "EventSelector", theSvc );
    00149     if( sc.isSuccess() && ( theEvtSel != m_evtSelector ) ) {
    00150       // Setup Event Selector
    00151       m_evtSelector = theEvtSel;
    00152       if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
    00153         sc = theSvc->reinitialize();
    00154         if( !sc.isSuccess() ) {
    00155           log << MSG::ERROR << "Failure Reinitializing EventSelector "
    00156               << theSvc->name( ) << endreq;
    00157           return sc;
    00158         }
    00159       }
    00160       else {
    00161         sc = theSvc->sysInitialize();
    00162         if( !sc.isSuccess() ) {
    00163           log << MSG::ERROR << "Failure Initializing EventSelector "
    00164               << theSvc->name( ) << endreq;
    00165           return sc;
    00166         }
    00167       }
    00168       sc = m_evtSelector->createContext(m_evtContext);
    00169       if( !sc.isSuccess() ) {
    00170         log << MSG::ERROR << "Can not create Context "
    00171             << theSvc->name( ) << endreq;
    00172         return sc;
    00173       }
    00174       log << MSG::INFO << "EventSelector service changed to "
    00175           << theSvc->name( ) << endreq;
    00176     }
    00177     else if ( m_evtSelector && m_evtContext )   {
    00178       m_evtSelector->releaseContext(m_evtContext);
    00179       m_evtContext = 0;
    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     }
    00187   }
    00188   else if ( m_evtSelector && m_evtContext )   {
    00189     m_evtSelector->releaseContext(m_evtContext);
    00190     m_evtSelector = 0;
    00191     m_evtContext = 0;
    00192   }
    00193   return StatusCode::SUCCESS;
    00194 }

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

implementation of IService::stop

Reimplemented from MinimalEventLoopMgr.

Definition at line 200 of file EventLoopMgr.cpp.

    00200                                  {
    00201   if ( ! m_endEventFired ) {
    00202     // Fire pending EndEvent incident
    00203     m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
    00204     m_endEventFired = true;
    00205   }
    00206   return MinimalEventLoopMgr::stop();
    00207 }

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

implementation of IService::finalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 212 of file EventLoopMgr.cpp.

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

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

implementation of IService::nextEvent

Reimplemented from MinimalEventLoopMgr.

Definition at line 318 of file EventLoopMgr.cpp.

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

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

implementation of IEventProcessor::executeEvent(void* par)

Reimplemented from MinimalEventLoopMgr.

Definition at line 283 of file EventLoopMgr.cpp.

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

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

implementation of IEventProcessor::executeRun()

Reimplemented from MinimalEventLoopMgr.

Definition at line 308 of file EventLoopMgr.cpp.

    00308                                                    {
    00309   StatusCode  sc;
    00310   // initialize the base class
    00311   sc = MinimalEventLoopMgr::executeRun(maxevt);
    00312   return sc;
    00313 }

## Member Data Documentation

IDataManagerSvc* EventLoopMgr::m_evtDataMgrSvc`[protected]`

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 41 of file EventLoopMgr.h.

IDataProviderSvc* EventLoopMgr::m_evtDataSvc`[protected]`

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 43 of file EventLoopMgr.h.

IEvtSelector* EventLoopMgr::m_evtSelector`[protected]`

Reference to the Event Selector.

Definition at line 45 of file EventLoopMgr.h.

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

Event Iterator.

Definition at line 47 of file EventLoopMgr.h.

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

Event selector.

Definition at line 49 of file EventLoopMgr.h.

IDataManagerSvc* EventLoopMgr::m_histoDataMgrSvc`[protected]`

Reference to the Histogram Data Service.

Definition at line 51 of file EventLoopMgr.h.

IConversionSvc* EventLoopMgr::m_histoPersSvc`[protected]`

Reference to the Histogram Persistency Service.

Definition at line 53 of file EventLoopMgr.h.

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

Name of the Hist Pers type.

Definition at line 55 of file EventLoopMgr.h.

IProperty* EventLoopMgr::m_appMgrProperty`[protected]`

Property interface of ApplicationMgr.

Definition at line 57 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 60 of file EventLoopMgr.h.

bool EventLoopMgr::m_warnings`[protected]`

Flag to disable warning messages when using external input.

Definition at line 62 of file EventLoopMgr.h.

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

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