| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Protected Attributes

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

    : MinimalEventLoopMgr(nam, svcLoc)
    {
      m_histoDataMgrSvc   = 0;
      m_histoPersSvc      = 0;
      m_evtDataMgrSvc     = 0;
      m_evtDataSvc        = 0;
      m_evtSelector       = 0;
      m_evtContext        = 0;
      m_endEventFired     = true;

      // Declare properties
      declareProperty("HistogramPersistency", m_histPersName = "");
      declareProperty("EvtSel", m_evtsel );
      declareProperty("Warnings",m_warnings=true,
                      "Set this property to false to suppress warning messages");
    }

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

Standard Destructor.

Definition at line 47 of file EventLoopMgr.cpp.

                                  {
      if( m_histoDataMgrSvc ) m_histoDataMgrSvc->release();
      if( m_histoPersSvc ) m_histoPersSvc->release();
      if( m_evtDataMgrSvc ) m_evtDataMgrSvc->release();
      if( m_evtDataSvc ) m_evtDataSvc->release();
      if( m_evtSelector ) m_evtSelector->release();
      if( m_evtContext ) delete m_evtContext;
    }

## Member Function Documentation

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

implementation of IEventProcessor::executeEvent(void* par)

Reimplemented from MinimalEventLoopMgr.

Definition at line 287 of file EventLoopMgr.cpp.

                                                      {

      // Fire BeginEvent "Incident"
      m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent));
      // An incident may schedule a stop, in which case is better to exit before the actual execution.
      if ( m_scheduledStop ) {
        MsgStream  log( msgSvc(), name() );
        log << MSG::ALWAYS << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
        return StatusCode::SUCCESS;
      }

      // Execute Algorithms
      m_incidentSvc->fireIncident(Incident(name(), IncidentType::BeginProcessing));
      StatusCode sc = MinimalEventLoopMgr::executeEvent(par);
      m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndProcessing));

      // Check if there was an error processing current event
      if( !sc.isSuccess() ){
        MsgStream log( msgSvc(), name() );
        log << MSG::ERROR << "Terminating event processing loop due to errors" << endmsg;
      }
      return sc;
    }

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

implementation of IEventProcessor::executeRun()

Reimplemented from MinimalEventLoopMgr.

Definition at line 314 of file EventLoopMgr.cpp.

                                                       {
      StatusCode  sc;
      // initialize the base class
      sc = MinimalEventLoopMgr::executeRun(maxevt);
      return sc;
    }

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

implementation of IService::finalize

Reimplemented from MinimalEventLoopMgr.

Definition at line 217 of file EventLoopMgr.cpp.

                                         {
      StatusCode sc;
      MsgStream log(msgSvc(), name());

      // Finalize base class
      sc = MinimalEventLoopMgr::finalize();
      if (! sc.isSuccess()) {
        log << MSG::ERROR << "Error finalizing base class" << endmsg;
        return sc;
      }

      // Save Histograms Now
      if ( m_histoPersSvc != 0 )    {
        HistogramAgent agent;
        sc = m_histoDataMgrSvc->traverseTree( &agent );
        if( sc.isSuccess() )   {
          IDataSelector* objects = agent.selectedObjects();
          // skip /stat entry!
          if ( objects->size() > 0 )    {
            IDataSelector::iterator i;
            for ( i = objects->begin(); i != objects->end(); i++ )    {
              IOpaqueAddress* pAddr = 0;
              StatusCode iret = m_histoPersSvc->createRep(*i, pAddr);
              if ( iret.isSuccess() )     {
                (*i)->registry()->setAddress(pAddr);
              }
              else  {
                sc = iret;
              }
            }
            for ( i = objects->begin(); i != objects->end(); i++ )    {
              IRegistry* reg = (*i)->registry();
              StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), *i);
              if ( !iret.isSuccess() )    {
                sc = iret;
              }
            }
          }
          if ( sc.isSuccess() )    {
            log << MSG::INFO << "Histograms converted successfully according to request." << endmsg;
          }
          else  {
            log << MSG::ERROR << "Error while saving Histograms." << endmsg;
          }
        }
        else {
          log << MSG::ERROR << "Error while traversing Histogram data store" << endmsg;
        }
      }

      // Release event selector context
      if ( m_evtSelector && m_evtContext )   {
        m_evtSelector->releaseContext(m_evtContext).ignore();
        m_evtContext = 0;
      }

      // Release all interfaces...
      m_histoDataMgrSvc = 0;
      m_histoPersSvc    = 0;

      m_evtSelector     = 0;
      m_evtDataSvc      = 0;
      m_evtDataMgrSvc   = 0;

      return StatusCode::SUCCESS;
    }

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

