The Gaudi Framework  v32r2 (46d42edc)
EventSelector Class Reference

Definition of class EventSelector. More...

#include <src/EventSelector/EventSelector.h>

Inheritance diagram for EventSelector:
Collaboration diagram for EventSelector:

Public Types

typedef std::vector< EventSelectorDataStream * > Streams
 
typedef std::vector< std::stringStreamSpecs
 
typedef std::vector< Gaudi::Property< std::string > > Properties
 
- Public Types inherited from extends< Service, IEvtSelector >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

StatusCode initialize () override
 IService implementation: Db event selector override. More...
 
StatusCode finalize () override
 IService implementation: Service finalization. More...
 
StatusCode reinitialize () override
 Service override: Reinitialize service. More...
 
StatusCode createContext (Context *&refpCtxt) const override
 Create a new event loop context. More...
 
StatusCode next (Context &refCtxt) const override
 Get next iteration item from the event loop context. More...
 
StatusCode next (Context &refCtxt, int jump) const override
 Get next iteration item from the event loop context, but skip jump elements. More...
 
StatusCode previous (Context &refCtxt) const override
 Get previous iteration item from the event loop context. More...
 
StatusCode previous (Context &refCtxt, int jump) const override
 Get previous iteration item from the event loop context, but skip jump elements. More...
 
StatusCode rewind (Context &refCtxt) const override
 Rewind the dataset. More...
 
StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&refpAddr) const override
 Create new Opaque address corresponding to the current record. More...
 
StatusCode releaseContext (Context *&refCtxt) const override
 Release existing event iteration context. More...
 
StatusCode resetCriteria (const std::string &cr, Context &c) const override
 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. More...
 
StatusCode last (Context &c) const override
 Access last item in the iteration. More...
 
StatusCode firstOfNextStream (bool shutDown, EvtSelectorContext &it) const
 Retrieve first entry of the next data stream. More...
 
StatusCode lastOfPreviousStream (bool shutDown, EvtSelectorContext &it) const
 Retrieve last entry of the previous data stream. More...
 
- Public Member Functions inherited from extends< Service, IEvtSelector >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Public Attributes

long int m_streamID
 

Protected Member Functions

virtual void printEvtInfo (const EvtSelectorContext *iter) const
 Progress report. More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

SmartIF< IIncidentSvcm_incidentSvc = nullptr
 Reference to the indicent service. More...
 
SmartIF< IToolSvcm_toolSvc = nullptr
 
IDataStreamToolm_streamtool = nullptr
 
bool m_reconfigure = false
 Reconfigure occurred. More...
 
StreamSpecs m_streamSpecsLast
 Input stream specifiers (last used) More...
 
Streams m_streams
 Input streams. More...
 
int m_streamCount = 0
 Input stream counter (0..oo, monotonely increasing) More...
 
Gaudi::Property< StreamSpecsm_streamSpecs {this, "Input", {}, "input stream specifiers (for job options)"}
 
Gaudi::Property< int > m_firstEvent {this, "FirstEvent", 0, "first event to be processed"}
 
Gaudi::Property< int > m_evtMax {this, "EvtMax", INT_MAX, "maximum number of events to be processed"}
 
Gaudi::Property< int > m_evtPrintFrequency {this, "PrintFreq", 10, "printout frequency"}
 
Gaudi::Property< std::stringm_streamManager {this, "StreamManager", "DataStreamTool", ""}
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, " unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

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 | +------—+-------------------------------------------—+---------—+ | 4/09/09 | Added firing incident on opening/ending file | R. Lambert | +------—+-------------------------------------------—+---------—+

Author
Markus Frank
R. Lambert
Version
1.0

Definition at line 53 of file EventSelector.h.

Member Typedef Documentation

◆ Properties

◆ Streams

◆ StreamSpecs

Member Function Documentation

◆ createAddress()

StatusCode EventSelector::createAddress ( const Context &  refCtxt,
IOpaqueAddress *&  refpAddr 
) const
override

Create new Opaque address corresponding to the current record.

Parameters
refCtxt[IN/OUT] Reference to the context
refpAddr[OUT] Reference to address pointer
Returns
StatusCode indicating success or failure

Definition at line 275 of file EventSelector.cpp.

