The Gaudi Framework  master (37c0b60a)
EventSelector Class Reference

Definition of class EventSelector. More...

#include </builds/gaudi/Gaudi/GaudiCoreSvc/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...
 
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 >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
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 std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 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...
 

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
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- 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" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] 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()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
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 63 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 281 of file EventSelector.cpp.

281  {
282  auto cpIt = dynamic_cast<const EvtSelectorContext*>( &refCtxt );
283  auto pIt = const_cast<EvtSelectorContext*>( cpIt );
284  refpAddr = nullptr;
286  if ( pIt ) {
287  auto s = m_streamtool->getStream( pIt->ID() );
288  auto it = pIt->context();
289  auto sel = s->selector();
290  if ( it && sel ) {
291  IOpaqueAddress* pAddr = nullptr;
292  sc = sel->createAddress( *it, pAddr );
293  if ( sc.isSuccess() ) { refpAddr = pAddr; }
294  pIt->set( it, pAddr );
295  }
296  }
297  return sc;
298 }

◆ 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 161 of file EventSelector.cpp.

161  {
162  // Max event is zero. Return begin = end
163  refpCtxt = nullptr;
164  if ( m_firstEvent < 0 ) {
165  error() << "First Event = " << m_firstEvent << " not valid" << endmsg;
166  error() << "It should be > 0 " << endmsg;
167  return StatusCode::FAILURE; // if failure => iterators = end();
168  }
169  auto ctxt = new EvtSelectorContext( this );
170  refpCtxt = ctxt;
171  ctxt->set( 0, -1, 0, 0 );
172  firstOfNextStream( true, *ctxt ).ignore();
173  long nskip = m_firstEvent;
174  while ( --nskip > 0 ) {
175  StatusCode sc = next( *refpCtxt );
176  if ( sc.isFailure() ) {
177  error() << " createContext() failed to start with event number " << m_firstEvent << endmsg;
178  if ( sc = releaseContext( refpCtxt ); !sc ) return sc;
179  refpCtxt = nullptr;
180  return StatusCode::FAILURE;
181  }
182  }
183  return StatusCode::SUCCESS;
184 }

◆ finalize()

StatusCode EventSelector::finalize ( )
override

IService implementation: Service finalization.

Definition at line 389 of file EventSelector.cpp.

389  {
390 
391  if ( msgLevel( MSG::DEBUG ) ) { debug() << "finalize()" << endmsg; }
392 
393  m_incidentSvc = nullptr;
394 
395  if ( m_streamtool ) {
396  if ( m_toolSvc ) {
397  m_toolSvc->releaseTool( m_streamtool ).ignore();
398  } else {
399  // It should not be possible to get here
401  }
402  m_streamtool = nullptr;
403  }
404  m_toolSvc.reset();
405 
406  return Service::finalize();
407 }

◆ firstOfNextStream()

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

Retrieve first entry of the next data stream.

Definition at line 53 of file EventSelector.cpp.

53  {
55  IDataStreamTool::size_type iter_id = ( m_reconfigure ) ? 0 : iter.ID() + 1;
56  if ( m_reconfigure ) const_cast<EventSelector*>( this )->m_reconfigure = false;
57  if ( shutDown ) {
58  if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() ) {
59  const EventSelectorDataStream* s = m_streamtool->getStream( iter.ID() );
60  if ( s->isInitialized() ) {
61  EventSelector* thisPtr = const_cast<EventSelector*>( this );
62  if ( s->selector() && iter.context() ) {
63  Context* ctxt = iter.context();
64  s->selector()->releaseContext( ctxt ).ignore();
65  iter.set( 0, 0 );
66  }
67  status = thisPtr->m_streamtool->finalizeStream( const_cast<EventSelectorDataStream*>( s ) );
68  iter.set( 0, 0 );
69  }
70  }
71  }
72 
73  const EventSelectorDataStream* s = nullptr;
74  status = m_streamtool->getNextStream( s, iter_id );
75 
76  if ( status.isSuccess() ) {
77 
78  if ( s ) {
79  if ( !s->isInitialized() ) {
80  EventSelector* thisPtr = const_cast<EventSelector*>( this );
81  status = thisPtr->m_streamtool->initializeStream( const_cast<EventSelectorDataStream*>( s ) );
82  }
83 
84  if ( status.isSuccess() ) {
85  const IEvtSelector* sel = s->selector();
86  if ( sel ) {
87  Context* ctxt = nullptr;
88  status = sel->createContext( ctxt );
89  if ( status.isSuccess() ) {
90  status = sel->resetCriteria( s->criteria(), *ctxt );
91  if ( status.isSuccess() ) {
92  iter.set( this, iter_id, ctxt, 0 );
93  info() << *s << endmsg;
94  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::BeginInputFile ) );
95  return StatusCode::SUCCESS;
96  }
97  }
98  delete ctxt;
99  }
100  }
101  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::FailInputFile ) );
102  }
103  }
104 
105  iter.set( this, -1, 0, 0 );
106  // m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::FailInputFile));
107  return StatusCode::FAILURE;
108 }

