| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 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::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
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.
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 36 of file EventLoopMgr.h.

## 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 384 of file EventLoopMgr.cpp.

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

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." << endmsg;
    00063     return sc;
    00064   }
    00065
    00066   // Setup access to event data services
    00067   m_evtDataMgrSvc = serviceLocator()->service("EventDataSvc");
    00068   if( !m_evtDataMgrSvc.isValid() )  {
    00069     log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
    00070     return StatusCode::FAILURE;
    00071   }
    00072   m_evtDataSvc = serviceLocator()->service("EventDataSvc");
    00073   if( !m_evtDataSvc.isValid() )  {
    00074     log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endmsg;
    00075     return StatusCode::FAILURE;
    00076   }
    00077
    00078   // Obtain the IProperty of the ApplicationMgr
    00079   SmartIF<IProperty> prpMgr(serviceLocator());
    00080   if ( ! prpMgr.isValid() )   {
    00081     log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
    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     m_evtSelector = serviceLocator()->service("EventSelector");
    00093     if( m_evtSelector.isValid() ) {
    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." << endmsg;
    00098         return sc;
    00099       }
    00100     }
    00101     else {
    00102       log << MSG::FATAL << "EventSelector not found." << endmsg;
    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\" " << endmsg;
    00111       log << MSG::WARNING << "No events will be processed from external input." << endmsg;
    00112     }
    00113   }
    00114
    00115   // Setup access to histogramming services
    00116   m_histoDataMgrSvc = serviceLocator()->service("HistogramDataSvc");
    00117   if( !m_histoDataMgrSvc.isValid() )  {
    00118     log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endmsg;
    00119     return sc;
    00120   }
    00121   // Setup histogram persistency
    00122   m_histoPersSvc = serviceLocator()->service("HistogramPersistencySvc");
    00123   if( !m_histoPersSvc.isValid() ) {
    00124     log << MSG::WARNING << "Histograms cannot not be saved - though required." << endmsg;
    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." << 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       m_evtSelector = theEvtSel;
    00150       if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
    00151         sc = theSvc->reinitialize();
    00152         if( !sc.isSuccess() ) {
    00153           log << MSG::ERROR << "Failure Reinitializing EventSelector "
    00154               << theSvc->name( ) << endmsg;
    00155           return sc;
    00156         }
    00157       }
    00158       else {
    00159         sc = theSvc->sysInitialize();
    00160         if( !sc.isSuccess() ) {
    00161           log << MSG::ERROR << "Failure Initializing EventSelector "
    00162               << theSvc->name( ) << endmsg;
    00163           return sc;
    00164         }
    00165       }
    00166       sc = m_evtSelector->createContext(m_evtContext);
    00167       if( !sc.isSuccess() ) {
    00168         log << MSG::ERROR << "Can not create Context "
    00169             << theSvc->name( ) << endmsg;
    00170         return sc;
    00171       }
    00172       log << MSG::INFO << "EventSelector service changed to "
    00173           << theSvc->name( ) << endmsg;
    00174     }
    00175     else if ( m_evtSelector.isValid() && m_evtContext ) {
    00176       m_evtSelector->releaseContext(m_evtContext);
    00177       m_evtContext = 0;
    00178       sc = m_evtSelector->createContext(m_evtContext);
    00179       if( !sc.isSuccess() ) {
    00180         log << MSG::ERROR << "Can not create Context "
    00181             << theSvc->name( ) << endmsg;
    00182         return sc;
    00183       }
    00184     }
    00185   }
    00186   else if ( m_evtSelector.isValid() && m_evtContext ) {
    00187     m_evtSelector->releaseContext(m_evtContext);
    00188     m_evtSelector = 0;
    00189     m_evtContext = 0;
    00190   }
    00191   return StatusCode::SUCCESS;
    00192 }

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

implementation of IService::stop

Reimplemented from MinimalEventLoopMgr.

Definition at line 198 of file EventLoopMgr.cpp.

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

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

implementation of IService::finalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 210 of file EventLoopMgr.cpp.

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

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

implementation of IService::nextEvent

Reimplemented from MinimalEventLoopMgr.

Definition at line 316 of file EventLoopMgr.cpp.

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

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

implementation of IEventProcessor::executeEvent(void* par)

Reimplemented from MinimalEventLoopMgr.

Definition at line 281 of file EventLoopMgr.cpp.

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

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

implementation of IEventProcessor::executeRun()

Reimplemented from MinimalEventLoopMgr.

Definition at line 306 of file EventLoopMgr.cpp.

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

## Member Data Documentation

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

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 41 of file EventLoopMgr.h.

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

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 43 of file EventLoopMgr.h.

SmartIF<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.

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

Reference to the Histogram Data Service.

Definition at line 51 of file EventLoopMgr.h.

SmartIF<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_v21r7p1/GaudiSvc/src/ApplicationMgr/EventLoopMgr.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7p1/GaudiSvc/src/ApplicationMgr/EventLoopMgr.cpp