275  {
276  auto cpIt = dynamic_cast<const EvtSelectorContext*>( &refCtxt );
277  auto pIt = const_cast<EvtSelectorContext*>( cpIt );
278  refpAddr = nullptr;
280  if ( pIt ) {
281  auto s = m_streamtool->getStream( pIt->ID() );
282  auto it = pIt->context();
283  auto sel = s->selector();
284  if ( it && sel ) {
285  IOpaqueAddress* pAddr = nullptr;
286  sc = sel->createAddress( *it, pAddr );
287  if ( sc.isSuccess() ) { refpAddr = pAddr; }
288  pIt->set( it, pAddr );
289  }
290  }
291  return sc;
292 }
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual EventSelectorDataStream * getStream(size_type)=0
bool isSuccess() const
Definition: StatusCode.h:267
string s
Definition: gaudirun.py:318
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Opaque address interface definition.

◆ createContext()

StatusCode EventSelector::createContext ( Context *&  refpCtxt) const
override

Create a new event loop context.

Parameters
refpCtxt[IN/OUT] Reference to pointer to store the context
Returns
StatusCode indicating success or failure

Definition at line 152 of file EventSelector.cpp.

152  {
153  // Max event is zero. Return begin = end
154  refpCtxt = nullptr;
155  if ( m_firstEvent < 0 ) {
156  error() << "First Event = " << m_firstEvent << " not valid" << endmsg;
157  error() << "It should be > 0 " << endmsg;
158  return StatusCode::FAILURE; // if failure => iterators = end();
159  }
160  auto ctxt = new EvtSelectorContext( this );
161  refpCtxt = ctxt;
162  ctxt->set( 0, -1, 0, 0 );
163  firstOfNextStream( true, *ctxt ).ignore();
164  long nskip = m_firstEvent;
165  while ( --nskip > 0 ) {
166  StatusCode sc = next( *refpCtxt );
167  if ( sc.isFailure() ) {
168  error() << " createContext() failed to start with event number " << m_firstEvent << endmsg;
169  releaseContext( refpCtxt );
170  refpCtxt = nullptr;
171  return StatusCode::FAILURE;
172  }
173  }
174  return StatusCode::SUCCESS;
175 }
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition of class EventIterator.
Definition: EventIterator.h:32
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode firstOfNextStream(bool shutDown, EvtSelectorContext &it) const
Retrieve first entry of the next data stream.
Gaudi::Property< int > m_firstEvent
Definition: EventSelector.h:80
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
constexpr static const auto FAILURE
Definition: StatusCode.h:86
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ finalize()

StatusCode EventSelector::finalize ( )
override

IService implementation: Service finalization.

Definition at line 383 of file EventSelector.cpp.

