LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SIO::SIOReader Class Reference

Concrete implementation of LCWriter using SIO. More...

#include <SIOReader.h>

+ Inheritance diagram for SIO::SIOReader:

Public Member Functions

 SIOReader (int lcReaderFlag=0)
 Default constructor. More...
 
 SIOReader (const SIOReader &)=delete
 no copy constructor More...
 
SIOReaderoperator= (const SIOReader &)=delete
 no assignment operator More...
 
virtual ~SIOReader ()
 Destructor. More...
 
void open (const std::vector< std::string > &filenames) override
 Opens a list of files for reading (read-only). More...
 
void open (const std::string &filename) override
 Opens a file for reading (read-only). More...
 
EVENT::LCRunHeaderreadNextRunHeader () override
 Reads the next run header from the file. More...
 
EVENT::LCRunHeaderreadNextRunHeader (int accessMode) override
 Same as readNextRunHeader() but allows to set the access mode LCIO::READ_ONLY (default) or LCIO::Update. More...
 
EVENT::LCEventreadNextEvent () override
 Reads the next event from the file. More...
 
EVENT::LCEventreadNextEvent (int accessMode) override
 Same as readNextRunHeader() but allows to set the access mode LCIO::READ_ONLY (default) or LCIO::Update. More...
 
int getNumberOfEvents () override
 Return the number of events in the file - the file has to be open. More...
 
int getNumberOfRuns () override
 Return the number of runs (run headers) in the file - the file has to be open. More...
 
void getRuns (EVENT::IntVec &runs) override
 Return the run numbers of the runs (run headers) in the file - the file has to be open. More...
 
void getEvents (EVENT::IntVec &events) override
 Return the run and event numbers of the events in the file - the file has to be open. More...
 
void skipNEvents (int n) override
 Skips the next n events from the current position. More...
 
void setReadCollectionNames (const std::vector< std::string > &colnames) override
 Limit the collection names that are going to be read to the subset given in the vector - all other collection will be ignored. More...
 
EVENT::LCRunHeaderreadRunHeader (int runNumber) override
 Reads the specified runHeader from file. More...
 
EVENT::LCRunHeaderreadRunHeader (int runNumber, int accessMode) override
 Same as LCEvent* readRunHeader(int runNumber) allowing to set the access mode LCIO::READ_ONLY (default) or LCIO::Update. More...
 
EVENT::LCEventreadEvent (int runNumber, int evtNumber) override
 Reads the specified event from file. More...
 