◆ initialize()

StatusCode EventSelector::initialize ( )
override

IService implementation: Db event selector override.

Definition at line 316 of file EventSelector.cpp.

316  {
317  // Initialize base class
318  StatusCode status = Service::initialize();
319  if ( !status.isSuccess() ) {
320  error() << "Error initializing base class Service!" << endmsg;
321  return status;
322  }
323  // Get the references to the services that are needed by the ApplicationMgr itself
324  m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
325  if ( !m_incidentSvc ) {
326  fatal() << "Error retrieving IncidentSvc." << endmsg;
327  return StatusCode::FAILURE;
328  }
329  if ( m_evtMax != INT_MAX ) {
330  error() << "EvtMax is an obsolete property of the event selector." << endmsg;
331  error() << "Please set \"ApplicationMgr.EvtMax = " << m_evtMax << ";\" to process the requested number of events."
332  << endmsg;
333  return StatusCode::FAILURE;
334  }
335 
336  m_toolSvc = serviceLocator()->service( "ToolSvc" );
337  if ( !m_toolSvc ) {
338  error() << " Could not locate the Tool Service! " << endmsg;
339  return StatusCode::FAILURE;
340  }
341  // make sure we finalize _prior_ to ToolSvc... we are about to get a
342  // a pointer to a tool which gets finalized and released by the ToolSvc
343  // during ToolSvc::finalize, and we don't want dangling pointers...
345  auto prio = mgr->getPriority( "ToolSvc" );
346  mgr->setPriority( name(), prio + 1 ).ignore();
347 
348  status = m_toolSvc->retrieveTool( m_streamManager, m_streamtool, this );
349 
350  if ( status.isFailure() ) {
351  error() << "Error initializing " << m_streamManager << endmsg;
352  return status;
353  }
354 
355  status = m_streamtool->clear();
356  if ( status.isFailure() ) {
357  // Message already printed by the tool
358  return status;
359  }
360 
362 
364 
365  m_streamID = 0;
366 
367  return status;
368 }

◆ 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 258 of file EventSelector.cpp.

258  {
259  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
260  if ( pIt ) {}
261  return StatusCode::FAILURE;
262 }

◆ lastOfPreviousStream()

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

Retrieve last entry of the previous data stream.

Definition at line 111 of file EventSelector.cpp.

111  {
113  if ( shutDown ) {
114  if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() ) {
115  const EventSelectorDataStream* s = m_streamtool->getStream( iter.ID() );
116  if ( s->isInitialized() ) {
117  EventSelector* thisPtr = const_cast<EventSelector*>( this );
118  if ( s->selector() && iter.context() ) {
119  Context* ctxt = iter.context();
120  if ( status = s->selector()->releaseContext( ctxt ); !status ) return status;
121  iter.set( 0, 0 );
122  }
123  status = thisPtr->m_streamtool->finalizeStream( const_cast<EventSelectorDataStream*>( s ) );
124  iter.set( 0, 0 );
125  }
126  }
127  }
128 
129  IDataStreamTool::size_type iter_id = iter.ID() - 1;
130  const EventSelectorDataStream* s = nullptr;
131  status = m_streamtool->getPreviousStream( s, iter_id );
132 
133  if ( status.isSuccess() ) {
134 
135  if ( !s->isInitialized() ) {
136  EventSelector* thisPtr = const_cast<EventSelector*>( this );
137  status = thisPtr->m_streamtool->initializeStream( const_cast<EventSelectorDataStream*>( s ) );
138  }
139  if ( status.isSuccess() ) {
140  const IEvtSelector* sel = s->selector();
141  if ( sel ) {
142  Context* ctxt = nullptr;
143  status = sel->createContext( ctxt );
144  if ( status.isSuccess() ) {
145  status = sel->resetCriteria( s->criteria(), *ctxt );
146  if ( status.isSuccess() ) {
147  iter.set( this, iter_id, ctxt, 0 );
148  info() << *s << endmsg;
149  return StatusCode::SUCCESS;
150  }
151  }
152  }
153  }
154  }
155 
156  iter.set( this, -1, 0, 0 );
157  return StatusCode::FAILURE;
158 }