383  {
384 
385  if ( msgLevel( MSG::DEBUG ) ) { debug() << "finalize()" << endmsg; }
386 
387  m_incidentSvc = nullptr;
388 
389  if ( m_streamtool ) {
390  if ( m_toolSvc ) {
392  } else {
393  // It should not be possible to get here
395  }
396  m_streamtool = nullptr;
397  }
398  m_toolSvc.reset();
399 
400  return Service::finalize();
401 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
Definition: EventSelector.h:63
StatusCode finalize() override
Definition: Service.cpp:164
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< IToolSvc > m_toolSvc
Definition: EventSelector.h:65
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ firstOfNextStream()

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

Retrieve first entry of the next data stream.

Definition at line 43 of file EventSelector.cpp.

43  {
45  IDataStreamTool::size_type iter_id = ( m_reconfigure ) ? 0 : iter.ID() + 1;
46  if ( m_reconfigure ) const_cast<EventSelector*>( this )->m_reconfigure = false;
47  if ( shutDown ) {
48  if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() ) {
49  const EventSelectorDataStream* s = m_streamtool->getStream( iter.ID() );
50  if ( s->isInitialized() ) {
51  EventSelector* thisPtr = const_cast<EventSelector*>( this );
52  if ( s->selector() && iter.context() ) {
53  Context* ctxt = iter.context();
54  s->selector()->releaseContext( ctxt ).ignore();
55  iter.set( 0, 0 );
56  }
57  status = thisPtr->m_streamtool->finalizeStream( const_cast<EventSelectorDataStream*>( s ) );
58  iter.set( 0, 0 );
59  }
60  }
61  }
62 
63  const EventSelectorDataStream* s = nullptr;
64  status = m_streamtool->getNextStream( s, iter_id );
65 
66  if ( status.isSuccess() ) {
67 
68  if ( s ) {
69  if ( !s->isInitialized() ) {
70  EventSelector* thisPtr = const_cast<EventSelector*>( this );
71  status = thisPtr->m_streamtool->initializeStream( const_cast<EventSelectorDataStream*>( s ) );
72  }
73 
74  if ( status.isSuccess() ) {
75  const IEvtSelector* sel = s->selector();
76  if ( sel ) {
77  Context* ctxt = nullptr;
78  status = sel->createContext( ctxt );
79  if ( status.isSuccess() ) {
80  status = sel->resetCriteria( s->criteria(), *ctxt );
81  if ( status.isSuccess() ) {
82  iter.set( this, iter_id, ctxt, 0 );
83  info() << *s << endmsg;
84  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::BeginInputFile ) );
85  return StatusCode::SUCCESS;
86  }
87  }
88  delete ctxt;
89  }
90  }
91  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::FailInputFile ) );
92  }
93  }
94 
95  iter.set( this, -1, 0, 0 );
96  status.setChecked();
97  // m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::FailInputFile));
98  return StatusCode::FAILURE;
99 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
Definition: EventSelector.h:63
virtual StatusCode finalizeStream(EventSelectorDataStream *)=0
The Event Selector Interface.
Definition: IEvtSelector.h:18
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual EventSelectorDataStream * getStream(size_type)=0
bool isSuccess() const
Definition: StatusCode.h:267
Definition of class EventSelectorDataStream.
Base class for all Incidents (computing events).
Definition: Incident.h:17
string s
Definition: gaudirun.py:318
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Definition of class EventSelector.
Definition: EventSelector.h:53
virtual size_type size()=0
virtual StatusCode initializeStream(EventSelectorDataStream *)=0
bool m_reconfigure
Reconfigure occurred.
Definition: EventSelector.h:70
virtual StatusCode getNextStream(const EventSelectorDataStream *&, size_type &)=0
const StatusCode & setChecked(bool checked=true) const
Check/uncheck StatusCode.
Definition: StatusCode.h:143
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ initialize()

StatusCode EventSelector::initialize ( )
override

IService implementation: Db event selector override.

Definition at line 310 of file EventSelector.cpp.

