Gaudi Framework, version v20r2

Generated: 18 Jul 2008

EventSelector Class Reference

#include <EventSelector.h>

Inheritance diagram for EventSelector:

Inheritance graph
[legend]
Collaboration diagram for EventSelector:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition of class EventSelector.

Basic event selector service. The event selector service itself is able to connect other services to attached streams.

History: +---------+----------------------------------------------+---------+ | Date | Comment | Who | +---------+----------------------------------------------+---------+ | 3/10/00 | Initial version | M.Frank | +---------+----------------------------------------------+---------+

Author:
Markus Frank
Version:
1.0

Definition at line 50 of file EventSelector.h.

Public Types

typedef std::vector< EventSelectorDataStream * > Streams
typedef std::vector< std::stringStreamSpecs
typedef std::vector< StringPropertyProperties

Public Member Functions

virtual StatusCode initialize ()
 IService implementation: Db event selector override.
virtual StatusCode finalize ()
 IService implementation: Service finalization.
virtual StatusCode reinitialize ()
 Service override: Reinitialize service.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Service override: queryInterface.
virtual StatusCode createContext (Context *&refpCtxt) const
 
Parameters:
refpCtxt [IN/OUT] Reference to pointer to store the context

virtual StatusCode next (Context &refCtxt) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode next (Context &refCtxt, int jump) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode previous (Context &refCtxt) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode previous (Context &refCtxt, int jump) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode rewind (Context &refCtxt) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&refpAddr) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode releaseContext (Context *&refCtxt) const
 
Parameters:
refCtxt [IN/OUT] Reference to the context

virtual StatusCode resetCriteria (const std::string &cr, Context &c) const
 Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.
virtual StatusCode last (Context &c) const
 Access last item in the iteration.
StatusCode firstOfNextStream (bool shutDown, EvtSelectorContext &it) const
 Retrieve first entry of the next data stream.