◆ 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 187 of file EventSelector.cpp.

187 { return next( refCtxt, 1 ); }

◆ 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 190 of file EventSelector.cpp.

190  {
191  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
192  if ( pIt ) {
193  if ( pIt->ID() != -1 ) {
194  const EventSelectorDataStream* s = m_streamtool->getStream( pIt->ID() );
195  Context* it = pIt->context();
196  IEvtSelector* sel = s->selector();
197  if ( it && sel ) { // First exploit the current stream
198  StatusCode sc = sel->next( *it ); // This stream is empty: advance to the next stream
199  if ( !sc.isSuccess() ) {
200  m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::EndInputFile ) );
201  sc = firstOfNextStream( true, *pIt );
202  if ( sc.isSuccess() ) sc = next( *pIt );
203  } else {
204  pIt->increaseCounters( false );
205  pIt->set( it, 0 );
206  printEvtInfo( pIt );
207  }
208  return sc;
209  } else if ( m_reconfigure ) {
210  StatusCode sc = firstOfNextStream( false, *pIt );
211  printEvtInfo( pIt );
212  return sc;
213  }
214  } else if ( m_reconfigure ) {
215  StatusCode sc = firstOfNextStream( false, *pIt );
216  printEvtInfo( pIt );
217  return sc;
218  }
219  pIt->increaseCounters( false );
220  }
221  printEvtInfo( pIt );
222  return StatusCode::FAILURE;
223 }

◆ 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 226 of file EventSelector.cpp.

226 { return previous( refCtxt, 1 ); }

◆ 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 229 of file EventSelector.cpp.

229  {
230  EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
231  if ( pIt && jump > 0 ) {
233  for ( int i = 0; i < jump && sc.isSuccess(); ++i ) {
234  const EventSelectorDataStream* s = m_streamtool->getStream( pIt->ID() );
235  Context* it = pIt->context();
236  IEvtSelector* sel = s->selector();
237  if ( it && sel ) { // First exploit the current stream
238  // This stream is empty: advance to the next stream
239  sc = sel->previous( *it ); // This stream is empty: advance to the next stream
240  if ( !sc.isSuccess() ) {
241  sc = lastOfPreviousStream( true, *pIt );
242  } else {
243  pIt->increaseCounters( false );
244  pIt->set( it, 0 );
245  }
246  printEvtInfo( pIt );
247  if ( !sc.isSuccess() ) { return sc; }
248  }
249  pIt->increaseCounters( false );
250  }
251  return sc;
252  }
253  printEvtInfo( pIt );
254  return StatusCode::FAILURE;
255 }

◆ printEvtInfo()

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

Progress report.

Definition at line 35 of file EventSelector.cpp.

35  {
36  if ( iter ) {
37  long count = iter->numEvent();
38  // Print an message every m_evtPrintFrequency events
39  if ( 0 == iter->context() ) {
40  info() << "End of event input reached." << endmsg;
41  } else if ( iter->numStreamEvent() == -1 ) {
42  // Intial value for this stream
43  } else if ( m_evtPrintFrequency > 0 && ( count % m_evtPrintFrequency == 0 ) ) {
44  always() << "Reading Event record " << count + 1 << ". Record number within stream " << iter->ID() + 1 << ": "
45  << iter->numStreamEvent() + 1 << endmsg;
46  }
47  } else {
48  info() << "End of event input reached." << endmsg;
49  }
50 }

