The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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::string > StreamSpecs
 
typedef std::vector< Gaudi::Property< std::string > > Properties
 
- Public Types inherited from extends< Service, IEvtSelector >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- 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
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

StatusCode initialize () override
 IService implementation: Db event selector override.
 
StatusCode finalize () override
 IService implementation: Service finalization.
 
StatusCode reinitialize () override
 Service override: Reinitialize service.
 
StatusCode createContext (Context *&refpCtxt) const override
 Create a new event loop context.
 
StatusCode next (Context &refCtxt) const override
 Get next iteration item from the event loop context.
 
StatusCode next (Context &refCtxt, int jump) const override
 Get next iteration item from the event loop context, but skip jump elements.
 
StatusCode previous (Context &refCtxt) const override
 Get previous iteration item from the event loop context.
 
StatusCode previous (Context &refCtxt, int jump) const override
 Get previous iteration item from the event loop context, but skip jump elements.
 
StatusCode rewind (Context &refCtxt) const override
 Rewind the dataset.
 
StatusCode createAddress (const Context &refCtxt, IOpaqueAddress *&refpAddr) const override
 Create new Opaque address corresponding to the current record.
 
StatusCode releaseContext (Context *&refCtxt) const override
 Release existing event iteration context.
 
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.
 
StatusCode last (Context &c) const override
 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.
 
- Public Member Functions inherited from extends< Service, IEvtSelector >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
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.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
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.
 
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.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Public Attributes

long int m_streamID
 

Protected Member Functions

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

Protected Attributes

SmartIF< IIncidentSvcm_incidentSvc = nullptr
 Reference to the indicent service.
 
SmartIF< IToolSvcm_toolSvc = nullptr
 
IDataStreamToolm_streamtool = nullptr
 
bool m_reconfigure = false
 Reconfigure occurred.
 
StreamSpecs m_streamSpecsLast
 Input stream specifiers (last used)
 
Streams m_streams
 Input streams.
 
int m_streamCount = 0
 Input stream counter (0..oo, monotonely increasing)
 
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::string > m_streamManager { this, "StreamManager", "DataStreamTool", "" }
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
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.
 

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

Member Typedef Documentation

◆ Properties

typedef std::vector<Gaudi::Property<std::string> > EventSelector::Properties

Definition at line 45 of file EventSelector.h.

◆ Streams

Definition at line 43 of file EventSelector.h.

◆ StreamSpecs

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

Definition at line 44 of file EventSelector.h.

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

279 {
280 auto cpIt = dynamic_cast<const EvtSelectorContext*>( &refCtxt );
281 auto pIt = const_cast<EvtSelectorContext*>( cpIt );
282 refpAddr = nullptr;
283 StatusCode sc = StatusCode::FAILURE;
284 if ( pIt ) {
285 auto s = m_streamtool->getStream( pIt->ID() );
286 auto it = pIt->context();
287 auto sel = s->selector();
288 if ( it && sel ) {
289 IOpaqueAddress* pAddr = nullptr;
290 sc = sel->createAddress( *it, pAddr );
291 if ( sc.isSuccess() ) { refpAddr = pAddr; }
292 pIt->set( it, pAddr );
293 }
294 }
295 return sc;
296}
IDataStreamTool * m_streamtool
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto FAILURE
Definition StatusCode.h:100

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

159 {
160 // Max event is zero. Return begin = end
161 refpCtxt = nullptr;
162 if ( m_firstEvent < 0 ) {
163 error() << "First Event = " << m_firstEvent << " not valid" << endmsg;
164 error() << "It should be > 0 " << endmsg;
165 return StatusCode::FAILURE; // if failure => iterators = end();
166 }
167 auto ctxt = new EvtSelectorContext( this );
168 refpCtxt = ctxt;
169 ctxt->set( 0, -1, 0, 0 );
170 firstOfNextStream( true, *ctxt ).ignore();
171 long nskip = m_firstEvent;
172 while ( --nskip > 0 ) {
173 StatusCode sc = next( *refpCtxt );
174 if ( sc.isFailure() ) {
175 error() << " createContext() failed to start with event number " << m_firstEvent << endmsg;
176 if ( sc = releaseContext( refpCtxt ); !sc ) return sc;
177 refpCtxt = nullptr;
178 return StatusCode::FAILURE;
179 }
180 }
181 return StatusCode::SUCCESS;
182}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
StatusCode firstOfNextStream(bool shutDown, EvtSelectorContext &it) const
Retrieve first entry of the next data stream.
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
Gaudi::Property< int > m_firstEvent
bool isFailure() const
Definition StatusCode.h:129
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ finalize()