Create event address using event selector.

Definition at line 397 of file EventLoopMgr.cpp.

                                                                    {
      refpAddr = 0;
      StatusCode sc = m_evtSelector->next(*m_evtContext);
      if ( !sc.isSuccess() )  {
        return sc;
      }
      // Create root address and assign address to data service
      sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
      if( !sc.isSuccess() )  {
        sc = m_evtSelector->next(*m_evtContext);
        if ( sc.isSuccess() )  {
          sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
          if ( !sc.isSuccess() )  {
            MsgStream log( msgSvc(), name() );
            log << MSG::WARNING << "Error creating IOpaqueAddress." << endmsg;
          }
        }
      }
      return sc;
    }

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

implementation of IService::initialize

Reimplemented from MinimalEventLoopMgr.

Definition at line 59 of file EventLoopMgr.cpp.

                                           {
      // Initialize the base class
      StatusCode sc = MinimalEventLoopMgr::initialize();
      MsgStream log(msgSvc(), name());
      if( !sc.isSuccess() ) {
        log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
        return sc;
      }

      // Setup access to event data services
      m_evtDataMgrSvc = serviceLocator()->service("EventDataSvc");
      if( !m_evtDataMgrSvc.isValid() )  {
        log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
        return StatusCode::FAILURE;
      }
      m_evtDataSvc = serviceLocator()->service("EventDataSvc");
      if( !m_evtDataSvc.isValid() )  {
        log << MSG::FATAL << "Error retrieving EventDataSvc interface IDataProviderSvc." << endmsg;
        return StatusCode::FAILURE;
      }

      // Obtain the IProperty of the ApplicationMgr
      m_appMgrProperty = serviceLocator();
      if ( ! m_appMgrProperty.isValid() )   {
        log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
        return StatusCode::FAILURE;
      }

      // We do not expect a Event Selector necessarily being declared
      setProperty(m_appMgrProperty->getProperty("EvtSel")).ignore();

      if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
        m_evtSelector = serviceLocator()->service("EventSelector");
        if( m_evtSelector.isValid() ) {
          // Setup Event Selector
          sc=m_evtSelector->createContext(m_evtContext);
          if( !sc.isSuccess() )   {
            log << MSG::FATAL << "Can not create the event selector Context." << endmsg;
            return sc;
          }
        }
        else {
          log << MSG::FATAL << "EventSelector not found." << endmsg;
          return sc;
        }
      }
      else {
        m_evtSelector = 0;
        m_evtContext = 0;
        if ( m_warnings ) {
          log << MSG::WARNING << "Unable to locate service \"EventSelector\" " << endmsg;
          log << MSG::WARNING << "No events will be processed from external input." << endmsg;
        }
      }

      // Setup access to histogramming services
      m_histoDataMgrSvc = serviceLocator()->service("HistogramDataSvc");
      if( !m_histoDataMgrSvc.isValid() )  {
        log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endmsg;
        return sc;
      }
      // Setup histogram persistency
      m_histoPersSvc = serviceLocator()->service("HistogramPersistencySvc");
      if( !m_histoPersSvc.isValid() ) {
        log << MSG::WARNING << "Histograms cannot not be saved - though required." << endmsg;
        return sc;
      }

      return StatusCode::SUCCESS;
    }

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

implementation of IService::nextEvent

Reimplemented from MinimalEventLoopMgr.