◆ reinitialize()

StatusCode EventSelector::reinitialize ( )
override

Service override: Reinitialize service.

Definition at line 371 of file EventSelector.cpp.

371  {
373  error() << "Cannot reinitialize: service not in state initialized" << endmsg;
374  return StatusCode::FAILURE;
375  }
376 
377  if ( m_streamSpecsLast != m_streamSpecs ) {
378  StatusCode status = m_streamtool->clear();
379  if ( status.isFailure() ) return status;
381  m_reconfigure = true;
383  }
384 
385  return StatusCode::SUCCESS;
386 }

◆ 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 301 of file EventSelector.cpp.

301  {
303  auto cpIt = dynamic_cast<const EvtSelectorContext*>( refCtxt );
304  std::unique_ptr<EvtSelectorContext> pIt{ const_cast<EvtSelectorContext*>( cpIt ) };
305  if ( pIt && pIt->ID() >= 0 && pIt->ID() < (long)m_streamtool->size() ) {
306  const auto s = m_streamtool->getStream( pIt->ID() );
307  auto it = pIt->context();
308  auto sel = s->selector();
309  if ( it && sel ) { sc = sel->releaseContext( it ); }
310  }
311  refCtxt = nullptr; // std::unique_ptr always deletes object, so always set to NULL
312  return sc;
313 }

◆ 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 30 of file EventSelector.cpp.

30  {
31  return StatusCode::FAILURE;
32 }

◆ 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 265 of file EventSelector.cpp.

265  {
267  EvtSelectorContext* ctxt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
268  if ( ctxt ) {
269  ctxt->set( 0, -1, 0, 0 );
270  if ( sc = firstOfNextStream( true, *ctxt ); !sc ) return sc;
271  long nskip = m_firstEvent;
272  while ( --nskip > 0 ) {
273  sc = next( *ctxt );
274  if ( sc.isFailure() ) { error() << "rewind() failed to start with event number " << m_firstEvent << endmsg; }
275  }
276  }
277  return sc;
278 }

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 91 of file EventSelector.h.

◆ m_evtPrintFrequency

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

Definition at line 92 of file EventSelector.h.

◆ m_firstEvent

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

Definition at line 90 of file EventSelector.h.

◆ m_incidentSvc

SmartIF<IIncidentSvc> EventSelector::m_incidentSvc = nullptr
protected

Reference to the indicent service.

Definition at line 73 of file EventSelector.h.

◆ m_reconfigure

bool EventSelector::m_reconfigure = false
protected

Reconfigure occurred.

Definition at line 80 of file EventSelector.h.

◆ m_streamCount

int EventSelector::m_streamCount = 0
protected

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

Definition at line 86 of file EventSelector.h.

◆ m_streamID

long int EventSelector::m_streamID

Definition at line 69 of file EventSelector.h.

◆ m_streamManager

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

Definition at line 93 of file EventSelector.h.

◆ m_streams

Streams EventSelector::m_streams
protected

Input streams.

Definition at line 84 of file EventSelector.h.

◆ m_streamSpecs

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

Definition at line 89 of file EventSelector.h.

◆ m_streamSpecsLast

StreamSpecs EventSelector::m_streamSpecsLast
protected

Input stream specifiers (last used)

Definition at line 82 of file EventSelector.h.

◆ m_streamtool

IDataStreamTool* EventSelector::m_streamtool = nullptr
protected

Definition at line 77 of file EventSelector.h.

◆ m_toolSvc

SmartIF<IToolSvc> EventSelector::m_toolSvc = nullptr
protected

Definition at line 75 of file EventSelector.h.