StatusCode EventSelector::finalize ( )
override

IService implementation: Service finalization.

Definition at line 387 of file EventSelector.cpp.

387 {
388
389 if ( msgLevel( MSG::DEBUG ) ) { debug() << "finalize()" << endmsg; }
390
391 m_incidentSvc = nullptr;
392
393 if ( m_streamtool ) {
394 if ( m_toolSvc ) {
395 m_toolSvc->releaseTool( m_streamtool ).ignore();
396 } else {
397 // It should not be possible to get here
398 m_streamtool->release();
399 }
400 m_streamtool = nullptr;
401 }
402 m_toolSvc.reset();
403
404 return Service::finalize();
405}
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the indicent service.
SmartIF< IToolSvc > m_toolSvc
StatusCode finalize() override
Definition Service.cpp:223
@ DEBUG
Definition IMessageSvc.h:22

◆ firstOfNextStream()

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

Retrieve first entry of the next data stream.

Definition at line 51 of file EventSelector.cpp.

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

◆ initialize()

StatusCode EventSelector::initialize ( )
override

IService implementation: Db event selector override.

Definition at line 314 of file EventSelector.cpp.

314 {
315 // Initialize base class
316 StatusCode status = Service::initialize();
317 if ( !status.isSuccess() ) {
318 error() << "Error initializing base class Service!" << endmsg;
319 return status;
320 }
321 // Get the references to the services that are needed by the ApplicationMgr itself
322 m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
323 if ( !m_incidentSvc ) {
324 fatal() << "Error retrieving IncidentSvc." << endmsg;
325 return StatusCode::FAILURE;
326 }
327 if ( m_evtMax != INT_MAX ) {
328 error() << "EvtMax is an obsolete property of the event selector." << endmsg;
329 error() << "Please set \"ApplicationMgr.EvtMax = " << m_evtMax << ";\" to process the requested number of events."
330 << endmsg;
331 return StatusCode::FAILURE;
332 }
333
334 m_toolSvc = serviceLocator()->service( "ToolSvc" );
335 if ( !m_toolSvc ) {
336 error() << " Could not locate the Tool Service! " << endmsg;
337 return StatusCode::FAILURE;
338 }
339 // make sure we finalize _prior_ to ToolSvc... we are about to get a
340 // a pointer to a tool which gets finalized and released by the ToolSvc
341 // during ToolSvc::finalize, and we don't want dangling pointers...
342 SmartIF<ISvcManager> mgr( serviceLocator() );
343 auto prio = mgr->getPriority( "ToolSvc" );
344 mgr->setPriority( name(), prio + 1 ).ignore();
345
346 status = m_toolSvc->retrieveTool( m_streamManager, m_streamtool, this );
347
348 if ( status.isFailure() ) {
349 error() << "Error initializing " << m_streamManager << endmsg;
350 return status;
351 }
352
353 status = m_streamtool->clear();
354 if ( status.isFailure() ) {
355 // Message already printed by the tool
356 return status;
357 }
358
359 status = m_streamtool->addStreams( m_streamSpecs );
360
362
363 m_streamID = 0;
364
365 return status;
366}
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
StreamSpecs m_streamSpecsLast
Input stream specifiers (last used)
Gaudi::Property< int > m_evtMax
Gaudi::Property< StreamSpecs > m_streamSpecs
long int m_streamID
Gaudi::Property< std::string > m_streamManager
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition Service.cpp:336
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
StatusCode initialize() override
Definition Service.cpp:118

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

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

◆ lastOfPreviousStream()

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

Retrieve last entry of the previous data stream.

Definition at line 109 of file EventSelector.cpp.

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

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

