11 modified files
lcio/doc
diff -u -r1.43 -r1.44
--- versions.readme 19 Sep 2005 15:40:25 -0000 1.43
+++ versions.readme 21 Oct 2005 13:53:18 -0000 1.44
@@ -4,6 +4,10 @@
- added optional momentum[3] to SimTrackerHit (momentum of particle at position of hit)
+
+ - added LCReader::skipNEvents() method to skip (the first) n events in a file
+
+ - added option to dump the n-th event in a file to $LCIO/bin/dumpevent
======================
v01-05
lcio/src/aid/IO
diff -u -r1.12 -r1.13
--- LCReader.aid 17 Feb 2004 15:09:26 -0000 1.12
+++ LCReader.aid 21 Oct 2005 13:53:19 -0000 1.13
@@ -56,6 +56,11 @@
*/
public LCEvent* readNextEvent(int accessMode) throws IOException ;
+
+ /** Skips the next n events from the current position.
+ */
+ public void skipNEvents(int n) ;
+
/** Reads the specified event from file.
* To be used with care: events have to be read in sequential
* order (as LCIO has no direct access yet). Returns NULL if
lcio/src/cpp/include/CPPFORT
diff -u -r1.3 -r1.4
--- lcrdr.h 15 Apr 2005 08:37:34 -0000 1.3
+++ lcrdr.h 21 Oct 2005 13:53:19 -0000 1.4
@@ -1,3 +1,4 @@
+
/**Header file for the f77-wrapper functions of the LCReader class.
*
* @author F. Gaede
@@ -21,6 +22,8 @@
PTRTYPE lcrdrreadnextevent(PTRTYPE reader, int accessMode) ;
PTRTYPE lcrdrreadevent(PTRTYPE reader, int runNumber, int evtNumber );
+int lcrdrskipnevents( PTRTYPE reader, int n ) ;
+
extern "C"{
FCALLSCFUN0(CFORTRANPNTR, lcrdrcreate, LCRDRCREATE, lcrdrcreate )
@@ -34,5 +37,7 @@
FCALLSCFUN2(INT,lcrdrreadnextevent,LCRDRREADNEXTEVENT,lcrdrreadnextevent,CFORTRANPNTR,INT)
FCALLSCFUN3(INT,lcrdrreadevent,LCRDRREADEVENT,lcrdrreadevent,CFORTRANPNTR,INT,INT)
+FCALLSCFUN2(INT, lcrdrskipnevents, LCRDRSKIPNEVENTS, lcrdrskipnevents, CFORTRANPNTR, INT )
+
}
lcio/src/cpp/include/SIO
diff -u -r1.23 -r1.24
--- SIOReader.h 15 Apr 2005 08:37:42 -0000 1.23
+++ SIOReader.h 21 Oct 2005 13:53:19 -0000 1.24
@@ -22,7 +22,7 @@
/** Concrete implementation of LCWriter using SIO.
*
* @author gaede
- * @version $Id: SIOReader.h,v 1.23 2005/04/15 08:37:42 gaede Exp $
+ * @version $Id: SIOReader.h,v 1.24 2005/10/21 13:53:19 gaede Exp $
*/
class SIOReader : public IO::LCReader {
@@ -80,6 +80,12 @@
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.
+ */
+ virtual void skipNEvents(int n) ;
+
+
/** Reads the specified event from file.
* To be used with care: events have to be read in sequential
* order (as LCIO has no direct access yet).
lcio/src/cpp/src/CPPFORT
diff -u -r1.4 -r1.5
--- lcrdr.cc 25 Jun 2004 16:27:14 -0000 1.4
+++ lcrdr.cc 21 Oct 2005 13:53:19 -0000 1.5
@@ -60,3 +60,9 @@
LCReader* rdr = reinterpret_cast<LCReader*>(reader) ;
return C2F_POINTER( LCEvent*, rdr->readEvent( runNumber, evtNumber ) );
}
+
+int lcrdrskipnevents( PTRTYPE reader, int n ) {
+ LCReader* rdr = reinterpret_cast<LCReader*>(reader) ;
+ rdr->skipNEvents( n ) ;
+ return LCIO::SUCCESS ;
+}
lcio/src/cpp/src/EXAMPLE
diff -u -r1.5 -r1.6
--- dumpevent.cc 25 Aug 2003 14:52:02 -0000 1.5
+++ dumpevent.cc 21 Oct 2005 13:53:20 -0000 1.6
@@ -19,36 +19,81 @@
char* FILEN ;
int runNumber ;
int evtNumber ;
+ int nthEvent ;
// read file name from command line (only argument)
- if( argc < 4 ) {
+ if( argc < 3 ) {
+
cout << " usage: dumpevent filename runNum evtNum " << endl ;
+ cout << " or: dumpevent filename n " << endl ;
+ cout << " where the first dumps the event with the specified run and event number" << endl ;
+ cout << " and the second simply dumps the n-th event in the file" << endl ;
+
exit(1) ;
}
FILEN = argv[1] ;
- runNumber = atoi( argv[2] ) ;
- evtNumber = atoi( argv[3] ) ;
-
+
+ bool dumpNthEvent( argc == 3 ) ;
+
+
+
+ if( dumpNthEvent ) {
+
+ nthEvent = atoi( argv[2] ) ;
+
+ if( nthEvent < 1 ) {
+
+ cout << " usage: dumpevent filename n - whith n > 0 ! " << endl ;
+
+ exit(1) ;
+ }
+
+ }else{
+
+ runNumber = atoi( argv[2] ) ;
+ evtNumber = atoi( argv[3] ) ;
+ }
LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
- LCEvent* evt(0) ;
- try{
-
+
+ LCEvent* evt(0) ;
+
+ try{
+
lcReader->open( FILEN ) ;
- evt = lcReader->readEvent(runNumber, evtNumber) ;
+ if( dumpNthEvent ) {
+
+ lcReader->skipNEvents( nthEvent - 1 ) ;
+
+ evt = lcReader->readNextEvent() ;
+
+ }else{
+
+ evt = lcReader->readEvent(runNumber, evtNumber) ;
+ }
+
// } catch( EndOfDataException& e) {
// cout << " couldn't find event " << evtNumber << " - run " << runNumber
// << " in file " << FILEN << endl ;
// exit(1) ;
- if(!evt){
- cout << " couldn't find event " << evtNumber << " - run " << runNumber
- << " in file " << FILEN << endl ;
- exit(1) ;
- }
+ if( !evt ){
+
+ if(dumpNthEvent){
+
+ cout << " less than " << nthEvent << " events in file " << FILEN << endl ;
+
+ }else{
+
+ cout << " couldn't find event " << evtNumber << " - run " << runNumber
+ << " in file " << FILEN << endl ;
+ }
+
+ exit(1) ;
+ }
LCTOOLS::dumpEventDetailed( evt ) ;
lcio/src/cpp/src/SIO
diff -u -r1.45 -r1.46
--- SIOReader.cc 1 Jun 2005 15:12:26 -0000 1.45
+++ SIOReader.cc 21 Oct 2005 13:53:20 -0000 1.46
@@ -401,6 +401,26 @@
}
}
+ void SIOReader::skipNEvents(int n) {
+
+ int eventsSkipped = 0 ;
+
+ SIOUnpack hdrUnp( SIOUnpack::EVENTHDR ) ;
+
+ while( eventsSkipped++ < n ){
+
+ try {
+
+ readRecord() ;
+
+ }
+ catch(EndOfDataException){
+
+ return ;
+ }
+ }
+
+ }
EVENT::LCEvent * SIOReader::readEvent(int runNumber, int evtNumber)
throw (IOException , std::exception) {
@@ -427,13 +447,13 @@
SIOUnpack hdrUnp( SIOUnpack::EVENTHDR ) ;
while( !evtFound ){
-
- try{
- readRecord() ;
- }
- catch(EndOfDataException){
- return 0 ;
- }
+
+ try{
+ readRecord() ;
+ }
+ catch(EndOfDataException){
+ return 0 ;
+ }
evtFound = ( (*_evtP)->getEventNumber() == evtNumber ) ;
}
lcio/src/f77
diff -u -r1.12 -r1.13
--- anajob.F 21 Sep 2004 15:44:50 -0000 1.12
+++ anajob.F 21 Oct 2005 13:53:20 -0000 1.13
@@ -113,7 +113,12 @@
nEvents = 0
+
+c---- ---fg: debugging only:
+c status = lcrdrskipnevents( reader, 97 )
+
c---- ---- event loop ------
+
20 continue
event = lcrdrreadnextevent( reader, LCIO_READ_ONLY )
if( event .eq. 0 ) go to 30
lcio/src/f77
diff -u -r1.33 -r1.34
--- lciof77api.inc 10 Oct 2005 11:16:21 -0000 1.33
+++ lciof77api.inc 21 Oct 2005 13:53:20 -0000 1.34
@@ -12,7 +12,7 @@
* H. Vogt
* 05/06/2004 (reconstruction part added)
*
-* $Id: lciof77api.inc,v 1.33 2005/10/10 11:16:21 hvogt Exp $
+* $Id: lciof77api.inc,v 1.34 2005/10/21 13:53:20 gaede Exp $
***************************************************
#include "lciof77pointer.inc"
@@ -21,6 +21,7 @@
c----- the LCReader interface
PTRTYPE lcrdrcreate
integer lcrdrdelete, lcrdropen, lcrdrclose, lcrdrreadstream
+ integer lcrdrskipnevents
PTRTYPE lcrdrreadnextrunheader
PTRTYPE lcrdrreadnextevent
PTRTYPE lcrdrreadevent
lcio/src/java/hep/lcio/example
diff -u -r1.5 -r1.6
--- AnalysisJob.java 17 Feb 2004 15:09:28 -0000 1.5
+++ AnalysisJob.java 21 Oct 2005 13:53:21 -0000 1.6
@@ -38,6 +38,9 @@
lcReader.close();
lcReader.open(args);
+ //fg: for debugging only:
+ //lcReader.skipNEvents( 97 ) ;
+
// dump all events in the file
int nEvents = 0;
for (;;)
lcio/src/java/hep/lcio/implementation/sio
diff -u -r1.12 -r1.13
--- SIOLCReader.java 14 Jul 2004 15:50:45 -0000 1.12
+++ SIOLCReader.java 21 Oct 2005 13:53:21 -0000 1.13
@@ -22,7 +22,7 @@
/**
*
* @author Tony Johnson
- * @version $Id: SIOLCReader.java,v 1.12 2004/07/14 15:50:45 gaede Exp $
+ * @version $Id: SIOLCReader.java,v 1.13 2005/10/21 13:53:21 gaede Exp $
*/
class SIOLCReader implements LCReader
{
@@ -114,6 +114,24 @@
}
}
+ public void skipNEvents(int n)
+ {
+ int nEvents = 0 ;
+ try
+ {
+ while( nEvents < n )
+ {
+ SIORecord record = reader.readRecord();
+ String name = record.getRecordName();
+ if ( ! name.equals( SIOFactory.eventHeaderRecordName) )
+ continue;
+ ++nEvents ;
+ }
+ }
+ catch (IOException x)
+ {
+ }
+ }
public LCEvent readNextEvent() throws IOException
{
return readNextEvent(LCIO.READ_ONLY);
@@ -237,4 +255,5 @@
{
runListeners.remove(ls);
}
+
}
CVSspam 0.2.8