The documentation for this class was generated from the following files:
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
IDataStreamTool::getStream
virtual EventSelectorDataStream * getStream(size_type)=0
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
EventSelector::firstOfNextStream
StatusCode firstOfNextStream(bool shutDown, EvtSelectorContext &it) const
Retrieve first entry of the next data stream.
Definition: EventSelector.cpp:53
IDataStreamTool::size
virtual size_type size()=0
EventSelector::lastOfPreviousStream
StatusCode lastOfPreviousStream(bool shutDown, EvtSelectorContext &it) const
Retrieve last entry of the previous data stream.
Definition: EventSelector.cpp:111
EventSelector::m_firstEvent
Gaudi::Property< int > m_firstEvent
Definition: EventSelector.h:90
EventSelector::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Definition: EventSelector.h:75
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
EvtSelectorContext::increaseCounters
IDataStreamTool::size_type increaseCounters(bool reset=false)
Increase counters.
Definition: EventIterator.h:82
EventSelector::releaseContext
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
Definition: EventSelector.cpp:301
gaudirun.s
string s
Definition: gaudirun.py:346
IOpaqueAddress
Definition: IOpaqueAddress.h:33
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
IEvtSelector
Definition: IEvtSelector.h:28
EvtSelectorContext::context
IEvtSelector::Context * context() const
Access "real" iterator.
Definition: EventIterator.h:80
EventSelector::printEvtInfo
virtual void printEvtInfo(const EvtSelectorContext *iter) const
Progress report.
Definition: EventSelector.cpp:35
EvtSelectorContext::ID
virtual IDataStreamTool::size_type ID() const
Stream identifier.
Definition: EventIterator.h:99
EventSelector::next
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
Definition: EventSelector.cpp:187
IDataStreamTool::initializeStream
virtual StatusCode initializeStream(EventSelectorDataStream *)=0
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
EventSelector::previous
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.
Definition: EventSelector.cpp:226
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
EvtSelectorContext
Definition of class EventIterator.
Definition: EventIterator.h:42
EventSelector::m_streamtool
IDataStreamTool * m_streamtool
Definition: EventSelector.h:77
IDataStreamTool::clear
virtual StatusCode clear()=0
EvtSelectorContext::numEvent
long numEvent() const
Access counter.
Definition: EventIterator.h:101
EventSelector::m_evtPrintFrequency
Gaudi::Property< int > m_evtPrintFrequency
Definition: EventSelector.h:92
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
EvtSelectorContext::numStreamEvent
long numStreamEvent() const
Access counter within stream.
Definition: EventIterator.h:103
EventSelector::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
Definition: EventSelector.h:73
IDataStreamTool::getNextStream
virtual StatusCode getNextStream(const EventSelectorDataStream *&, size_type &)=0
SmartIF< ISvcManager >
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
EventSelector::m_evtMax
Gaudi::Property< int > m_evtMax
Definition: EventSelector.h:91
IOTest.sel
sel
Definition: IOTest.py:106
IDataStreamTool::finalizeStream
virtual StatusCode finalizeStream(EventSelectorDataStream *)=0
EventSelector::m_streamManager
Gaudi::Property< std::string > m_streamManager
Definition: EventSelector.h:93
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
IDataStreamTool::getPreviousStream
virtual StatusCode getPreviousStream(const EventSelectorDataStream *&, size_type &)=0
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
IDataStreamTool::size_type
long size_type
Definition: IDataStreamTool.h:38
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
EventSelector::m_streamID
long int m_streamID
Definition: EventSelector.h:69
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
EventSelector::m_streamSpecs
Gaudi::Property< StreamSpecs > m_streamSpecs
Definition: EventSelector.h:89
EventSelectorDataStream
Definition of class EventSelectorDataStream.
Definition: EventSelectorDataStream.h:55
EventSelector::m_reconfigure
bool m_reconfigure
Reconfigure occurred.
Definition: EventSelector.h:80
std::count
T count(T... args)
EventSelector::m_streamSpecsLast
StreamSpecs m_streamSpecsLast
Input stream specifiers (last used)
Definition: EventSelector.h:82
EvtSelectorContext::set
void set(const IEvtSelector *sel, IDataStreamTool::size_type id, IEvtSelector::Context *it, IOpaqueAddress *pA)
Set the address of the iterator.
Definition: EventIterator.h:65
IDataStreamTool::addStreams
virtual StatusCode addStreams(const StreamSpecs &)=0
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
EventSelector
Definition of class EventSelector.
Definition: EventSelector.h:63
Incident
Definition: Incident.h:27
std::unique_ptr
STL class.
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335