185{ 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 188 of file EventSelector.cpp.

188 {
189 EvtSelectorContext* pIt = dynamic_cast<EvtSelectorContext*>( &refCtxt );
190 if ( pIt ) {
191 if ( pIt->ID() != -1 ) {
192 const EventSelectorDataStream* s = m_streamtool->getStream( pIt->ID() );
193 Context* it = pIt->context();
194 IEvtSelector* sel = s->selector();
195 if ( it && sel ) { // First exploit the current stream
196 StatusCode sc = sel->next( *it ); // This stream is empty: advance to the next stream
197 if ( !sc.isSuccess() ) {
198 m_incidentSvc->fireIncident( Incident( s->dbName(), IncidentType::EndInputFile ) );
199 sc = firstOfNextStream( true, *pIt );
200 if ( sc.isSuccess() ) sc = next( *pIt );
201 } else {
202 pIt->increaseCounters( false );
203 pIt->set( it, 0 );
204 printEvtInfo( pIt );
205 }
206 return sc;
207 } else if ( m_reconfigure ) {
208 StatusCode sc = firstOfNextStream( false, *pIt );
209 printEvtInfo( pIt );
210 return sc;
211 }
212 } else if ( m_reconfigure ) {
213 StatusCode sc = firstOfNextStream( false, *pIt );
214 printEvtInfo( pIt );
215 return sc;
216 }
217 pIt->increaseCounters( false );
218 }
219 printEvtInfo( pIt );
220 return StatusCode::FAILURE;
221}
virtual void printEvtInfo(const EvtSelectorContext *iter) const
Progress report.
virtual IDataStreamTool::size_type ID() const
Stream identifier.
IEvtSelector::Context * context() const
Access "real" iterator.
void set(const IEvtSelector *sel, IDataStreamTool::size_type id, IEvtSelector::Context *it, IOpaqueAddress *pA)
Set the address of the iterator.
IDataStreamTool::size_type increaseCounters(bool reset=false)
Increase counters.

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

224{ 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 227 of file EventSelector.cpp.

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

◆ printEvtInfo()

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

Progress report.

Definition at line 33 of file EventSelector.cpp.

33 {
34 if ( iter ) {
35 long count = iter->numEvent();
36 // Print an message every m_evtPrintFrequency events
37 if ( 0 == iter->context() ) {
38 info() << "End of event input reached." << endmsg;
39 } else if ( iter->numStreamEvent() == -1 ) {
40 // Intial value for this stream
41 } else if ( m_evtPrintFrequency > 0 && ( count % m_evtPrintFrequency == 0 ) ) {
42 always() << "Reading Event record " << count + 1 << ". Record number within stream " << iter->ID() + 1 << ": "
43 << iter->numStreamEvent() + 1 << endmsg;
44 }
45 } else {
46 info() << "End of event input reached." << endmsg;
47 }
48}
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
Gaudi::Property< int > m_evtPrintFrequency
long numEvent() const
Access counter.
long numStreamEvent() const
Access counter within stream.

◆ reinitialize()

StatusCode EventSelector::reinitialize ( )
override

Service override: Reinitialize service.

Definition at line 369 of file EventSelector.cpp.

369 {
371 error() << "Cannot reinitialize: service not in state initialized" << endmsg;
372 return StatusCode::FAILURE;
373 }
374
376 StatusCode status = m_streamtool->clear();
377 if ( status.isFailure() ) return status;
379 m_reconfigure = true;
380 return m_streamtool->addStreams( m_streamSpecs );
381 }
382
383 return StatusCode::SUCCESS;
384}
Gaudi::StateMachine::State FSMState() const override
Definition Service.h:55

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

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

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

28 {
30}

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

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

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

69{ this, "EvtMax", INT_MAX, "maximum number of events to be processed" };

◆ m_evtPrintFrequency

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

Definition at line 70 of file EventSelector.h.

70{ this, "PrintFreq", 10, "printout frequency" };

◆ m_firstEvent

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

Definition at line 68 of file EventSelector.h.

68{ this, "FirstEvent", 0, "first event to be processed" };

◆ m_incidentSvc

SmartIF<IIncidentSvc> EventSelector::m_incidentSvc = nullptr
protected

Reference to the indicent service.

Definition at line 51 of file EventSelector.h.

◆ m_reconfigure

bool EventSelector::m_reconfigure = false
protected

Reconfigure occurred.

Definition at line 58 of file EventSelector.h.

◆ m_streamCount

int EventSelector::m_streamCount = 0
protected

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

Definition at line 64 of file EventSelector.h.

◆ m_streamID

long int EventSelector::m_streamID

Definition at line 47 of file EventSelector.h.

◆ m_streamManager

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

Definition at line 71 of file EventSelector.h.

71{ this, "StreamManager", "DataStreamTool", "" };

◆ m_streams

Streams EventSelector::m_streams
protected

Input streams.

Definition at line 62 of file EventSelector.h.

◆ m_streamSpecs

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

Definition at line 67 of file EventSelector.h.

67{ this, "Input", {}, "input stream specifiers (for job options)" };

◆ m_streamSpecsLast

StreamSpecs EventSelector::m_streamSpecsLast
protected

Input stream specifiers (last used)

Definition at line 60 of file EventSelector.h.

◆ m_streamtool

IDataStreamTool* EventSelector::m_streamtool = nullptr
protected

Definition at line 55 of file EventSelector.h.

◆ m_toolSvc

SmartIF<IToolSvc> EventSelector::m_toolSvc = nullptr
protected

Definition at line 53 of file EventSelector.h.


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