EVENT::LCEventreadEvent (int runNumber, int evtNumber, int accessMode) override
 Same as LCEvent* readEvent(int runNumber, int evtNumber allowing to set the access mode LCIO::READ_ONLY (default) or LCIO::Update. More...
 
void close () override
 Closes the output file/stream etc. More...
 
void registerLCEventListener (IO::LCEventListener *ls) override
 Registers a listener for reading LCEvents from a stream. More...
 
void removeLCEventListener (IO::LCEventListener *ls) override
 Remove a listener for reading LCEvents from a stream. More...
 
void registerLCRunListener (IO::LCRunListener *ls) override
 Registers a listener for reading LCEventsLCRunHeaders from a stream. More...
 
void removeLCRunListener (IO::LCRunListener *ls) override
 Remove a listener for reading LCRunHeaders from a stream. More...
 
void readStream () override
 Reads the input stream and notifies registered listeners according to the object type found in the stream. More...
 
void readStream (int maxRecord) override
 Reads maxRecord from the input stream and notifies registered listeners according to the object type found in the stream. More...
 
- Public Member Functions inherited from IO::LCReader
virtual ~LCReader ()
 Destructor. More...
 

Private Member Functions

void processEvent (std::shared_ptr< EVENT::LCEvent > event) override
 
void processRunHeader (std::shared_ptr< EVENT::LCRunHeader > hdr) override
 
- Private Member Functions inherited from MT::LCReaderListener
virtual ~LCReaderListener ()
 Destructor. More...
 
virtual void processEvent (LCEventPtr event)=0
 process an event More...
 
virtual void processRunHeader (LCRunHeaderPtr hdr)=0
 process a run header More...
 

Private Attributes

MT::LCReader _reader
 The underlying implementation of the LCReader. More...
 
std::set< IO::LCRunListener * > _runListeners {}
 The run listeners. More...
 
std::set< IO::LCEventListener * > _evtListeners {}
 The event listeners. More...
 
EVENT::LCEvent_currentEvent = nullptr
 pointer to current Event More...
 
EVENT::LCRunHeader_currentRun = nullptr
 pointer to current RunHeader More...
 

Additional Inherited Members

- Static Public Attributes inherited from IO::LCReader
static const int directAccess = 0x00000001 << 0
 Configuration flags for the LCReader instance - to be used with LCFactory::createLCReader(). More...
 

Detailed Description

Concrete implementation of LCWriter using SIO.

Author
gaede
Version
Id:
SIOReader.h,v 1.29 2011-03-03 16:00:12 gaede Exp

Definition at line 31 of file SIOReader.h.

Constructor & Destructor Documentation

SIO::SIOReader::SIOReader ( int  lcReaderFlag = 0)

Default constructor.

Definition at line 22 of file SIOReader.cc.

SIO::SIOReader::SIOReader ( const SIOReader )
delete

no copy constructor

SIO::SIOReader::~SIOReader ( )
virtual

Destructor.

Definition at line 29 of file SIOReader.cc.

Member Function Documentation

void SIO::SIOReader::close ( )
overridevirtual

Closes the output file/stream etc.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 155 of file SIOReader.cc.

References _reader, and MT::LCReader::close().

void SIO::SIOReader::getEvents ( EVENT::IntVec events)
overridevirtual

Return the run and event numbers of the events in the file - the file has to be open.

In case several input files are specified in the open() method - the run and event numbers of the events in the file that is currently open are returned. The size of the vector events will be twice the number of events, where i-th run number will be in events[2*i] and the i-th event number in events[2*i+].

Implements IO::LCReader.

Definition at line 71 of file SIOReader.cc.

References _reader, and MT::LCReader::getEvents().

int SIO::SIOReader::getNumberOfEvents ( )
overridevirtual

Return the number of events in the file - the file has to be open.

In case several input files are specified in the open() method - the number of events in the file that is currently open is returned.

Implements IO::LCReader.

Definition at line 53 of file SIOReader.cc.

References _reader, and MT::LCReader::getNumberOfEvents().

int SIO::SIOReader::getNumberOfRuns ( )
overridevirtual

Return the number of runs (run headers) in the file - the file has to be open.

In case several input files are specified in the open() method - the number of runs (run headers) in the file that is currently open is returned.

Implements IO::LCReader.

Definition at line 59 of file SIOReader.cc.

References _reader, and MT::LCReader::getNumberOfRuns().

void SIO::SIOReader::getRuns ( EVENT::IntVec runs)
overridevirtual

Return the run numbers of the runs (run headers) in the file - the file has to be open.

In case several input files are specified in the open() method - the run numbers of the runs (run headers) in the file that is currently open is returned.

Implements IO::LCReader.

Definition at line 65 of file SIOReader.cc.

References _reader, and MT::LCReader::getRuns().

void SIO::SIOReader::open ( const std::vector< std::string > &  filenames)
overridevirtual

Opens a list of files for reading (read-only).

All subsequent read operations will operate on the list, i.e. if an EOF is encountered the next file in the list will be opened and read transparently to the user.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 41 of file SIOReader.cc.

References _reader, and MT::LCReader::open().

void SIO::SIOReader::open ( const std::string filename)
overridevirtual

Opens a file for reading (read-only).

Exceptions
IOException

Implements IO::LCReader.

Definition at line 47 of file SIOReader.cc.

References _reader, and MT::LCReader::open().

SIOReader& SIO::SIOReader::operator= ( const SIOReader )
delete

no assignment operator

void SIO::SIOReader::processEvent ( std::shared_ptr< EVENT::LCEvent event)
overrideprivate

Definition at line 197 of file SIOReader.cc.

References _evtListeners, std::set< K >::begin(), and std::set< K >::end().

void SIO::SIOReader::processRunHeader ( std::shared_ptr< EVENT::LCRunHeader hdr)
overrideprivate
EVENT::LCEvent * SIO::SIOReader::readEvent ( int  runNumber,
int  evtNumber 
)
overridevirtual

Reads the specified event from file.

Returns NULL if the specified event hasn't been found in the file.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 137 of file SIOReader.cc.

EVENT::LCEvent * SIO::SIOReader::readEvent ( int  runNumber,
int  evtNumber,
int  accessMode 
)
overridevirtual

Same as LCEvent* readEvent(int runNumber, int evtNumber allowing to set the access mode LCIO::READ_ONLY (default) or LCIO::Update.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 143 of file SIOReader.cc.

References _currentEvent, _reader, and MT::LCReader::readEvent().

EVENT::LCEvent * SIO::SIOReader::readNextEvent ( )
overridevirtual

Reads the next event from the file.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 95 of file SIOReader.cc.

EVENT::LCEvent * SIO::SIOReader::readNextEvent ( int  accessMode)
overridevirtual

Same as readNextRunHeader() but allows to set the access mode LCIO::READ_ONLY (default) or LCIO::Update.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 101 of file SIOReader.cc.

References _currentEvent, _reader, and MT::LCReader::readNextEvent().

EVENT::LCRunHeader * SIO::SIOReader::readNextRunHeader ( )
overridevirtual

Reads the next run header from the file.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 77 of file SIOReader.cc.

EVENT::LCRunHeader * SIO::SIOReader::readNextRunHeader ( int  accessMode)
overridevirtual

Same as readNextRunHeader() but allows to set the access mode LCIO::READ_ONLY (default) or LCIO::Update.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 83 of file SIOReader.cc.

References _currentRun, _reader, and MT::LCReader::readNextRunHeader().

EVENT::LCRunHeader * SIO::SIOReader::readRunHeader ( int  runNumber)
overridevirtual

Reads the specified runHeader from file.

Returns NULL if the specified runHeader hasn't been found in the file.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 119 of file SIOReader.cc.

EVENT::LCRunHeader * SIO::SIOReader::readRunHeader ( int  runNumber,
int  accessMode 
)
overridevirtual

Same as LCEvent* readRunHeader(int runNumber) allowing to set the access mode LCIO::READ_ONLY (default) or LCIO::Update.

Exceptions
IOException

Implements IO::LCReader.

Definition at line 125 of file SIOReader.cc.

References _currentRun, _reader, and MT::LCReader::readRunHeader().

void SIO::SIOReader::readStream ( )
overridevirtual

Reads the input stream and notifies registered listeners according to the object type found in the stream.

Exceptions
IOException
EndOfException

Implements IO::LCReader.

Definition at line 185 of file SIOReader.cc.

void SIO::SIOReader::readStream ( int  maxRecord)
overridevirtual

Reads maxRecord from the input stream and notifies registered listeners according to the object type found in the stream.

Throws EndOfException if less than maxRecord records are found in the stream.

Exceptions
IOException
EndOfException

Implements IO::LCReader.

Definition at line 191 of file SIOReader.cc.

References _reader, and MT::LCReader::readStream().

void SIO::SIOReader::registerLCEventListener ( IO::LCEventListener ls)
overridevirtual

Registers a listener for reading LCEvents from a stream.

Implements IO::LCReader.

Definition at line 161 of file SIOReader.cc.

References _evtListeners, std::set< K >::end(), and std::set< K >::insert().

void SIO::SIOReader::registerLCRunListener ( IO::LCRunListener ls)
overridevirtual

Registers a listener for reading LCEventsLCRunHeaders from a stream.

Implements IO::LCReader.

Definition at line 173 of file SIOReader.cc.

References _runListeners, std::set< K >::end(), and std::set< K >::insert().

void SIO::SIOReader::removeLCEventListener ( IO::LCEventListener ls)
overridevirtual

Remove a listener for reading LCEvents from a stream.

Implements IO::LCReader.

Definition at line 167 of file SIOReader.cc.

References _evtListeners, std::set< K >::erase(), and std::set< K >::find().

void SIO::SIOReader::removeLCRunListener ( IO::LCRunListener ls)
overridevirtual

Remove a listener for reading LCRunHeaders from a stream.

Implements IO::LCReader.

Definition at line 179 of file SIOReader.cc.

References _runListeners, std::set< K >::erase(), and std::set< K >::find().

void SIO::SIOReader::setReadCollectionNames ( const std::vector< std::string > &  colnames)
overridevirtual

Limit the collection names that are going to be read to the subset given in the vector - all other collection will be ignored.

This might improve the reading performance considerably in cases where only a small subset of the collections in the event is needed.

Implements IO::LCReader.

Definition at line 35 of file SIOReader.cc.

References _reader, and MT::LCReader::setReadCollectionNames().

void SIO::SIOReader::skipNEvents ( int  n)
overridevirtual

Skips the next n events from the current position.

In fact simply reads the next n event headers so that the next event read is the (n+1)-th event.

Implements IO::LCReader.

Definition at line 113 of file SIOReader.cc.

References _reader, and MT::LCReader::skipNEvents().

Member Data Documentation

EVENT::LCEvent* SIO::SIOReader::_currentEvent = nullptr
private

pointer to current Event

Definition at line 213 of file SIOReader.h.

Referenced by readEvent(), and readNextEvent().

EVENT::LCRunHeader* SIO::SIOReader::_currentRun = nullptr
private

pointer to current RunHeader

Definition at line 215 of file SIOReader.h.

Referenced by readNextRunHeader(), and readRunHeader().

std::set<IO::LCEventListener*> SIO::SIOReader::_evtListeners {}
private

The event listeners.

Definition at line 211 of file SIOReader.h.

Referenced by processEvent(), registerLCEventListener(), and removeLCEventListener().

MT::LCReader SIO::SIOReader::_reader
private
std::set<IO::LCRunListener*> SIO::SIOReader::_runListeners {}
private

The run listeners.

Definition at line 209 of file SIOReader.h.

Referenced by processRunHeader(), registerLCRunListener(), and removeLCRunListener().


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