StatusCode lastOfPreviousStream (bool shutDown, EvtSelectorContext &it) const
 Retrieve last entry of the previous data stream.
 EventSelector (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
virtual ~EventSelector ()
 Standard Destructor.

Public Attributes

long int m_streamID

Protected Member Functions

virtual void printEvtInfo (const EvtSelectorContext *iter) const
 Progress report.

Protected Attributes

IIncidentSvcm_incidentSvc
 Reference to the indicent service.
IToolSvcm_toolSvc
IDataStreamToolm_streamtool
bool m_reconfigure
 Reconfigure occurred.
StreamSpecs m_streamSpecs
 Input stream specifiers (for job options).
StreamSpecs m_streamSpecsLast
 Input stream specifiers (last used).
Streams m_streams
 Input streams.
int m_streamCount
 Input stream counter (0..oo, monotonely increasing).
int m_firstEvent
 First event to be processed.
int m_evtMax
 Maximum number of events to be processed.
int m_evtPrintFrequency
 Printout frequency.
std::string m_streamManager


Member Typedef Documentation

typedef std::vector<EventSelectorDataStream*> EventSelector::Streams

Definition at line 52 of file EventSelector.h.

typedef std::vector<std::string> EventSelector::StreamSpecs

Definition at line 53 of file EventSelector.h.

typedef std::vector<StringProperty> EventSelector::Properties

Definition at line 54 of file EventSelector.h.


Constructor & Destructor Documentation

EventSelector::EventSelector ( const std::string name,
ISvcLocator svcloc 
)

Standard Constructor.

Definition at line 26 of file EventSelector.cpp.

References Service::declareProperty().

00027   : Service( name, svcloc)
00028 {
00029   m_incidentSvc       = 0;
00030   m_toolSvc           = 0;
00031   m_streamCount       = 0;
00032   m_firstEvent        = 0;
00033   m_evtPrintFrequency = 10;
00034   m_evtMax            = INT_MAX;
00035   declareProperty( "Input",      m_streamSpecs);
00036   declareProperty( "FirstEvent", m_firstEvent);
00037   declareProperty( "EvtMax",     m_evtMax);
00038   declareProperty( "PrintFreq",  m_evtPrintFrequency);
00039   declareProperty( "StreamManager",  m_streamManager="DataStreamTool");
00040   m_reconfigure = false;
00041 }

EventSelector::~EventSelector (  )  [virtual]

Standard Destructor.

Definition at line 44 of file EventSelector.cpp.

00045 {
00046 }


Member Function Documentation

void EventSelector::printEvtInfo ( const EvtSelectorContext iter  )  const [protected, virtual]

Progress report.

Definition at line 56 of file EventSelector.cpp.

References MSG::ALWAYS, EvtSelectorContext::context(), count(), endreq(), EvtSelectorContext::ID(), MSG::INFO, m_evtPrintFrequency, Service::messageService(), Service::name(), EvtSelectorContext::numEvent(), and EvtSelectorContext::numStreamEvent().

Referenced by next(), and previous().

00056                                                                      {
00057   if ( 0 != iter )  {
00058     long count = iter->numEvent();
00059     // Print an message every m_evtPrintFrequency events
00060     if ( 0 == iter->context() )   {
00061       MsgStream log(messageService(), name());
00062       log << MSG::INFO << "End of event input reached." << endreq;
00063     }
00064     else if( iter->numStreamEvent() == -1 ) {
00065       // Intial value for this stream
00066     }
00067     else if( m_evtPrintFrequency != -1 && (count % m_evtPrintFrequency == 0))   {
00068       MsgStream log(messageService(), name());
00069       log << MSG::ALWAYS << "Reading Event record " << count+1
00070           << ". Record number within stream " << iter->ID()+1 
00071           << ": " << iter->numStreamEvent()+1 << endreq;
00072     }
00073   }
00074   else  {
00075     MsgStream log(messageService(), name());
00076     log << MSG::INFO << "End of event input reached." << endreq;
00077   }
00078 }

StatusCode EventSelector::initialize (  )  [virtual]

IService implementation: Db event selector override.

Reimplemented from Service.

Definition at line 385 of file EventSelector.cpp.

References IDataStreamTool::addStreams(), std::basic_string< _CharT, _Traits, _Alloc >::c_str(), endreq(), MSG::ERROR, StatusCode::FAILURE, MSG::FATAL, Service::initialize(), StatusCode::isFailure(), StatusCode::isSuccess(), apmon_utils::logger(), m_evtMax, m_incidentSvc, m_streamID, m_streamManager, m_streamSpecs, m_streamSpecsLast, m_streamtool, m_toolSvc, Service::messageService(), Service::name(), IToolSvc::retrieveTool(), ISvcLocator::service(), and Service::serviceLocator().

00385                                         {
00386   // Initialize base class
00387   StatusCode status = Service::initialize();
00388   MsgStream logger(messageService(), name());
00389   if ( !status.isSuccess() )    {
00390     logger << MSG::ERROR << "Error initializing base class Service!" << endreq;
00391     return status;
00392   }
00393   // Get the references to the services that are needed by the ApplicationMgr itself
00394   StatusCode sc = serviceLocator()->service("IncidentSvc", m_incidentSvc, true);
00395   if( !sc.isSuccess() )  {
00396     logger << MSG::FATAL << "Error retrieving IncidentSvc." << endreq;
00397     return sc;
00398   }
00399   if ( m_evtMax != INT_MAX )   {
00400     logger << MSG::ERROR << "EvtMax is an obsolete property of the event selector." << endreq;
00401     logger << MSG::ERROR << "Please set \"ApplicationMgr.EvtMax = " << m_evtMax 
00402            << ";\" to process the requested number of events." << endreq;
00403     return StatusCode::FAILURE;
00404   }
00405   
00406   m_toolSvc = 0 ;
00407   sc = serviceLocator()->service( "ToolSvc" , m_toolSvc , true );
00408   if ( sc.isFailure() )
00409   { logger << MSG::ERROR << " Could not locate the Tool Service! " << endreq ;
00410   return StatusCode::FAILURE ;}
00411 
00412   sc = m_toolSvc->retrieveTool(m_streamManager.c_str(), m_streamtool, this );
00413   
00414   if( sc.isFailure() ) {
00415     logger << MSG::ERROR << "Error initializing " 
00416            << m_streamManager << endreq;
00417     return sc;
00418   }
00419   
00420   status = m_streamtool->addStreams(m_streamSpecs);
00421   
00422   m_streamSpecsLast = m_streamSpecs;
00423  
00424   m_streamID          = 0;
00425 
00426   return status;
00427 }

StatusCode EventSelector::finalize (  )  [virtual]

IService implementation: Service finalization.

Reimplemented from Service.

Definition at line 449 of file EventSelector.cpp.

References MSG::DEBUG, endreq(), Service::finalize(), m_incidentSvc, m_streamtool, m_toolSvc, Service::msgSvc(), Service::name(), and IInterface::release().

00449                                       {
00450 
00451   MsgStream log(msgSvc(), name());
00452 
00453   log << MSG::DEBUG << "finalize()" << endreq;
00454   
00455   if( m_incidentSvc ) {
00456     m_incidentSvc->release();
00457     m_incidentSvc = 0 ;
00458   }
00459     
00460   if( m_streamtool ) {
00461     m_streamtool->release();
00462     m_streamtool = 0 ;
00463   }
00464 
00465   if( m_toolSvc ) {
00466     m_toolSvc->release();
00467     m_toolSvc = 0 ;
00468   }
00469 
00470   return Service::finalize();
00471 }

StatusCode EventSelector::reinitialize (  )  [virtual]

Service override: Reinitialize service.

Reimplemented from Service.

Definition at line 430 of file EventSelector.cpp.

References IDataStreamTool::addStreams(), IDataStreamTool::clear(), endreq(), MSG::ERROR, StatusCode::FAILURE, Service::FSMState(), Gaudi::StateMachine::INITIALIZED, StatusCode::isFailure(), apmon_utils::logger(), m_reconfigure, m_streamSpecs, m_streamSpecsLast, m_streamtool, Service::messageService(), Service::name(), and StatusCode::SUCCESS.

00430                                        {
00431   if ( FSMState() != Gaudi::StateMachine::INITIALIZED ) {
00432     MsgStream logger(messageService(), name());
00433     logger << MSG::ERROR << "Cannot reinitialize: service not in state initialized" << endreq;
00434     return StatusCode::FAILURE;
00435   }
00436   
00437   if( m_streamSpecsLast != m_streamSpecs ) {
00438     StatusCode status = m_streamtool->clear();
00439     if ( status.isFailure() ) return status;
00440     m_streamSpecsLast = m_streamSpecs;
00441     m_reconfigure = true;
00442     return m_streamtool->addStreams(m_streamSpecs);
00443   }
00444   
00445   return StatusCode::SUCCESS;
00446 }

StatusCode EventSelector::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual]