310  {
311  // Initialize base class
312  StatusCode status = Service::initialize();
313  if ( !status.isSuccess() ) {
314  error() << "Error initializing base class Service!" << endmsg;
315  return status;
316  }
317  // Get the references to the services that are needed by the ApplicationMgr itself
318  m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
319  if ( !m_incidentSvc ) {
320  fatal() << "Error retrieving IncidentSvc." << endmsg;
321  return StatusCode::FAILURE;
322  }
323  if ( m_evtMax != INT_MAX ) {
324  error() << "EvtMax is an obsolete property of the event selector." << endmsg;
325  error() << "Please set \"ApplicationMgr.EvtMax = " << m_evtMax << ";\" to process the requested number of events."
326  << endmsg;
327  return StatusCode::FAILURE;
328  }
329 
330  m_toolSvc = serviceLocator()->service( "ToolSvc" );
331  if ( !m_toolSvc ) {
332  error() << " Could not locate the Tool Service! " << endmsg;
333  return StatusCode::FAILURE;
334  }
335  // make sure we finalize _prior_ to ToolSvc... we are about to get a
336  // a pointer to a tool which gets finalized and released by the ToolSvc
337  // during ToolSvc::finalize, and we don't want dangling pointers...
339  auto prio = mgr->getPriority( "ToolSvc" );
340  mgr->setPriority( name(), prio + 1 ).ignore();
341 
343 
344  if ( status.isFailure() ) {
345  error() << "Error initializing " << m_streamManager << endmsg;
346  return status;
347  }
348 
349  status = m_streamtool->clear();
350  if ( status.isFailure() ) {
351  // Message already printed by the tool
352  return status;
353  }
354 
356 
358 
359  m_streamID = 0;
360 
361  return status;
362 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
Definition: EventSelector.h:63
StatusCode initialize() override
Definition: Service.cpp:60
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
long int m_streamID
Definition: EventSelector.h:59
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.
Definition: IToolSvc.h:138
StreamSpecs m_streamSpecsLast
Input stream specifiers (last used)
Definition: EventSelector.h:72
virtual StatusCode addStreams(const StreamSpecs &)=0
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Gaudi::Property< std::string > m_streamManager
Definition: EventSelector.h:83
virtual StatusCode clear()=0
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Property< int > m_evtMax
Definition: EventSelector.h:81
Gaudi::Property< StreamSpecs > m_streamSpecs
Definition: EventSelector.h:79
bool isSuccess() const
Definition: StatusCode.h:267
SmartIF< IToolSvc > m_toolSvc
Definition: EventSelector.h:65
constexpr static const auto FAILURE
Definition: StatusCode.h:86
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ last()

StatusCode EventSelector::last ( Context &  c) const
override

Access last item in the iteration.

Parameters
cReference to the Context object.
Returns
StatusCode indicating success or failure

Definition at line 249 of file EventSelector.cpp.

249  {
250  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
251  if ( pIt ) {}
252  return StatusCode::FAILURE;
253 }
Definition of class EventIterator.
Definition: EventIterator.h:32
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ lastOfPreviousStream()

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

Retrieve last entry of the previous data stream.

Definition at line 102 of file EventSelector.cpp.

102  {
104  if ( shutDown ) {
105  if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() ) {
106  const EventSelectorDataStream* s = m_streamtool->getStream( iter.ID() );
107  if ( s->isInitialized() ) {
108  EventSelector* thisPtr = const_cast<EventSelector*>( this );
109  if ( s->selector() && iter.context() ) {
110  Context* ctxt = iter.context();
111  s->selector()->releaseContext( ctxt );
112  iter.set( 0, 0 );
113  }
114  status = thisPtr->m_streamtool->finalizeStream( const_cast<EventSelectorDataStream*>( s ) );
115  iter.set( 0, 0 );
116  }
117  }
118  }
119 
120  IDataStreamTool::size_type iter_id = iter.ID() - 1;
121  const EventSelectorDataStream* s = nullptr;
122  status = m_streamtool->getPreviousStream( s, iter_id );
123 
124  if ( status.isSuccess() ) {
125 
126  if ( !s->isInitialized() ) {
127  EventSelector* thisPtr = const_cast<EventSelector*>( this );
128  status = thisPtr->m_streamtool->initializeStream( const_cast<EventSelectorDataStream*>( s ) );
129  }
130  if ( status.isSuccess() ) {
131  const IEvtSelector* sel = s->selector();
132  if ( sel ) {
133  Context* ctxt = nullptr;
134  status = sel->createContext( ctxt );
135  if ( status.isSuccess() ) {
136  status = sel->resetCriteria( s->criteria(), *ctxt );
137  if ( status.isSuccess() ) {
138  iter.set( this, iter_id, ctxt, 0 );
139  info() << *s << endmsg;
140  return StatusCode::SUCCESS;
141  }
142  }
143  }
144  }
145  }
146 
147  iter.set( this, -1, 0, 0 );
148  return StatusCode::FAILURE;
149 }
virtual StatusCode finalizeStream(EventSelectorDataStream *)=0
The Event Selector Interface.
Definition: IEvtSelector.h:18
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual EventSelectorDataStream * getStream(size_type)=0
bool isSuccess() const
Definition: StatusCode.h:267
virtual StatusCode getPreviousStream(const EventSelectorDataStream *&, size_type &)=0
Definition of class EventSelectorDataStream.
string s
Definition: gaudirun.py:318
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Definition of class EventSelector.
Definition: EventSelector.h:53
virtual size_type size()=0
virtual StatusCode initializeStream(EventSelectorDataStream *)=0
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ next() [1/2]

StatusCode EventSelector::next ( Context &  refCtxt) const
override

Get next iteration item from the event loop context.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Definition at line 178 of file EventSelector.cpp.

178 { return next( refCtxt, 1 ); }
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.

◆ next() [2/2]

StatusCode EventSelector::next ( Context &  refCtxt,
int  jump 
) const
override

Get next iteration item from the event loop context, but skip jump elements.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Definition at line 181 of file EventSelector.cpp.

