lcsim/src/org/lcsim/util/loop
diff -u -r1.4 -r1.5
--- StdhepEventSource.java 25 Aug 2006 01:29:17 -0000 1.4
+++ StdhepEventSource.java 4 Oct 2006 22:57:44 -0000 1.5
@@ -17,7 +17,7 @@
/**
* Convert an LCIOReader to a SequentialRecordSource
* @author tonyj
- * @version $Id: StdhepEventSource.java,v 1.4 2006/08/25 01:29:17 tonyj Exp $
+ * @version $Id: StdhepEventSource.java,v 1.5 2006/10/04 22:57:44 tonyj Exp $
*/
public class StdhepEventSource implements RandomAccessRecordSource
{
@@ -104,12 +104,14 @@
catch (IOException x) {}
}
- public void goToRecord(int numberToSkip) throws NoSuchRecordException
+ public void goToRecord(int target) throws NoSuchRecordException
{
try
{
- int target = currentEventNumber+numberToSkip;
- for (;;)
+ if (target < currentEventNumber) rewind();
+ if (target == currentEventNumber) return;
+
+ while (true)
{
StdhepRecord record = reader.nextRecord();
if (record instanceof StdhepEvent)
lcsim/test
diff -u -r1.12 -r1.13
--- LCIOReadTest.java 25 Aug 2006 01:28:51 -0000 1.12
+++ LCIOReadTest.java 4 Oct 2006 22:57:44 -0000 1.13
@@ -78,6 +78,23 @@
assertEquals(50, loop.getTotalCountableSupplied());
loop.dispose();
}
+ public void testSkip0() throws Exception
+ {
+ final String detectorName = "sidaug05";
+ URL url = new URL("ftp://ftp-lcd.slac.stanford.edu/lcd/NewData/NLC500/ZZ/stdhep/pythia/pythiaZZ_nunu_bbbar.stdhep");
+ FileCache cache = new FileCache();
+ File stdhep = cache.getCachedFile(url);
+
+ LCSimLoop loop = new LCSimLoop();
+ loop.setStdhepRecordSource(stdhep,detectorName);
+ long start = System.nanoTime();
+ loop.skip(0);
+ long stop = System.nanoTime();
+ System.out.println("Skip took "+(stop-start)/1000000.+"ms");
+ loop.loop(1000);
+ assertEquals(1000, loop.getTotalCountableSupplied());
+ loop.dispose();
+ }
public void testSkipSpeed() throws Exception
{
final String detectorName = "sidaug05";