Service override: queryInterface.

Reimplemented from Service.

Definition at line 375 of file EventSelector.cpp.

References Service::addRef(), IID_IEvtSelector, Service::queryInterface(), and IInterface::SUCCESS.

00375                                                                                       {
00376   if ( riid == IID_IEvtSelector )  {
00377     *ppvInterface = (IEvtSelector*)this;
00378     addRef();
00379     return SUCCESS;
00380   }
00381   return Service::queryInterface( riid, ppvInterface );
00382 }

StatusCode EventSelector::createContext ( Context *&  refpCtxt  )  const [virtual]

Parameters:
refpCtxt [IN/OUT] Reference to pointer to store the context

Returns:
StatusCode indicating success or failure

Definition at line 188 of file EventSelector.cpp.

References endreq(), MSG::ERROR, StatusCode::FAILURE, firstOfNextStream(), StatusCode::ignore(), StatusCode::isFailure(), m_firstEvent, Service::messageService(), Service::name(), next(), releaseContext(), EvtSelectorContext::set(), and StatusCode::SUCCESS.

00189 {
00190   // Max event is zero. Return begin = end
00191   refpCtxt = 0;
00192   if ( m_firstEvent < 0 ) {
00193     MsgStream log(messageService(), name());
00194     log << MSG::ERROR  << "First Event = " << m_firstEvent << " not valid" << endreq;
00195     log << MSG::ERROR  << "It should be > 0 " << endreq;
00196     return StatusCode::FAILURE;    // if failure => iterators = end();
00197   }
00198   EvtSelectorContext* ctxt = new EvtSelectorContext(this);
00199   ctxt->set(0, -1, 0, 0);
00200   firstOfNextStream(true, *ctxt).ignore();
00201   refpCtxt = ctxt;
00202   long nskip = m_firstEvent;
00203   while( --nskip > 0 )    {
00204     StatusCode sc = next(*refpCtxt);
00205     if ( sc.isFailure() ) {
00206       MsgStream log(messageService(), name());
00207       log << MSG::ERROR << " createContext() failed to start with event number " 
00208           << m_firstEvent << endreq;
00209       releaseContext(refpCtxt);
00210       refpCtxt = 0;
00211       return StatusCode::FAILURE;
00212     }
00213   }
00214   return StatusCode::SUCCESS;
00215 }

StatusCode EventSelector::next ( Context &  refCtxt  )  const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Returns:
StatusCode indicating success or failure

Definition at line 218 of file EventSelector.cpp.

Referenced by createContext(), next(), and rewind().

00218                                                       {
00219   return next(refCtxt, 1);
00220 }

StatusCode EventSelector::next ( Context &  refCtxt,
int  jump 
) const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Returns:
StatusCode indicating success or failure

Definition at line 223 of file EventSelector.cpp.

References EvtSelectorContext::context(), StatusCode::FAILURE, firstOfNextStream(), IDataStreamTool::getStream(), EvtSelectorContext::ID(), EvtSelectorContext::increaseCounters(), StatusCode::isSuccess(), m_reconfigure, m_streamtool, next(), IEvtSelector::next(), printEvtInfo(), Gaudi::Units::s, and EvtSelectorContext::set().

00223                                                                        {
00224   EvtSelectorContext *pIt  = dynamic_cast<EvtSelectorContext*>(&refCtxt);
00225   if ( pIt )    {
00226     if ( pIt->ID() != -1 ) {
00227       const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
00228       Context* it = pIt->context();
00229       IEvtSelector* sel = s->selector();
00230       if ( it && sel )    { // First exploit the current stream
00231         StatusCode sc = sel->next(*it);  // This stream is empty: advance to the next stream
00232         if ( !sc.isSuccess() )   {
00233           sc = firstOfNextStream(true, *pIt);
00234           if (sc.isSuccess() ) sc = next(*pIt);
00235         }
00236         else  {
00237           pIt->increaseCounters(false);
00238           pIt->set(it, 0);
00239           printEvtInfo(pIt);
00240         }
00241         return sc;
00242       }
00243       else if ( m_reconfigure )  {
00244         StatusCode sc = firstOfNextStream(false, *pIt);
00245         printEvtInfo(pIt);
00246         return sc;
00247       }
00248     }
00249     else if ( m_reconfigure )  {
00250       StatusCode sc = firstOfNextStream(false, *pIt);
00251       printEvtInfo(pIt);
00252       return sc;
00253     }
00254     pIt->increaseCounters(false);
00255   }
00256   printEvtInfo(pIt);
00257   return StatusCode::FAILURE;
00258 }

StatusCode EventSelector::previous ( Context &  refCtxt  )  const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Parameters:
jump [IN] Number of events to be skipped
Returns:
StatusCode indicating success or failure

Definition at line 261 of file EventSelector.cpp.

00261                                                           {
00262   return previous(refCtxt, 1);
00263 }

StatusCode EventSelector::previous ( Context &  refCtxt,
int  jump 
) const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Parameters:
jump [IN] Number of events to be skipped
Returns:
StatusCode indicating success or failure

Definition at line 266 of file EventSelector.cpp.

References EvtSelectorContext::context(), StatusCode::FAILURE, IDataStreamTool::getStream(), EvtSelectorContext::ID(), EvtSelectorContext::increaseCounters(), StatusCode::isSuccess(), lastOfPreviousStream(), m_streamtool, IEvtSelector::previous(), printEvtInfo(), Gaudi::Units::s, EvtSelectorContext::set(), and StatusCode::SUCCESS.

00266                                                               {
00267   EvtSelectorContext *pIt  = dynamic_cast<EvtSelectorContext*>(&it);
00268   if ( pIt && jump > 0 )    {
00269     StatusCode sc = StatusCode::SUCCESS;
00270     for ( int i = 0; i < jump && sc.isSuccess(); ++i ) {
00271       const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
00272       Context* it = pIt->context();
00273       IEvtSelector* sel = s->selector();
00274       if ( it && sel )    { // First exploit the current stream
00275                             // This stream is empty: advance to the next stream
00276         sc = sel->previous(*it);  // This stream is empty: advance to the next stream
00277         if ( !sc.isSuccess() )   {
00278           sc = lastOfPreviousStream(true, *pIt);
00279         }
00280         else  {
00281           pIt->increaseCounters(false);
00282           pIt->set(it, 0);
00283         }
00284         printEvtInfo(pIt);
00285         if ( !sc.isSuccess() ) {
00286           return sc;
00287         }
00288       }
00289       pIt->increaseCounters(false);
00290     }
00291     return sc;
00292   }
00293   printEvtInfo(pIt);
00294   return StatusCode::FAILURE;
00295 }

StatusCode EventSelector::rewind ( Context &  refCtxt  )  const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Returns:
StatusCode indicating success or failure

Definition at line 306 of file EventSelector.cpp.

References endreq(), MSG::ERROR, StatusCode::FAILURE, firstOfNextStream(), StatusCode::isFailure(), m_firstEvent, Service::messageService(), Service::name(), next(), EvtSelectorContext::set(), and StatusCode::SUCCESS.

00306                                                         {
00307   EvtSelectorContext *ctxt  = dynamic_cast<EvtSelectorContext*>(&refCtxt);
00308   if ( ctxt )    {
00309     ctxt->set(0, -1, 0, 0);
00310     firstOfNextStream(true, *ctxt);
00311     long nskip = m_firstEvent;
00312     while( --nskip > 0 )    {
00313       StatusCode sc = next(*ctxt);
00314       if ( sc.isFailure() ) {
00315         MsgStream log(messageService(), name());
00316         log << MSG::ERROR << "rewind() failed to start with event number " 
00317             << m_firstEvent << endreq;
00318         return StatusCode::FAILURE;
00319       }
00320     }
00321     return StatusCode::SUCCESS;
00322   }
00323   return StatusCode::FAILURE;
00324 }

StatusCode EventSelector::createAddress ( const Context &  refCtxt,
IOpaqueAddress *&  refpAddr 
) const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Parameters:
refpAddr [OUT] Reference to address pointer
Returns:
StatusCode indicating success or failure

Definition at line 328 of file EventSelector.cpp.

References IEvtSelector::createAddress(), StatusCode::FAILURE, IDataStreamTool::getStream(), StatusCode::isSuccess(), m_streamtool, and Gaudi::Units::s.

00330 {
00331   const EvtSelectorContext *cpIt  = dynamic_cast<const EvtSelectorContext*>(&refCtxt);
00332   EvtSelectorContext *pIt  = const_cast<EvtSelectorContext*>(cpIt);
00333   refpAddr = 0;
00334   if ( pIt )    {
00335     const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
00336     Context* it = pIt->context();
00337     IEvtSelector* sel = s->selector();
00338     if ( it && sel )    {
00339       IOpaqueAddress* pAddr = 0;
00340       StatusCode sc = sel->createAddress(*it, pAddr);
00341       if ( sc.isSuccess() )  {
00342         refpAddr = pAddr;
00343       }
00344       pIt->set(it, pAddr);
00345       return sc;
00346     }
00347   }
00348   return StatusCode::FAILURE;
00349 }

StatusCode EventSelector::releaseContext ( Context *&  refCtxt  )  const [virtual]

Parameters:
refCtxt [IN/OUT] Reference to the context

Returns:
StatusCode indicating success or failure

Definition at line 352 of file EventSelector.cpp.

References IDataStreamTool::getStream(), StatusCode::isSuccess(), m_streamtool, IEvtSelector::releaseContext(), Gaudi::Units::s, IDataStreamTool::size(), and StatusCode::SUCCESS.

Referenced by createContext().

00352                                                                  {
00353   const EvtSelectorContext *cpIt = dynamic_cast<const EvtSelectorContext*>(refCtxt);
00354   EvtSelectorContext       *pIt  = const_cast<EvtSelectorContext*>(cpIt);
00355   if ( pIt && pIt->ID() >= 0 && pIt->ID() < (long)m_streamtool->size() ) {
00356     const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
00357     Context* it = pIt->context();
00358     IEvtSelector* sel = s->selector();
00359     if ( it && sel )    {
00360       StatusCode sc = sel->releaseContext(it);
00361       if ( sc.isSuccess() )  {
00362         refCtxt = 0;
00363         delete pIt;
00364         return sc;
00365       }
00366     }
00367   }
00368   if ( pIt )   {
00369     delete pIt;
00370   }
00371   return StatusCode::SUCCESS;
00372 }

StatusCode EventSelector::resetCriteria ( const std::string cr,
Context &  c 
) const [virtual]

Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.

Parameters:
cr The new criteria string.
c Reference pointer to the Context object.
Returns:
StatusCode indicating success or failure

Definition at line 49 of file EventSelector.cpp.

References StatusCode::FAILURE.

00051 {
00052   return StatusCode::FAILURE;
00053 }

StatusCode EventSelector::last ( Context &  c  )  const [virtual]

Access last item in the iteration.

Parameters:
c Reference to the Context object.
Returns:
StatusCode indicating success or failure

Definition at line 298 of file EventSelector.cpp.

References StatusCode::FAILURE.

00298                                                      {
00299   EvtSelectorContext *pIt  = dynamic_cast<EvtSelectorContext*>(&refCtxt);
00300   if ( pIt )    {
00301   }
00302   return StatusCode::FAILURE;
00303 }

StatusCode EventSelector::firstOfNextStream ( bool  shutDown,
EvtSelectorContext it 
) const

Retrieve first entry of the next data stream.

Definition at line 82 of file EventSelector.cpp.

References EvtSelectorContext::context(), endreq(), StatusCode::FAILURE, IDataStreamTool::getNextStream(), IDataStreamTool::getStream(), EvtSelectorContext::ID(), MSG::INFO, StatusCode::isSuccess(), m_reconfigure, m_streamtool, Service::messageService(), Service::name(), Gaudi::Units::s, EvtSelectorContext::set(), StatusCode::setChecked(), IDataStreamTool::size(), and StatusCode::SUCCESS.

Referenced by createContext(), next(), and rewind().

00082                                                                               {
00083   StatusCode status = StatusCode::SUCCESS;
00084   IDataStreamTool::size_type iter_id = (m_reconfigure) ? 0 : iter.ID()+1;
00085   if ( m_reconfigure ) const_cast<EventSelector*>(this)->m_reconfigure = false;
00086   if ( shutDown )   {
00087     if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() )   {
00088       const EventSelectorDataStream* s = m_streamtool->getStream(iter.ID());
00089       if ( s->isInitialized() )    {
00090         EventSelector* thisPtr = const_cast<EventSelector*>(this);
00091         if ( s->selector() && iter.context() )  {
00092           Context* ctxt = iter.context();
00093           s->selector()->releaseContext(ctxt).ignore();
00094           iter.set(0,0);
00095         }
00096         status = thisPtr->m_streamtool->finalizeStream(const_cast<EventSelectorDataStream*>(s));
00097         iter.set(0,0);
00098       }
00099     }
00100   }
00101   
00102   const EventSelectorDataStream* s ;
00103   status = m_streamtool->getNextStream( s , iter_id );
00104   
00105   if ( status.isSuccess() )   {
00106     
00107     if ( !s->isInitialized() )    {
00108       EventSelector* thisPtr = const_cast<EventSelector*>(this);
00109       status = thisPtr->m_streamtool->initializeStream(const_cast<EventSelectorDataStream*>(s));
00110     }
00111     
00112     if ( status.isSuccess() ) {
00113       const IEvtSelector* sel = s->selector();
00114       if ( sel )    {
00115         Context* ctxt = 0;
00116         status = sel->createContext(ctxt);
00117         if ( status.isSuccess() )   {
00118           status = sel->resetCriteria(s->criteria(), *ctxt);
00119           if ( status.isSuccess() )   {
00120             MsgStream log(messageService(), name());
00121             iter.set(this, iter_id, ctxt, 0);
00122             log << MSG::INFO << *s << endreq;
00123             return StatusCode::SUCCESS;
00124           }
00125         }
00126       }
00127     }
00128   }
00129   
00130   iter.set(this, -1, 0, 0);
00131   status.setChecked();
00132   return StatusCode::FAILURE;
00133 }

StatusCode EventSelector::lastOfPreviousStream ( bool  shutDown,
EvtSelectorContext it 
) const

Retrieve last entry of the previous data stream.

Definition at line 137 of file EventSelector.cpp.

References EvtSelectorContext::context(), endreq(), StatusCode::FAILURE, IDataStreamTool::getPreviousStream(), IDataStreamTool::getStream(), EvtSelectorContext::ID(), MSG::INFO, StatusCode::isSuccess(), m_streamtool, Service::messageService(), Service::name(), Gaudi::Units::s, EvtSelectorContext::set(), IDataStreamTool::size(), and StatusCode::SUCCESS.

Referenced by previous().

00137                                                                                  {
00138   StatusCode status = StatusCode::SUCCESS;
00139   if ( shutDown )   {
00140     if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() )   {
00141       const EventSelectorDataStream* s = m_streamtool->getStream(iter.ID());
00142       if ( s->isInitialized() )    {
00143         EventSelector* thisPtr = const_cast<EventSelector*>(this);
00144         if ( s->selector() && iter.context() )  {
00145           Context* ctxt = iter.context();
00146           s->selector()->releaseContext(ctxt);
00147           iter.set(0,0);
00148         }
00149         status = thisPtr->m_streamtool->finalizeStream(const_cast<EventSelectorDataStream*>(s));
00150         iter.set(0,0);
00151       }
00152     }
00153   }
00154   
00155   IDataStreamTool::size_type iter_id = iter.ID()-1;
00156   const EventSelectorDataStream* s ;
00157   status = m_streamtool->getPreviousStream( s , iter_id );
00158   
00159   if ( status.isSuccess() )   {
00160     
00161     if ( !s->isInitialized() )    {
00162       EventSelector* thisPtr = const_cast<EventSelector*>(this);
00163       status = thisPtr->m_streamtool->initializeStream(const_cast<EventSelectorDataStream*>(s));
00164     }
00165     if ( status.isSuccess() )   {
00166       const IEvtSelector* sel = s->selector();
00167       if ( sel )  {
00168         Context* ctxt = 0;
00169         status = sel->createContext(ctxt);
00170         if ( status.isSuccess() )   {
00171           status = sel->resetCriteria(s->criteria(), *ctxt);
00172           if ( status.isSuccess() )   {
00173             MsgStream log(messageService(), name());
00174             iter.set(this, iter_id, ctxt, 0);
00175             log << MSG::INFO << *s << endreq;
00176             return StatusCode::SUCCESS;
00177           }
00178         }
00179       }
00180     }
00181   }
00182   
00183   iter.set(this, -1, 0, 0);
00184   return StatusCode::FAILURE;
00185 }


Member Data Documentation

long int EventSelector::m_streamID

Definition at line 56 of file EventSelector.h.

Referenced by initialize().

IIncidentSvc* EventSelector::m_incidentSvc [protected]

Reference to the indicent service.

Definition at line 60 of file EventSelector.h.

Referenced by finalize(), and initialize().

IToolSvc* EventSelector::m_toolSvc [protected]

Definition at line 62 of file EventSelector.h.

Referenced by finalize(), and initialize().

IDataStreamTool* EventSelector::m_streamtool [protected]

Definition at line 64 of file EventSelector.h.

Referenced by createAddress(), finalize(), firstOfNextStream(), initialize(), lastOfPreviousStream(), next(), previous(), reinitialize(), and releaseContext().

bool EventSelector::m_reconfigure [protected]

Reconfigure occurred.

Definition at line 67 of file EventSelector.h.

Referenced by firstOfNextStream(), next(), and reinitialize().

StreamSpecs EventSelector::m_streamSpecs [protected]

Input stream specifiers (for job options).

Definition at line 69 of file EventSelector.h.

Referenced by initialize(), and reinitialize().

StreamSpecs EventSelector::m_streamSpecsLast [protected]

Input stream specifiers (last used).

Definition at line 71 of file EventSelector.h.

Referenced by initialize(), and reinitialize().

Streams EventSelector::m_streams [protected]

Input streams.

Definition at line 73 of file EventSelector.h.

int EventSelector::m_streamCount [protected]

Input stream counter (0..oo, monotonely increasing).

Definition at line 75 of file EventSelector.h.

int EventSelector::m_firstEvent [protected]

First event to be processed.

Definition at line 77 of file EventSelector.h.

Referenced by createContext(), and rewind().

int EventSelector::m_evtMax [protected]

Maximum number of events to be processed.

Definition at line 79 of file EventSelector.h.

Referenced by initialize().

int EventSelector::m_evtPrintFrequency [protected]

Printout frequency.

Definition at line 81 of file EventSelector.h.

Referenced by printEvtInfo().

std::string EventSelector::m_streamManager [protected]

Definition at line 83 of file EventSelector.h.

Referenced by initialize().


The documentation for this class was generated from the following files:
Generated at Fri Jul 18 12:07:13 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004