181  {
182  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
183  if ( pIt ) {
184  if ( pIt->ID() != -1 ) {
185  const EventSelectorDataStream* s = m_streamtool->getStream( pIt->ID() );
186  Context* it = pIt->context();
187  IEvtSelector* sel = s->selector();
188  if ( it && sel ) { // First exploit the current stream
189  StatusCode sc = sel->next( *it ); // This stream is empty: advance to the next stream
190  if ( !sc.isSuccess() ) {
191  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::EndInputFile ) );
192  sc = firstOfNextStream( true, *pIt );
193  if ( sc.isSuccess() ) sc = next( *pIt );
194  } else {
195  pIt->increaseCounters( false );
196  pIt->set( it, 0 );
197  printEvtInfo( pIt );
198  }
199  return sc;
200  } else if ( m_reconfigure ) {
201  StatusCode sc = firstOfNextStream( false, *pIt );
202  printEvtInfo( pIt );
203  return sc;
204  }
205  } else if ( m_reconfigure ) {
206  StatusCode sc = firstOfNextStream( false, *pIt );
207  printEvtInfo( pIt );
208  return sc;
209  }
210  pIt->increaseCounters( false );
211  }
212  printEvtInfo( pIt );
213  return StatusCode::FAILURE;
214 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
Definition: EventSelector.h:63
IEvtSelector::Context * context() const
Access "real" iterator.
Definition: EventIterator.h:70
The Event Selector Interface.
Definition: IEvtSelector.h:18
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
Definition of class EventIterator.
Definition: EventIterator.h:32
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual void printEvtInfo(const EvtSelectorContext *iter) const
Progress report.
virtual EventSelectorDataStream * getStream(size_type)=0
StatusCode firstOfNextStream(bool shutDown, EvtSelectorContext &it) const
Retrieve first entry of the next data stream.
bool isSuccess() const
Definition: StatusCode.h:267
void set(const IEvtSelector *sel, IDataStreamTool::size_type id, IEvtSelector::Context *it, IOpaqueAddress *pA)
Set the address of the iterator.
Definition: EventIterator.h:55
Definition of class EventSelectorDataStream.
Base class for all Incidents (computing events).
Definition: Incident.h:17
string s
Definition: gaudirun.py:318
constexpr static const auto FAILURE
Definition: StatusCode.h:86
virtual IDataStreamTool::size_type ID() const
Stream identifier.
Definition: EventIterator.h:89
IDataStreamTool::size_type increaseCounters(bool reset=false)
Increase counters.
Definition: EventIterator.h:72
bool m_reconfigure
Reconfigure occurred.
Definition: EventSelector.h:70

◆ previous() [1/2]

StatusCode EventSelector::previous ( Context &  refCtxt) const
override

Get previous iteration item from the event loop context.

Parameters
refCtxt[IN/OUT] Reference to the context
jump[IN] Number of events to be skipped
Returns
StatusCode indicating success or failure

Definition at line 217 of file EventSelector.cpp.

217 { return previous( refCtxt, 1 ); }
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.

◆ previous() [2/2]

StatusCode EventSelector::previous ( Context &  refCtxt,
int  jump 
) const
override

Get previous iteration item from the event loop context, but skip jump elements.

Parameters
refCtxt[IN/OUT] Reference to the context
jump[IN] Number of events to be skipped
Returns
StatusCode indicating success or failure

Definition at line 220 of file EventSelector.cpp.

220  {
221  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
222  if ( pIt && jump > 0 ) {
224  for ( int i = 0; i < jump && sc.isSuccess(); ++i ) {
225  const EventSelectorDataStream* s = m_streamtool->getStream( pIt->ID() );
226  Context* it = pIt->context();
227  IEvtSelector* sel = s->selector();
228  if ( it && sel ) { // First exploit the current stream
229  // This stream is empty: advance to the next stream
230  sc = sel->previous( *it ); // This stream is empty: advance to the next stream
231  if ( !sc.isSuccess() ) {
232  sc = lastOfPreviousStream( true, *pIt );
233  } else {
234  pIt->increaseCounters( false );
235  pIt->set( it, 0 );
236  }
237  printEvtInfo( pIt );
238  if ( !sc.isSuccess() ) { return sc; }
239  }
240  pIt->increaseCounters( false );
241  }
242  return sc;
243  }
244  printEvtInfo( pIt );
245  return StatusCode::FAILURE;
246 }
IEvtSelector::Context * context() const
Access "real" iterator.
Definition: EventIterator.h:70
The Event Selector Interface.
Definition: IEvtSelector.h:18
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Definition of class EventIterator.
Definition: EventIterator.h:32
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual void printEvtInfo(const EvtSelectorContext *iter) const
Progress report.
virtual EventSelectorDataStream * getStream(size_type)=0
bool isSuccess() const
Definition: StatusCode.h:267
StatusCode lastOfPreviousStream(bool shutDown, EvtSelectorContext &it) const
Retrieve last entry of the previous data stream.
void set(const IEvtSelector *sel, IDataStreamTool::size_type id, IEvtSelector::Context *it, IOpaqueAddress *pA)
Set the address of the iterator.
Definition: EventIterator.h:55
Definition of class EventSelectorDataStream.
string s
Definition: gaudirun.py:318
constexpr static const auto FAILURE
Definition: StatusCode.h:86
virtual IDataStreamTool::size_type ID() const
Stream identifier.
Definition: EventIterator.h:89
IDataStreamTool::size_type increaseCounters(bool reset=false)
Increase counters.
Definition: EventIterator.h:72