Definition at line 324 of file EventLoopMgr.cpp.

                                                   {
      static int        total_nevt = 0;
      DataObject*       pObject = 0;
      StatusCode        sc(StatusCode::SUCCESS, true);
      MsgStream         log( msgSvc(), name() );

      // Reset the application return code.
      Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::Success, true).ignore();

      // loop over events if the maxevt (received as input) if different from -1.
      // if evtmax is -1 it means infinite loop
      for( int nevt = 0; (maxevt == -1 ? true : nevt < maxevt);  nevt++, total_nevt++) {

        // Check if there is a scheduled stop issued by some algorithm/service
        if ( m_scheduledStop ) {
          m_scheduledStop = false;
          log << MSG::ALWAYS << "Terminating event processing loop due to scheduled stop" << endmsg;
          break;
        }
        // Clear the event store, if used in the event loop
        if( 0 != total_nevt ) {

          if ( ! m_endEventFired ) {
            // Fire EndEvent "Incident" (it is considered part of the clearing of the TS)
            m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
            m_endEventFired = true;
          }
          sc = m_evtDataMgrSvc->clearStore();
          if( !sc.isSuccess() )  {
            log << MSG::DEBUG << "Clear of Event data store failed" << endmsg;
          }
        }

        // Setup event in the event store
        if( m_evtContext ) {
          IOpaqueAddress* addr = 0;
          // Only if there is a EventSelector
          sc = getEventRoot(addr);
          if( !sc.isSuccess() )  {
            log << MSG::INFO << "No more events in event selection " << endmsg;
            break;
          }
          // Set root clears the event data store first
          sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
          if( !sc.isSuccess() )  {
            log << MSG::WARNING << "Error declaring event root address." << endmsg;
            continue;
          }
          sc = m_evtDataSvc->retrieveObject("/Event", pObject);
          if( !sc.isSuccess() ) {
            log << MSG::WARNING << "Unable to retrieve Event root object" << endmsg;
            break;
          }
        }
        else {
          sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
          if( !sc.isSuccess() )  {
            log << MSG::WARNING << "Error declaring event root DataObject" << endmsg;
          }
        }
        // Execute event for all required algorithms
        sc = executeEvent(NULL);
        m_endEventFired = false;
        if( !sc.isSuccess() ){
          log << MSG::ERROR << "Terminating event processing loop due to errors" << endmsg;
          Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::AlgorithmFailure).ignore();
          return sc;
        }
      }
      return StatusCode::SUCCESS;
    }

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

implementation of IService::reinitialize

Reimplemented from MinimalEventLoopMgr.

Definition at line 132 of file EventLoopMgr.cpp.

                                          {
      MsgStream log(msgSvc(), name());

      // Initialize the base class
      StatusCode sc = MinimalEventLoopMgr::reinitialize();
      if( !sc.isSuccess() ) {
        log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
        return sc;
      }

      // Check to see whether a new Event Selector has been specified
      setProperty(m_appMgrProperty->getProperty("EvtSel"));
      if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
        SmartIF<IService> theSvc(serviceLocator()->service("EventSelector"));
        SmartIF<IEvtSelector> theEvtSel(theSvc);
        if( theEvtSel.isValid() && ( theEvtSel.get() != m_evtSelector.get() ) ) {
          // Setup Event Selector
          if ( m_evtSelector.get() && m_evtContext ) {
            // Need to release context before switching to new event selector
            m_evtSelector->releaseContext(m_evtContext);
            m_evtContext = 0;
          }
          m_evtSelector = theEvtSel;
          if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
            sc = theSvc->reinitialize();
            if( !sc.isSuccess() ) {
              log << MSG::ERROR << "Failure Reinitializing EventSelector "
                  << theSvc->name( ) << endmsg;
              return sc;
            }
          }
          else {
            sc = theSvc->sysInitialize();
            if( !sc.isSuccess() ) {
              log << MSG::ERROR << "Failure Initializing EventSelector "
                  << theSvc->name( ) << endmsg;
              return sc;
            }
          }
          sc = m_evtSelector->createContext(m_evtContext);
          if( !sc.isSuccess() ) {
            log << MSG::ERROR << "Can not create Context "
                << theSvc->name( ) << endmsg;
            return sc;
          }
          log << MSG::INFO << "EventSelector service changed to "
              << theSvc->name( ) << endmsg;
        }
        else if ( m_evtSelector.isValid() ) {
          if ( m_evtContext ) {
            m_evtSelector->releaseContext(m_evtContext);
            m_evtContext = 0;
          }
          sc = m_evtSelector->createContext(m_evtContext);
          if( !sc.isSuccess() ) {
            log << MSG::ERROR << "Can not create Context "
                << theSvc->name( ) << endmsg;
            return sc;
          }
        }
      }
      else if ( m_evtSelector.isValid() && m_evtContext ) {
        m_evtSelector->releaseContext(m_evtContext);
        m_evtSelector = 0;
        m_evtContext = 0;
      }
      return StatusCode::SUCCESS;
    }

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

implementation of IService::stop

Reimplemented from MinimalEventLoopMgr.

Definition at line 205 of file EventLoopMgr.cpp.

                                     {
      if ( ! m_endEventFired ) {
        // Fire pending EndEvent incident
        m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
        m_endEventFired = true;
      }
      return MinimalEventLoopMgr::stop();
    }

## Member Data Documentation

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.

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

Event Iterator.

Definition at line 50 of file EventLoopMgr.h.

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.

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

Event selector.

Definition at line 52 of file EventLoopMgr.h.

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

Reference to the Event Selector.

Definition at line 48 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.

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines