9 modified files
lcio/doc
diff -u -r1.89 -r1.90
--- versions.readme 7 Dec 2010 14:23:09 -0000 1.89
+++ versions.readme 3 Mar 2011 16:00:12 -0000 1.90
@@ -2,9 +2,17 @@
Describes the changes for the different versions/tags of LCIO
---------------------------------------------------------------
==========
- v01-52
+ v01-52 - to be released
==========
- - implemented method LCReader::readRunHeader(int runNumber )
+
+ - implemented new methods:
+
+ LCReader::getNumberOfRuns()
+
+ - C++ only:
+ LCReader::getNumberOfEvents()
+ LCReader::readRunHeader(int runNumber )
+
- added access mode to
LCReader::readRunHeader(int runNumber, int accessMode )
LCReader::readEvent(int runNumber, int evtNumber, int accessMode )
lcio/src/aid/IO
diff -u -r1.16 -r1.17
--- LCReader.aid 7 Dec 2010 14:23:09 -0000 1.16
+++ LCReader.aid 3 Mar 2011 16:00:12 -0000 1.17
@@ -65,8 +65,23 @@
*/
public LCEvent* readNextEvent(int accessMode) throws IOException ;
+ @ifdef cpp
- /** Skips the next n events from the current position.
+ /** 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.
+ */
+ public int getNumberOfEvents() throws IOException;
+
+ /** 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.
+ */
+ public int getNumberOfRuns() throws IOException;
+
+ @endif
+
+ /** Skips the next n events from the current position.
* @throws IOException
*/
public void skipNEvents(int n) throws IOException;
lcio/src/cpp/include/SIO
diff -u -r1.2 -r1.3
--- LCIORandomAccessMgr.h 22 Jun 2010 13:49:54 -0000 1.2
+++ LCIORandomAccessMgr.h 3 Mar 2011 16:00:12 -0000 1.3
@@ -32,7 +32,7 @@
*
*
* @author gaede
- * @version $Id: LCIORandomAccessMgr.h,v 1.2 2010/06/22 13:49:54 gaede Exp $
+ * @version $Id: LCIORandomAccessMgr.h,v 1.3 2011/03/03 16:00:12 gaede Exp $
*/
class LCIORandomAccessMgr {
@@ -61,10 +61,14 @@
}
/** Get the run and event header map from the stream - either by reading the random access records or by recreating
- * it for olf files.
+ * it for old files.
*/
- bool getEventMap(SIO_stream* s) ;
+ bool createEventMap(SIO_stream* s) ;
+ /** Return the event map - it will be empty, if not yet created.
+ */
+ const RunEventMap& getEventMap() { return _runEvtMap ; }
+
/** Initialize random access for append mode: read last LCIORandomAccess record if it exists -
* recreate the RunEvent map from the file if not (old files).
*/
lcio/src/cpp/include/SIO
diff -u -r1.2 -r1.3
--- RunEventMap.h 22 Jun 2010 13:49:54 -0000 1.2
+++ RunEventMap.h 3 Mar 2011 16:00:12 -0000 1.3
@@ -15,7 +15,7 @@
/** Map that holds positions of Run and Event records.
*
* @author gaede
- * @version $Id: RunEventMap.h,v 1.2 2010/06/22 13:49:54 gaede Exp $
+ * @version $Id: RunEventMap.h,v 1.3 2011/03/03 16:00:12 gaede Exp $
*/
class RunEventMap {
@@ -58,9 +58,9 @@
RunEvent maxRunEvent() ;
- int getNumberOfEventRecords() { return _nEvt ; }
+ int getNumberOfEventRecords() const { return _nEvt ; }
- int getNumberOfRunRecords() { return _nRun ; }
+ int getNumberOfRunRecords() const { return _nRun ; }
// map funcitons
size_t size() { return _map.size() ; }
lcio/src/cpp/include/SIO
diff -u -r1.28 -r1.29
--- SIOReader.h 7 Dec 2010 14:23:09 -0000 1.28
+++ SIOReader.h 3 Mar 2011 16:00:12 -0000 1.29
@@ -28,7 +28,7 @@
/** Concrete implementation of LCWriter using SIO.
*
* @author gaede
- * @version $Id: SIOReader.h,v 1.28 2010/12/07 14:23:09 gaede Exp $
+ * @version $Id: SIOReader.h,v 1.29 2011/03/03 16:00:12 gaede Exp $
*/
class SIOReader : public IO::LCReader {
@@ -89,11 +89,24 @@
virtual EVENT::LCEvent* readNextEvent( int accessMode) throw (IO::IOException, std::exception) ;
- /** 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.
+ /** 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.
*/
- virtual void skipNEvents(int n) throw (IO::IOException, std::exception ) ;
+ virtual int getNumberOfEvents() throw (IO::IOException, std::exception ) ;
+
+
+ /** 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.
+ */
+ virtual int getNumberOfRuns() throw (IO::IOException, std::exception ) ;
+
+ /** 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.
+ */
+ virtual void skipNEvents(int n) throw (IO::IOException, std::exception ) ;
/** Reads the specified runHeader from file. Returns NULL if
@@ -121,7 +134,7 @@
throw (IO::IOException, std::exception ) ;
- /** Same as LCEvent* readEvent(int runNumber, int evtNumber)
+ /** Same as LCEvent* readEvent(int runNumber, int evtNumber
* allowing to set the access mode LCIO::READ_ONLY (default) or LCIO::Update.
*
* @throws IOException
@@ -211,7 +224,7 @@
unsigned int _currentFileIndex ;
// EventMap _evtMap ;
- const bool _readEventMap ;
+ bool _readEventMap ;
// RunEventMap _reMap ;
LCIORandomAccessMgr _raMgr ;
lcio/src/cpp/src/EXAMPLE
diff -u -r1.16 -r1.17
--- anajob.cc 28 May 2008 14:02:09 -0000 1.16
+++ anajob.cc 3 Mar 2011 16:00:13 -0000 1.17
@@ -6,7 +6,6 @@
#include <cstdlib>
-//static const char* FILEN = "recjob.slcio" ; // default file name
static std::vector<std::string> FILEN ;
using namespace std ;
@@ -36,17 +35,27 @@
// first we read the run information
-
- // for reading from one file only use sth. like:
- // const char* FILEN = "recjob.slcio" ;
- lcReader->open( FILEN ) ;
-
- cout << " will open and read from files: " << endl ;
+ cout << "anajob: will open and read from files: " << endl ;
+
for(int i=0 ; i < nFiles ; i++){
- cout << " " << FILEN[i] << endl ;
+
+ lcReader->open( FILEN[i] ) ;
+
+ cout << endl << " " << FILEN[i]
+ << " [ number of runs: " << lcReader->getNumberOfRuns()
+ << ", number of events: " << lcReader->getNumberOfEvents() << " ] "
+ << endl
+ << endl ;
+
+ lcReader->close() ;
}
+
+ // open list of files
+ lcReader->open( FILEN ) ;
+
+
LCRunHeader *runHdr ;
// use a try catch block here: if sth. went wrong with reading the run data we
lcio/src/cpp/src/SIO
diff -u -r1.3 -r1.4
--- LCIORandomAccessMgr.cc 7 Oct 2010 19:32:16 -0000 1.3
+++ LCIORandomAccessMgr.cc 3 Mar 2011 16:00:13 -0000 1.4
@@ -213,7 +213,7 @@
}
- bool LCIORandomAccessMgr::getEventMap( SIO_stream* stream ) {
+ bool LCIORandomAccessMgr::createEventMap( SIO_stream* stream ) {
// check if the last record is LCIORandomAccess ( the file record )
if( ! readLCIORandomAccessAt( stream , -LCSIO_RANDOMACCESS_SIZE) ) {
lcio/src/cpp/src/SIO
diff -u -r1.57 -r1.58
--- SIOReader.cc 7 Dec 2010 14:23:09 -0000 1.57
+++ SIOReader.cc 3 Mar 2011 16:00:13 -0000 1.58
@@ -164,9 +164,40 @@
void SIOReader::getEventMap() {
- _raMgr.getEventMap( _stream ) ;
+ _raMgr.createEventMap( _stream ) ;
}
+
+
+ int SIOReader::getNumberOfEvents() throw (IOException, std::exception ) {
+
+ // create the event map if needed (i.e. not opened in direct access mode)
+ if( ! _readEventMap ){
+
+ _readEventMap = true ;
+
+ getEventMap() ;
+ }
+
+ return _raMgr.getEventMap().getNumberOfEventRecords() ;
+
+ }
+
+ int SIOReader::getNumberOfRuns() throw (IOException, std::exception ) {
+
+ // create the event map if needed (i.e. not opened in direct access mode)
+ if( ! _readEventMap ){
+
+ _readEventMap = true ;
+
+ getEventMap() ;
+ }
+
+ return _raMgr.getEventMap().getNumberOfRunRecords() ;
+
+ }
+
+
//-------------------------------------------------------------------------------------------
void SIOReader::readRecord() throw (IOException , EndOfDataException , std::exception) {
lcio/src/cpp/src/TESTS
diff -u -r1.5 -r1.6
--- test_randomaccess.cc 7 Dec 2010 14:23:10 -0000 1.5
+++ test_randomaccess.cc 3 Mar 2011 16:00:13 -0000 1.6
@@ -126,6 +126,10 @@
lcReader->open( "c_sim.slcio" ) ;
+ MYTEST( lcReader->getNumberOfRuns() , 10 , " LCReader::getNumberOfRuns() - number of run headers is not 10" );
+
+ MYTEST( lcReader->getNumberOfEvents() , 100 , " LCReader::getNumberOfEvents() - number of events is not 100" );
+
// test that we can still use read next for runheaders .....
LCRunHeader* rHdr = lcReader->readNextRunHeader() ;
CVSspam 0.2.8