◆ printEvtInfo()

void EventSelector::printEvtInfo ( const EvtSelectorContext iter) const
protectedvirtual

Progress report.

Definition at line 25 of file EventSelector.cpp.

25  {
26  if ( iter ) {
27  long count = iter->numEvent();
28  // Print an message every m_evtPrintFrequency events
29  if ( 0 == iter->context() ) {
30  info() << "End of event input reached." << endmsg;
31  } else if ( iter->numStreamEvent() == -1 ) {
32  // Intial value for this stream
33  } else if ( m_evtPrintFrequency != -1 && ( count % m_evtPrintFrequency == 0 ) ) {
34  always() << "Reading Event record " << count + 1 << ". Record number within stream " << iter->ID() + 1 << ": "
35  << iter->numStreamEvent() + 1 << endmsg;
36  }
37  } else {
38  info() << "End of event input reached." << endmsg;
39  }
40 }
IEvtSelector::Context * context() const
Access "real" iterator.
Definition: EventIterator.h:70
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Gaudi::Property< int > m_evtPrintFrequency
Definition: EventSelector.h:82
long numEvent() const
Access counter.
Definition: EventIterator.h:91
T count(T... args)
virtual IDataStreamTool::size_type ID() const
Stream identifier.
Definition: EventIterator.h:89
long numStreamEvent() const
Access counter within stream.
Definition: EventIterator.h:93
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ reinitialize()

StatusCode EventSelector::reinitialize ( )
override

Service override: Reinitialize service.

Definition at line 365 of file EventSelector.cpp.

365  {
367  error() << "Cannot reinitialize: service not in state initialized" << endmsg;
368  return StatusCode::FAILURE;
369  }
370 
371  if ( m_streamSpecsLast != m_streamSpecs ) {
372  StatusCode status = m_streamtool->clear();
373  if ( status.isFailure() ) return status;
375  m_reconfigure = true;
377  }
378 
379  return StatusCode::SUCCESS;
380 }
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:52
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StreamSpecs m_streamSpecsLast
Input stream specifiers (last used)
Definition: EventSelector.h:72
virtual StatusCode addStreams(const StreamSpecs &)=0
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual StatusCode clear()=0
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Property< StreamSpecs > m_streamSpecs
Definition: EventSelector.h:79
constexpr static const auto FAILURE
Definition: StatusCode.h:86
bool isFailure() const
Definition: StatusCode.h:130
bool m_reconfigure
Reconfigure occurred.
Definition: EventSelector.h:70
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ releaseContext()

StatusCode EventSelector::releaseContext ( Context *&  refCtxt) const
override

Release existing event iteration context.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Definition at line 295 of file EventSelector.cpp.

295  {
297  auto cpIt = dynamic_cast<const EvtSelectorContext*>( refCtxt );
298  std::unique_ptr<EvtSelectorContext> pIt{const_cast<EvtSelectorContext*>( cpIt )};
299  if ( pIt && pIt->ID() >= 0 && pIt->ID() < (long)m_streamtool->size() ) {
300  const auto s = m_streamtool->getStream( pIt->ID() );
301  auto it = pIt->context();
302  auto sel = s->selector();
303  if ( it && sel ) { sc = sel->releaseContext( it ); }
304  }
305  refCtxt = nullptr; // std::unique_ptr always deletes object, so always set to NULL
306  return sc;
307 }
IDataStreamTool * m_streamtool
Definition: EventSelector.h:67
sel
Definition: IOTest.py:94
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual EventSelectorDataStream * getStream(size_type)=0
STL class.
string s
Definition: gaudirun.py:318
virtual size_type size()=0

◆ resetCriteria()

StatusCode EventSelector::resetCriteria ( const std::string cr,
Context &  c 
) const
override

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
crThe new criteria string.
cReference pointer to the Context object.
Returns
StatusCode indicating success or failure

Definition at line 20 of file EventSelector.cpp.

20  {
21  return StatusCode::FAILURE;
22 }
constexpr static const auto FAILURE
Definition: StatusCode.h:86

◆ rewind()

StatusCode EventSelector::rewind ( Context &  refCtxt) const
override

Rewind the dataset.

Parameters
refCtxt[IN/OUT] Reference to the context
Returns
StatusCode indicating success or failure

Definition at line 256 of file EventSelector.cpp.

256  {
257  EvtSelectorContext* ctxt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
258  if ( ctxt ) {
259  ctxt->set( 0, -1, 0, 0 );
260  firstOfNextStream( true, *ctxt );
261  long nskip = m_firstEvent;
262  while ( --nskip > 0 ) {
263  StatusCode sc = next( *ctxt );
264  if ( sc.isFailure() ) {
265  error() << "rewind() failed to start with event number " << m_firstEvent << endmsg;
266  return StatusCode::FAILURE;
267  }
268  }
269  return StatusCode::SUCCESS;
270  }
271  return StatusCode::FAILURE;
272 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition of class EventIterator.
Definition: EventIterator.h:32
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode firstOfNextStream(bool shutDown, EvtSelectorContext &it) const
Retrieve first entry of the next data stream.
Gaudi::Property< int > m_firstEvent
Definition: EventSelector.h:80
void set(const IEvtSelector *sel, IDataStreamTool::size_type id, IEvtSelector::Context *it, IOpaqueAddress *pA)
Set the address of the iterator.
Definition: EventIterator.h:55
constexpr static const auto FAILURE
Definition: StatusCode.h:86
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

Member Data Documentation

◆ m_evtMax

Gaudi::Property<int> EventSelector::m_evtMax {this, "EvtMax", INT_MAX, "maximum number of events to be processed"}
protected

Definition at line 81 of file EventSelector.h.

◆ m_evtPrintFrequency

Gaudi::Property<int> EventSelector::m_evtPrintFrequency {this, "PrintFreq", 10, "printout frequency"}
protected

Definition at line 82 of file EventSelector.h.

◆ m_firstEvent

Gaudi::Property<int> EventSelector::m_firstEvent {this, "FirstEvent", 0, "first event to be processed"}
protected

Definition at line 80 of file EventSelector.h.

◆ m_incidentSvc

SmartIF<IIncidentSvc> EventSelector::m_incidentSvc = nullptr
protected

Reference to the indicent service.

Definition at line 63 of file EventSelector.h.

◆ m_reconfigure

bool EventSelector::m_reconfigure = false
protected

Reconfigure occurred.

Definition at line 70 of file EventSelector.h.

◆ m_streamCount

int EventSelector::m_streamCount = 0
protected

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

Definition at line 76 of file EventSelector.h.

◆ m_streamID

long int EventSelector::m_streamID

Definition at line 59 of file EventSelector.h.

◆ m_streamManager

Gaudi::Property<std::string> EventSelector::m_streamManager {this, "StreamManager", "DataStreamTool", ""}
protected

Definition at line 83 of file EventSelector.h.

◆ m_streams

Streams EventSelector::m_streams
protected

Input streams.

Definition at line 74 of file EventSelector.h.

◆ m_streamSpecs

Gaudi::Property<StreamSpecs> EventSelector::m_streamSpecs {this, "Input", {}, "input stream specifiers (for job options)"}
protected

Definition at line 79 of file EventSelector.h.

◆ m_streamSpecsLast

StreamSpecs EventSelector::m_streamSpecsLast
protected

Input stream specifiers (last used)

Definition at line 72 of file EventSelector.h.

◆ m_streamtool

IDataStreamTool* EventSelector::m_streamtool = nullptr
protected

Definition at line 67 of file EventSelector.h.

◆ m_toolSvc

SmartIF<IToolSvc> EventSelector::m_toolSvc = nullptr
protected

Definition at line 65 of file EventSelector.h.


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