23 modified files
lcsim
diff -u -r1.177 -r1.177.2.1
--- pom.xml 9 May 2012 18:16:16 -0000 1.177
+++ pom.xml 10 May 2012 21:22:32 -0000 1.177.2.1
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>lcsim</artifactId>
<name>org.lcsim</name>
- <version>1.24-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<description>A Java reconstruction and analysis framework for LCD studies.</description>
<scm>
<connection>scm:cvs:pserver:[log in to unmask]:/cvs/lcd:lcsim</connection>
@@ -26,7 +26,7 @@
<parent>
<groupId>org.lcsim</groupId>
<artifactId>lcsim-parent</artifactId>
- <version>1.16</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<distributionManagement>
<site>
@@ -88,6 +88,7 @@
<version>2.0.1</version>
<!--
use the command 'mvn freehep-jas:install' to install manually
+ -->
<executions>
<execution>
<goals>
@@ -95,7 +96,6 @@
</goals>
</execution>
</executions>
- -->
<configuration>
<jarName>lcsim</jarName>
<includes>
@@ -264,7 +264,7 @@
<dependency>
<groupId>org.lcsim</groupId>
<artifactId>GeomConverter</artifactId>
- <version>1.19</version>
+ <version>2.0-SNAPSHOT</version>
</dependency>
<!-- FIXME: This dep is not actually used in lcsim. -->
<dependency>
lcsim/src/org/lcsim/job
diff -u -r1.58 -r1.58.2.1
--- JobControlManager.java 30 Apr 2012 22:56:26 -0000 1.58
+++ JobControlManager.java 10 May 2012 21:22:32 -0000 1.58.2.1
@@ -32,8 +32,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
-import org.freehep.record.loop.LoopSourceExhaustedException;
-import org.freehep.record.loop.event.RecordSuppliedEvent;
+import org.freehep.record.loop.RecordEvent;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
@@ -80,7 +79,7 @@
* which it should be discarded. If the {@link #run()} method is called twice on
* the same manager, a fatal exception will be thrown.
*
- * @version $Id: JobControlManager.java,v 1.58 2012/04/30 22:56:26 jeremy Exp $
+ * @version $Id: JobControlManager.java,v 1.58.2.1 2012/05/10 21:22:32 onoprien Exp $
* @author Jeremy McCormick
*/
// TODO Allow no input files when only Driver list is needed.
@@ -384,7 +383,14 @@
}
// Execute the loop.
- loop.loop(maxEvents, statsStream);
+ long n = loop.loop(maxEvents, statsStream);
+
+ // Record source was exhausted before max events was hit. This is probably fine,
+ // but print message in case more were expected.
+ if (maxEvents > 0 && n < maxEvents) {
+ Throwable x = loop.getProgress().getException();
+ if (x != null) logStream.println(x.getMessage());
+ }
if (verbose) {
logStream.println();
@@ -397,11 +403,6 @@
logStream.println("Executed dry run. No events processed!");
}
}
- // Record source was exhausted before max events was hit. This is probably fine,
- // but print message in case more were expected.
- catch (LoopSourceExhaustedException x) {
- logStream.println(x.getMessage());
- }
// Catch other fatal exceptions thrown from the loop.
catch (Exception e)
{
@@ -1322,7 +1323,7 @@
// Process a single LCSim event using the DriverAdapter.
public void processEvent(EventHeader event) {
- getDriverAdapter().recordSupplied(new RecordSuppliedEvent(new Object(), event));
+ getDriverAdapter().recordSupplied(new RecordEvent(null, event));
}
public synchronized void reset() {
@@ -1379,11 +1380,11 @@
}
public void configure() {
- getDriverAdapter().configure(null);
+ getDriverAdapter().start(null);
}
public void reconfigure() {
- getDriverAdapter().reconfigure(null);
+ getDriverAdapter().start(null);
}
public void suspend() {
lcsim/src/org/lcsim/plugin
diff -u -r1.1 -r1.1.10.1
--- LCSim.java 21 Mar 2006 19:47:27 -0000 1.1
+++ LCSim.java 10 May 2012 21:22:32 -0000 1.1.10.1
@@ -1,6 +1,6 @@
package org.lcsim.plugin;
-import org.freehep.record.loop.SequentialRecordLoop;
+import org.freehep.record.loop.RecordLoop;
import org.freehep.util.FreeHEPLookup;
import org.lcsim.event.EventHeader;
@@ -25,7 +25,7 @@
{
try
{
- SequentialRecordLoop loop = (SequentialRecordLoop) lookup.lookup(SequentialRecordLoop.class);
+ RecordLoop loop = (RecordLoop) lookup.lookup(RecordLoop.class);
Object event = loop.getRecordSource().getCurrentRecord();
return (event instanceof EventHeader) ? (EventHeader) event : null;
}
lcsim/src/org/lcsim/plugin
diff -u -r1.1 -r1.1.8.1
--- LCSimDriverTree.java 11 Sep 2007 00:22:47 -0000 1.1
+++ LCSimDriverTree.java 10 May 2012 21:22:32 -0000 1.1.8.1
@@ -4,13 +4,12 @@
import java.util.ArrayList;
import java.util.List;
import javax.swing.tree.TreePath;
-import org.freehep.record.loop.SequentialRecordLoop;
-import org.freehep.record.loop.event.LoopEvent;
-import org.freehep.record.loop.event.LoopProgressEvent;
-import org.freehep.record.loop.event.RecordLoopListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.freehep.application.studio.Studio;
+import org.freehep.record.loop.LoopEvent;
+import org.freehep.record.loop.LoopListener;
+import org.freehep.record.loop.RecordLoop;
import org.freehep.swing.treetable.AbstractTreeTableModel;
import org.freehep.swing.treetable.JTreeTable;
import org.freehep.swing.treetable.TreeTableModel;
@@ -28,15 +27,15 @@
* @author tonyj
* @author gaede
*/
-public class LCSimDriverTree extends JPanel implements RecordLoopListener, LookupListener
+public class LCSimDriverTree extends JPanel implements LoopListener, LookupListener
{
private Studio app;
- private SequentialRecordLoop loop;
+ private RecordLoop loop;
private Result result;
private List<Driver> drivers = new ArrayList<Driver>();
private DriverTreeModel model;
- public LCSimDriverTree(Studio app, SequentialRecordLoop loop)
+ public LCSimDriverTree(Studio app, RecordLoop loop)
{
super(new BorderLayout());
this.app = app;
@@ -48,7 +47,7 @@
}
public void addNotify()
{
- loop.addRecordLoopListener(this);
+ loop.addLoopListener(this);
// Listen for record sources
// TODO: We use a "wild-card" template to work around a bug in Lookup.
@@ -64,27 +63,12 @@
public void removeNotify()
{
super.removeNotify();
- loop.removeRecordLoopListener(this);
+ loop.removeLoopListener(this);
result.removeLookupListener(this);
}
+
+ public void process(LoopEvent event) {}
- public void loopBeginning(LoopEvent loopEvent)
- {
- }
-
- public void loopEnded(LoopEvent loopEvent)
- {
-
- }
-
- public void loopReset(LoopEvent loopEvent)
- {
-
- }
-
- public void progress(LoopProgressEvent loopProgressEvent)
- {
- }
public class DriverTreeModel extends AbstractTreeTableModel
{
private String[] columns = { "Driver", "Events", "Time", "% of parent" };
lcsim/src/org/lcsim/plugin
diff -u -r1.14 -r1.14.6.1
--- LCSimPlugin.java 4 Sep 2008 17:40:51 -0000 1.14
+++ LCSimPlugin.java 10 May 2012 21:22:32 -0000 1.14.6.1
@@ -21,10 +21,9 @@
import org.freehep.jas.plugin.console.ConsoleService;
import org.freehep.jas.services.ScriptEngine;
import org.freehep.jas.services.WebBrowser;
-import org.freehep.record.loop.SequentialRecordLoop;
-import org.freehep.record.loop.event.LoopEvent;
-import org.freehep.record.loop.event.LoopProgressEvent;
-import org.freehep.record.loop.event.RecordLoopListener;
+import org.freehep.record.loop.LoopEvent;
+import org.freehep.record.loop.LoopListener;
+import org.freehep.record.loop.RecordLoop;
import org.freehep.util.FreeHEPLookup;
import org.freehep.util.commanddispatcher.CommandProcessor;
import org.freehep.util.commanddispatcher.CommandState;
@@ -38,14 +37,12 @@
import org.lcsim.util.Driver;
import org.lcsim.util.DriverAdapter;
import org.lcsim.util.loop.EventGeneratorRecordSource;
-import org.openide.util.Lookup;
-import org.openide.util.Lookup.Result;
import org.xml.sax.SAXException;
/**
*
* @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.14 2008/09/04 17:40:51 jeremy Exp $
+ * @version $Id: LCSimPlugin.java,v 1.14.6.1 2012/05/10 21:22:32 onoprien Exp $
*/
public class LCSimPlugin extends Plugin implements StudioListener, PageListener
@@ -118,8 +115,8 @@
app.removeToolBar(toolbar);
- SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
- loop.removeRecordLoopListener(commands);
+ RecordLoop loop = (RecordLoop) getApplication().getLookup().lookup(RecordLoop.class);
+ loop.removeLoopListener(commands);
}
protected void postInit()
{
@@ -136,8 +133,8 @@
System.err.println("WARNING: Unable to create LCSimHepRepConverter. The HepRep plugin is probably not installed.");
}
- SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
- loop.addRecordLoopListener(commands);
+ RecordLoop loop = (RecordLoop) getApplication().getLookup().lookup(RecordLoop.class);
+ loop.addLoopListener(commands);
try
{
@@ -230,7 +227,7 @@
}
}
- class LCSimCommands extends CommandProcessor implements RecordLoopListener
+ class LCSimCommands extends CommandProcessor implements LoopListener
{
public void onLCSimEventBrowser()
{
@@ -239,21 +236,21 @@
}
private void createNewEventBrowser()
{
- SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ RecordLoop loop = (RecordLoop) getApplication().getLookup().lookup(RecordLoop.class);
LCSimEventBrowser tree = new LCSimEventBrowser(getApplication(),loop);
getApplication().getPageManager().openPage(tree,"LCSim Event",null);
}
private void createNewDriverTree()
{
- SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ RecordLoop loop = (RecordLoop) getApplication().getLookup().lookup(RecordLoop.class);
LCSimDriverTree tree = new LCSimDriverTree(getApplication(),loop);
getApplication().getPageManager().openPage(tree,"LCSim Drivers",null);
}
public void enableLCSimEventBrowserButton(CommandState state)
{
- SequentialRecordLoop loop = (SequentialRecordLoop) getApplication().getLookup().lookup(SequentialRecordLoop.class);
+ RecordLoop loop = (RecordLoop) getApplication().getLookup().lookup(RecordLoop.class);
try
{
Object record = loop.getRecordSource().getCurrentRecord();
@@ -324,22 +321,24 @@
if (wb != null && help != null) wb.showURL(help);
}
- public void loopBeginning(LoopEvent loopEvent)
- {
- }
-
- public void loopEnded(LoopEvent loopEvent)
- {
- setChanged();
+ public void process(LoopEvent event) {
+ switch (event.getEventType()) {
+ case SUSPEND:
+ case RESET:
+ setChanged();
+ default:
+ }
}
- public void loopReset(LoopEvent loopEvent)
- {
- setChanged();
- }
+// public void loopEnded(LoopEvent loopEvent)
+// {
+// setChanged();
+// }
+//
+// public void loopReset(LoopEvent loopEvent)
+// {
+// setChanged();
+// }
- public void progress(LoopProgressEvent loopProgressEvent)
- {
- }
}
}
\ No newline at end of file
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.15 -r1.15.6.1
--- LCSimEventBrowser.java 5 May 2010 18:09:03 -0000 1.15
+++ LCSimEventBrowser.java 10 May 2012 21:22:32 -0000 1.15.6.1
@@ -6,11 +6,6 @@
import java.awt.Font;
import java.util.ArrayList;
import java.util.Collections;
-import org.freehep.record.loop.SequentialRecordLoop;
-import org.freehep.record.loop.event.LoopEvent;
-import org.freehep.record.loop.event.LoopProgressEvent;
-import org.freehep.record.loop.event.RecordLoopListener;
-import org.freehep.record.source.SequentialRecordSource;
import org.freehep.util.commanddispatcher.CommandProcessor;
import javax.swing.event.ListSelectionEvent;
@@ -31,6 +26,10 @@
import javax.swing.event.TreeWillExpandListener;
import javax.swing.tree.ExpandVetoException;
import org.freehep.application.studio.Studio;
+import org.freehep.record.loop.LoopEvent;
+import org.freehep.record.loop.LoopListener;
+import org.freehep.record.loop.RecordLoop;
+import org.freehep.record.source.RecordSource;
import org.freehep.util.FreeHEPLookup;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
@@ -42,7 +41,7 @@
* @author tonyj
* @author gaede
*/
-public class LCSimEventBrowser extends JPanel implements RecordLoopListener, TreeSelectionListener, ListSelectionListener, TreeWillExpandListener
+public class LCSimEventBrowser extends JPanel implements LoopListener, TreeSelectionListener, ListSelectionListener, TreeWillExpandListener
{
private static final String noEvent = "No Event";
private static final TreeModel m_empty = new DefaultTreeModel(new DefaultMutableTreeNode(noEvent));
@@ -54,7 +53,7 @@
private CollectionTable m_table;
private CardLayout m_cardLayout = new CardLayout();
private JPanel m_switchPanel = new JPanel(m_cardLayout);
- private SequentialRecordLoop m_loop;
+ private RecordLoop m_loop;
private EventHeader m_lce;
private String m_selectedNode;
private Commands m_commands = new Commands();
@@ -84,7 +83,7 @@
lookup.add(new StringVecTableModel());
}
- public LCSimEventBrowser(Studio app, SequentialRecordLoop loop)
+ public LCSimEventBrowser(Studio app, RecordLoop loop)
{
super(new BorderLayout());
this.app = app;
@@ -105,23 +104,24 @@
Font newFont = new Font( "Monospaced", oldFont.getStyle() , oldFont.getSize() ) ;
m_table.setFont( newFont ) ;
}
+
public void addNotify()
{
- SequentialRecordSource source = m_loop.getRecordSource();
+ RecordSource source = m_loop.getRecordSource();
setSource(source);
- m_loop.addRecordLoopListener(this);
+ m_loop.addLoopListener(this);
super.addNotify();
}
public void removeNotify()
{
super.removeNotify();
- m_loop.removeRecordLoopListener(this);
+ m_loop.removeLoopListener(this);
}
public CommandProcessor getCommands()
{
return m_commands;
}
- private void setSource(SequentialRecordSource source)
+ private void setSource(RecordSource source)
{
try
{
@@ -183,24 +183,15 @@
}
m_commands.setChanged();
}
- public void loopBeginning(LoopEvent loopEvent)
- {
- }
-
- public void loopEnded(LoopEvent loopEvent)
- {
- SequentialRecordLoop loop = (SequentialRecordLoop) loopEvent.getSource();
- setSource(loop.getRecordSource());
- }
-
- public void loopReset(LoopEvent loopEvent)
- {
- SequentialRecordLoop loop = (SequentialRecordLoop) loopEvent.getSource();
- setSource(loop.getRecordSource());
- }
-
- public void progress(LoopProgressEvent loopProgressEvent)
- {
+
+ public void process(LoopEvent event) {
+ switch (event.getEventType()) {
+ case SUSPEND:
+ case RESET:
+ RecordLoop loop = event.getSource();
+ setSource(loop.getRecordSource());
+ default:
+ }
}
public void valueChanged(TreeSelectionEvent e)
lcsim/src/org/lcsim/util
diff -u -r1.7 -r1.7.8.1
--- DriverAdapter.java 11 Sep 2007 00:21:00 -0000 1.7
+++ DriverAdapter.java 10 May 2012 21:22:32 -0000 1.7.8.1
@@ -3,10 +3,10 @@
import java.io.IOException;
import org.freehep.jas.plugin.console.ConsoleOutputStream;
import org.freehep.jas.plugin.console.ConsoleService;
-import org.freehep.record.loop.event.ConfigurationEvent;
-import org.freehep.record.loop.event.RecordAdapter;
-import org.freehep.record.loop.event.RecordEvent;
-import org.freehep.record.loop.event.RecordSuppliedEvent;
+import org.freehep.record.loop.AbstractLoopListener;
+import org.freehep.record.loop.LoopEvent;
+import org.freehep.record.loop.RecordEvent;
+import org.freehep.record.loop.RecordListener;
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
@@ -14,9 +14,9 @@
/**
* Drive a Driver from a Record loop
* @author Tony Johnson
- * @version $Id: DriverAdapter.java,v 1.7 2007/09/11 00:21:00 tonyj Exp $
+ * @version $Id: DriverAdapter.java,v 1.7.8.1 2012/05/10 21:22:32 onoprien Exp $
*/
-public class DriverAdapter extends RecordAdapter
+public class DriverAdapter extends AbstractLoopListener implements RecordListener
{
private Driver driver;
// The console stuff is here to fix LCSMI-128. More logically this stuff should
@@ -37,28 +37,28 @@
if (cs != null) out = cs.getConsoleOutputStream("Record Loop", null);
}
- public void finish(RecordEvent event)
+ public void finish(LoopEvent event)
{
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),out);
driver.endOfData();
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),null);
}
- public void suspend(RecordEvent event)
+ public void suspend(LoopEvent event)
{
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),out);
driver.suspend();
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),null);
}
- public void resume(RecordEvent event)
+ public void resume(LoopEvent event)
{
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),out);
driver.resume();
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),null);
}
- public void recordSupplied(RecordSuppliedEvent rse)
+ public void recordSupplied(RecordEvent rse)
{
try
{
@@ -86,14 +86,7 @@
driver.detectorChanged(detector);
}
- public void configure(ConfigurationEvent event)
- {
- if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),out);
- driver.startOfData();
- if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),null);
- }
-
- public void reconfigure(ConfigurationEvent event)
+ public void start(LoopEvent event)
{
if (cs != null) cs.redirectStandardOutputOnThreadToConsole(Thread.currentThread(),out);
driver.startOfData();
lcsim/src/org/lcsim/util
diff -u -r1.10 -r1.10.2.1
--- OverlayDriver.java 22 Mar 2012 12:48:03 -0000 1.10
+++ OverlayDriver.java 10 May 2012 21:22:32 -0000 1.10.2.1
@@ -18,7 +18,7 @@
import org.apache.commons.math.MathException;
import org.apache.commons.math.distribution.DistributionFactory;
import org.apache.commons.math.distribution.PoissonDistribution;
-import org.freehep.record.source.EndOfSourceException;
+import org.freehep.record.source.NoSuchRecordException;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.event.EventHeader;
import org.lcsim.event.GenericObject;
@@ -31,7 +31,6 @@
import org.lcsim.event.base.BaseSimCalorimeterHit;
import org.lcsim.event.base.BaseSimTrackerHit;
import org.lcsim.geometry.Detector;
-import org.lcsim.util.Driver;
import org.lcsim.util.lcio.LCIOConstants;
import org.lcsim.util.lcio.LCIOUtil;
import org.lcsim.util.lcio.SIOMCParticle;
@@ -357,7 +356,7 @@
try {
lcio.next();
event = (EventHeader) lcio.getCurrentRecord();
- } catch (EndOfSourceException e) {
+ } catch (NoSuchRecordException e) {
try {
lcio.rewind();
lcio.next();
lcsim/src/org/lcsim/util/aida
diff -u -r1.9 -r1.9.6.1
--- AIDA.java 30 Jan 2009 00:07:50 -0000 1.9
+++ AIDA.java 10 May 2012 21:22:32 -0000 1.9.6.1
@@ -24,9 +24,9 @@
import java.lang.ref.WeakReference;
import org.freehep.application.Application;
import org.freehep.application.studio.Studio;
-import org.freehep.record.loop.SequentialRecordLoop;
-import org.freehep.record.loop.event.LoopEvent;
-import org.freehep.record.loop.event.RecordLoopAdapter;
+import org.freehep.record.loop.AbstractLoopListener;
+import org.freehep.record.loop.LoopEvent;
+import org.freehep.record.loop.RecordLoop;
/**
* A convenience class for creating and filling histograms.
@@ -65,8 +65,8 @@
Application app = Application.getApplication();
if (app instanceof Studio)
{
- SequentialRecordLoop loop = (SequentialRecordLoop) ((Studio) app).getLookup().lookup(SequentialRecordLoop.class);
- if (loop != null) loop.addRecordLoopListener(new RewindListener(this));
+ RecordLoop loop = (RecordLoop) ((Studio) app).getLookup().lookup(RecordLoop.class);
+ if (loop != null) loop.addLoopListener(new RewindListener(this));
}
}
catch (IOException x)
@@ -350,14 +350,14 @@
if (obj instanceof IBaseHistogram) ((IBaseHistogram) obj).reset();
}
}
- private static class RewindListener extends RecordLoopAdapter
+ private static class RewindListener extends AbstractLoopListener
{
private Reference weak;
RewindListener(AIDA aida)
{
weak = new WeakReference(aida);
}
- public void loopReset(LoopEvent loopEvent)
+ public void reset(LoopEvent loopEvent)
{
AIDA aida = (AIDA) weak.get();
if (aida != null)
@@ -366,8 +366,8 @@
}
else
{
- SequentialRecordLoop loop = (SequentialRecordLoop) loopEvent.getSource();
- loop.removeRecordLoopListener(this);
+ RecordLoop loop = (RecordLoop) loopEvent.getSource();
+ loop.removeLoopListener(this);
}
}
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.7 -r1.7.2.1
--- LCIOReader.java 2 Sep 2008 21:38:15 -0000 1.7
+++ LCIOReader.java 10 May 2012 21:22:32 -0000 1.7.2.1
@@ -4,6 +4,7 @@
import hep.io.sio.SIOInputStream;
import hep.io.sio.SIOReader;
import hep.io.sio.SIORecord;
+import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -85,4 +86,19 @@
return event;
}
}
+ public int skipEventsChecked(int numberToSkip) throws IOException
+ {
+ int i=0;
+ while(i < numberToSkip)
+ {
+ try {
+ SIORecord record = reader.readRecord();
+ String name = record.getRecordName();
+ if (LCIOConstants.eventRecordName.equals(name)) i++;
+ } catch (EOFException x) {
+ break;
+ }
+ }
+ return i;
+ }
}
lcsim/src/org/lcsim/util/loop
diff -u -r1.1 -r1.1.14.1
--- EventGeneratorRecordSource.java 14 Mar 2005 16:11:37 -0000 1.1
+++ EventGeneratorRecordSource.java 10 May 2012 21:22:32 -0000 1.1.14.1
@@ -1,69 +1,58 @@
package org.lcsim.util.loop;
-import hep.physics.event.HEPEvent;
-import hep.physics.event.generator.EventGenerator;
-
import java.io.IOException;
+import hep.physics.event.HEPEvent;
+import hep.physics.event.generator.EventGenerator;
+import org.freehep.record.source.AbstractRecordSource;
import org.freehep.record.source.NoSuchRecordException;
-import org.freehep.record.source.SequentialRecordSource;
/**
*
* @author Tony Johnson
*/
-public class EventGeneratorRecordSource implements SequentialRecordSource
-{
- private EventGenerator generator;
- private String name;
- private HEPEvent current;
-
- public EventGeneratorRecordSource(EventGenerator generator, String name)
- {
- this.generator = generator;
- this.name = name;
- }
-
- public void rewind() throws IOException
- {
- generator.reset();
- }
-
- public String getSourceName()
- {
- return name;
- }
-
- public void close() throws IOException
- {
- }
-
- public Class getRecordClass()
- {
- return HEPEvent.class;
- }
-
- public long getEstimatedSize()
- {
- return UNKNOWN;
- }
-
- public Object getCurrentRecord() throws NoSuchRecordException
- {
- if (current == null) throw new NoSuchRecordException();
- return current;
- }
-
- public void next()
- {
- current = generator.generate();
- }
-
- public void releaseRecord(Object record)
- {
- }
- EventGenerator getGenerator()
- {
- return generator;
- }
+public class EventGeneratorRecordSource extends AbstractRecordSource {
+
+ private EventGenerator generator;
+ private HEPEvent current;
+
+ public EventGeneratorRecordSource(EventGenerator generator, String name) {
+ super(name);
+ this.generator = generator;
+ }
+
+ public boolean supportsRewind() {
+ return true;
+ }
+
+ public boolean hasRewind() {
+ return current != null;
+ }
+
+ public void rewind() throws IOException {
+ generator.reset();
+ current = null;
+ }
+
+ public Class<?> getRecordClass() {
+ return HEPEvent.class;
+ }
+
+ public Object getCurrentRecord() throws IOException {
+ if (current == null) throw new IllegalStateException();
+ return current;
+ }
+
+ public boolean supportsNext() {
+ return true;
+ }
+
+ public void next() throws IOException, NoSuchRecordException {
+ current = generator.generate();
+ if (current == null) throw new NoSuchRecordException();
+ }
+
+ EventGenerator getGenerator() {
+ return generator;
+ }
}
\ No newline at end of file
lcsim/src/org/lcsim/util/loop
diff -u -r1.5 -r1.5.6.1
--- LCIOEventSource.java 17 Nov 2009 16:53:49 -0000 1.5
+++ LCIOEventSource.java 10 May 2012 21:22:32 -0000 1.5.6.1
@@ -4,132 +4,238 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.freehep.record.source.EndOfSourceException;
+
+import org.freehep.record.source.AbstractRecordSource;
import org.freehep.record.source.NoSuchRecordException;
-import org.freehep.record.source.SequentialRecordSource;
import org.lcsim.event.EventHeader;
import org.lcsim.util.lcio.*;
/**
* Convert an LCIOReader to a SequentialRecordSource
* @author tonyj
- * @version $Id: LCIOEventSource.java,v 1.5 2009/11/17 16:53:49 tonyj Exp $
+ * @version $Id: LCIOEventSource.java,v 1.5.6.1 2012/05/10 21:22:32 onoprien Exp $
*/
-public class LCIOEventSource implements SequentialRecordSource
-{
- private List<File> files;
- private boolean atEnd;
- private LCIOReader reader;
- private EventHeader currentEvent;
- private int currentFile = 0;
- private String name;
-
- /**
- * Create an LCIO event source for reading a single LCIO file
- * @param file The file to read
- */
- public LCIOEventSource(File file) throws IOException
- {
- this.reader = new LCIOReader(file);
- this.files = Collections.singletonList(file);
- this.name = file.getName();
- }
- /**
- * Create an LCIO event source for reading a set of LCIO files.
- * @param name The name of the collection of event files
- * @param files The list of files to read.
- */
- public LCIOEventSource(String name, List<File> files) throws IOException
- {
- if (files.isEmpty()) throw new IOException("File list is empty");
- this.reader = new LCIOReader(files.get(0));
- this.files = files;
- this.name = name;
- }
- /**
- * Create an LCIO event source that will read a set of LCIO files
- * @param list The list of files to open
- */
- public LCIOEventSource(FileList list) throws FileNotFoundException, IOException
- {
- this.name = list.getTitle();
- this.files = list.getFileList();
- if (files.size() == 0) throw new IOException("File list is empty");
- this.reader = new LCIOReader(files.get(0));
- }
-
- public Object getCurrentRecord() throws NoSuchRecordException, IOException, EndOfSourceException
- {
- if (atEnd) throw new EndOfSourceException();
- if (currentEvent == null) throw new NoSuchRecordException();
- return currentEvent;
- }
-
- public long getEstimatedSize()
- {
- return SequentialRecordSource.UNKNOWN;
- }
-
- public Class getRecordClass()
- {
- return EventHeader.class;
- }
-
- public String getSourceName()
- {
- return name;
- }
-
- public void next() throws IOException
- {
- for (;;)
- {
- try
- {
- currentEvent = reader.read();
- currentEvent.put("INPUT_FILE",files.get(currentFile));
- }
- catch (EOFException x)
- {
- currentFile++;
- if (currentFile >= files.size()) atEnd = true;
- else
- {
- reader.close();
- reader = new LCIOReader(files.get(currentFile));
- continue;
- }
- }
- return;
+public class LCIOEventSource extends AbstractRecordSource {
+
+ private List<File> files;
+ private boolean atEnd = false;
+ private boolean atStart = true;
+ private LCIOReader reader;
+ private EventHeader currentEvent;
+ private int currentFile = 0;
+
+ private long _index = -1L;
+ private long[] _size;
+
+ /**
+ * Create an LCIO event source for reading a single LCIO file
+ *
+ * @param file The file to read
+ */
+ public LCIOEventSource(File file) throws IOException {
+ super(file.getName());
+ this.reader = new LCIOReader(file);
+ this.files = Collections.singletonList(file);
+ _size = new long[1]; _size[0] = -1L;
+ }
+
+ /**
+ * Create an LCIO event source for reading a set of LCIO files.
+ *
+ * @param name The name of the collection of event files
+ * @param files The list of files to read.
+ */
+ public LCIOEventSource(String name, List<File> files) throws IOException {
+ super(name);
+ if (files.isEmpty()) throw new IOException("File list is empty");
+ this.reader = new LCIOReader(files.get(0));
+ this.files = files;
+ _size = new long[files.size()]; Arrays.fill(_size, -1L);
+ }
+
+ /**
+ * Create an LCIO event source that will read a set of LCIO files
+ *
+ * @param list The list of files to open
+ */
+ public LCIOEventSource(FileList list) throws FileNotFoundException, IOException {
+ super(list.getTitle());
+ this.files = list.getFileList();
+ if (files.isEmpty()) throw new IOException("File list is empty");
+ this.reader = new LCIOReader(files.get(0));
+ _size = new long[files.size()]; Arrays.fill(_size, -1L);
+ }
+
+
+ public Object getCurrentRecord() throws IOException {
+ if (_index == -1L) throw new IllegalStateException();
+ if (currentEvent == null) throw new IOException();
+ return currentEvent;
+ }
+
+ public long getCurrentIndex() {
+ return _index;
+ }
+
+ public Class<?> getRecordClass() {
+ return EventHeader.class;
+ }
+
+ public boolean supportsCurrent() {return true;}
+
+ public boolean supportsNext() {return true;}
+
+ public boolean supportsPrevious() {return true;}
+
+ public boolean supportsIndex() {return true;}
+
+ public boolean supportsShift() {return true;}
+
+ public boolean supportsRewind() {return true;}
+
+ public boolean hasCurrent() {
+ return _index != -1L;
+ }
+
+ public boolean hasNext() {
+ return !atEnd;
+ }
+ public boolean hasPrevious() {
+ return _index > 0L;
+ }
+
+ public boolean hasIndex(long index) {
+ return index >= 0L;
+ }
+
+ public boolean hasShift(long numberOfRecords) {
+ return hasIndex(_index + numberOfRecords);
+ }
+
+ public boolean hasRewind() {
+ return _index != -1L;
+ }
+
+ public void current() throws IOException, NoSuchRecordException {
+ jump(_index);
+ }
+
+ public void next() throws IOException, NoSuchRecordException {
+ for (;;) {
+ try {
+ currentEvent = reader.read();
+ currentEvent.put("INPUT_FILE", files.get(currentFile));
+ _index++;
+ } catch (EOFException x) {
+ _size[currentFile] = _index;
+ if (currentFile + 1 >= files.size()) {
+ atEnd = true;
+ throw new NoSuchRecordException();
+ } else {
+ currentFile++;
+ reader.close();
+ reader = new LCIOReader(files.get(currentFile));
+ continue;
+ }
}
- }
- public void releaseRecord(Object obj)
- {
- currentEvent = null;
- }
- public void rewind() throws IOException
- {
- currentFile = 0;
+ return;
+ }
+ }
+
+ public void previous() throws IOException, NoSuchRecordException {
+ jump(_index-1);
+ }
+
+ public void jump(long index) throws IOException, NoSuchRecordException {
+ if (index < 0L) throw new NoSuchRecordException();
+ long i = _index;
+ int f = -1;
+ while (++f < files.size() && _size[f] != -1L && _size[f] < index);
+ if (f >= files.size()) throw new NoSuchRecordException();
+ atEnd = false;
+ long recoveryTarget = _index;
+ if (f != currentFile || index <= _index) {
reader.close();
- reader = new LCIOReader(files.get(currentFile));
- atEnd = false;
- }
- public void close() throws IOException
- {
- if (reader != null)
- {
- reader.close();
- reader = null;
+ reader = new LCIOReader(files.get(f));
+ i = (f == 0) ? -1L : _size[f-1];
+ }
+ int skipMax = Integer.MAX_VALUE - 10;
+ for (long skip = index - i - 1L; skip > 0L; ) {
+ int skipNow = skip > skipMax ? skipMax : (int)skip ;
+ skip -= skipNow;
+ while (true) {
+ int skipped = reader.skipEventsChecked(skipNow);
+ i += skipped;
+ if (skipped == skipNow) {
+ break;
+ } else {
+ skipNow -= skipped;
+ reader.close();
+ _size[f++] = i;
+ if (f < files.size()) {
+ reader = new LCIOReader(files.get(f));
+ } else {
+ reader = new LCIOReader(files.get(0));
+ if (_index != -1L) {
+ currentFile = 0;
+ atEnd = false;
+ _index = -1L;
+ try {
+ jump(recoveryTarget);
+ } catch (NoSuchRecordException x) {
+ throw new IOException(x);
+ }
+ }
+ throw new NoSuchRecordException();
+ }
+ }
}
- }
- public void finalize()
- {
- try
- {
- close();
+ }
+ _index = i;
+ currentFile = f;
+ try {
+ next();
+ } catch (NoSuchRecordException x) {
+ try {
+ jump(recoveryTarget);
+ } catch (NoSuchRecordException xx) {
+ throw new IOException(x);
}
- catch (IOException x) {}
- }
+ }
+ }
+
+ public void shift(long numberOfRecords) throws IOException, NoSuchRecordException {
+ jump(_index + numberOfRecords);
+ }
+
+ public void rewind() throws IOException {
+ currentFile = 0;
+ reader.close();
+ reader = new LCIOReader(files.get(currentFile));
+ atEnd = false;
+ _index = -1L;
+ currentEvent = null;
+ }
+
+ public void close() throws IOException {
+ if (reader != null) {
+ reader.close();
+ reader = null;
+ }
+ currentEvent = null;
+ }
+
+ public void releaseRecord(Object obj) {
+ currentEvent = null;
+ }
+
+ public void finalize() {
+ try {
+ close();
+ } catch (IOException x) {
+ }
+ }
}
\ No newline at end of file
lcsim/src/org/lcsim/util/loop
diff -u -r1.10 -r1.10.6.1
--- LCSimLoop.java 29 Jan 2009 23:50:32 -0000 1.10
+++ LCSimLoop.java 10 May 2012 21:22:32 -0000 1.10.6.1
@@ -3,13 +3,10 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
-import java.util.TooManyListenersException;
-import org.freehep.record.loop.LoopException;
-import org.freehep.record.loop.SequentialRecordLoopImpl;
+import org.freehep.record.loop.DefaultRecordLoop;
import org.freehep.record.source.NoSuchRecordException;
-import org.freehep.record.source.RandomAccessRecordSource;
-import org.freehep.record.source.SequentialRecordSource;
+import org.freehep.record.source.RecordSource;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.conditions.ConditionsManagerImplementation;
import org.lcsim.conditions.ConditionsReader;
@@ -21,7 +18,7 @@
* A main loop which can be used for standalone jobs (run outside of JAS).
* @author Tony Johnson
*/
-public class LCSimLoop extends SequentialRecordLoopImpl
+public class LCSimLoop extends DefaultRecordLoop
{
private Driver top = new Driver();
@@ -31,14 +28,9 @@
public LCSimLoop()
{
LCSimConditionsManagerImplementation.register();
- try
- {
- super.addRecordListener(new DriverAdapter(top));
- }
- catch (TooManyListenersException x)
- {
- throw new RuntimeException("Can't happen!",x);
- }
+ DriverAdapter da = new DriverAdapter(top);
+ addRecordListener(da);
+ addLoopListener(da);
}
/**
@@ -110,32 +102,31 @@
*/
public void skip(long recordsToSkip) throws NoSuchRecordException, IOException
{
- SequentialRecordSource rs = getRecordSource();
- if (rs instanceof RandomAccessRecordSource)
- {
- RandomAccessRecordSource rrs = (RandomAccessRecordSource) rs;
- rrs.goToRecord((int) (rrs.currentIndex()+recordsToSkip));
- }
- else
- {
- for (long i=0; i<recordsToSkip; i++)
- {
- rs.next();
- }
- }
+ if (recordsToSkip < 0L) throw new IllegalArgumentException();
+ RecordSource rs = getRecordSource();
+ if (rs.supportsIndex()) {
+ try {
+ rs.jump(rs.getCurrentIndex() + recordsToSkip);
+ return;
+ } catch (IllegalStateException x) {}
+ }
+ for (long i=0; i<recordsToSkip; i++) rs.next();
}
/**
* Loop over a given number of events, or until no more events are available.
* Statistics will be printed to standard output the end of the loop.
+ *
* @param number The number of events to loop over, or <CODE>-1</CODE> to loop
* until no more data is available.
- * @throws org.freehep.record.loop.LoopException If there is a problem iterating over events
- * (for example no event source specified)
- * @throws java.io.IOException If there is an IO exception reading or writing events
+ *
+ * @throws IllegalStateException If there is a problem iterating over events
+ * (for example no event source specified).
+ * @throws IOException If there is an IO exception reading or writing events.
+ *
* @return The number of events actually iterated over.
*/
- public long loop(long number) throws LoopException, IOException
+ public long loop(long number) throws IOException
{
return loop(number,System.out);
}
@@ -143,21 +134,26 @@
/**
* Loop for the given number of events, optionally printing statistics to the
* given output stream
- * @param number The number of events to loop over, or <CODE>-1</CODE> to iterate
+ *
+ * @param number The number of events to loop over, or <CODE>-1</CODE> to loop
* until no more data is available.
- * @param out The stream to which statistics should be output at the end of the
- * loop, or <CODE>null</CODE> to suppress statistics printing.
- * @throws org.freehep.record.loop.LoopException If the loop cannot run, for instance because no input event source
- * has been set.
- * @throws java.io.IOException If an IOException occurs while reading or writing events.
+ *
+ * @throws IllegalStateException If there is a problem iterating over events
+ * (for example no event source specified).
+ * @throws IOException If there is an IO exception reading or writing events.
+ *
* @return The number of events actually iterated over.
*/
- public long loop(long number, PrintStream out) throws LoopException, IOException
+ public long loop(long number, PrintStream out) throws IOException
{
top.clearStatistics();
- long result = super.loop(number);
+ if (number < 0L) {
+ execute(Command.GO);
+ } else {
+ execute(Command.GO_N, number);
+ }
if (out != null) printStatistics(out);
- return result;
+ return getCountableConsumed();
}
/**
lcsim/src/org/lcsim/util/loop
diff -u -r1.8 -r1.8.6.1
--- StdhepEventSource.java 17 Nov 2009 16:53:49 -0000 1.8
+++ StdhepEventSource.java 10 May 2012 21:22:32 -0000 1.8.6.1
@@ -1,206 +1,197 @@
package org.lcsim.util.loop;
-import hep.io.stdhep.StdhepEvent;
-import hep.io.stdhep.StdhepReader;
-import hep.io.stdhep.StdhepRecord;
-import hep.physics.particle.properties.ParticlePropertyManager;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
-import org.freehep.record.source.EndOfSourceException;
+
+import hep.io.stdhep.StdhepEvent;
+import hep.io.stdhep.StdhepReader;
+import hep.io.stdhep.StdhepRecord;
+import hep.physics.particle.properties.ParticlePropertyManager;
+import org.freehep.record.source.AbstractRecordSource;
import org.freehep.record.source.NoSuchRecordException;
-import org.freehep.record.source.RandomAccessRecordSource;
+import org.freehep.record.source.RecordSource;
import org.lcsim.event.EventHeader;
import org.lcsim.event.util.LCSimFactory;
/**
- * Convert an LCIOReader to a SequentialRecordSource
+ * {@link RecordSource} implementation that wraps {@link StdhepReader}.
+ *
* @author tonyj
- * @version $Id: StdhepEventSource.java,v 1.8 2009/11/17 16:53:49 tonyj Exp $
+ * @version $Id: StdhepEventSource.java,v 1.8.6.1 2012/05/10 21:22:32 onoprien Exp $
*/
-public class StdhepEventSource implements RandomAccessRecordSource
-{
- private List<File> files;
- private String name;
- private boolean atEnd;
- private StdhepReader reader;
- private final StdhepConverter converter;
- private EventHeader currentEvent;
- private int currentEventNumber;
- private int currentFile = 0;
-
- /**
- * Create an event source from a single stdhep file
- */
- public StdhepEventSource(File file, String detectorName) throws IOException
- {
- reader = new StdhepReader(file.getAbsolutePath());
- converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(),new LCSimFactory(detectorName));
- this.files = Collections.singletonList(file);
- this.name = file.getName();
- }
- /**
- * Create an event source from a list of stdhep files
- */
- public StdhepEventSource(FileList list, String detectorName) throws IOException
- {
- this.name = list.getTitle();
- this.files = list.getFileList();
- if (files.size() == 0) throw new IOException("File list is empty");
+public class StdhepEventSource extends AbstractRecordSource {
+
+ private List<File> files;
+ private boolean atEnd;
+ private StdhepReader reader;
+ private final StdhepConverter converter;
+ private EventHeader currentEvent;
+ private long currentEventNumber = -1L;
+ private int currentFile = 0;
+
+ /**
+ * Create an event source from a single stdhep file
+ */
+ public StdhepEventSource(File file, String detectorName) throws IOException {
+ super(file.getName());
+ reader = new StdhepReader(file.getAbsolutePath());
+ converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(), new LCSimFactory(detectorName));
+ this.files = Collections.singletonList(file);
+ }
+
+ /**
+ * Create an event source from a list of stdhep files
+ */
+ public StdhepEventSource(FileList list, String detectorName) throws IOException {
+ super(list.getTitle());
+ this.files = list.getFileList();
+ if (files.isEmpty()) throw new IOException("File list is empty");
+ reader = new StdhepReader(files.get(0).getAbsolutePath());
+ converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(), new LCSimFactory(detectorName));
+ }
+
+ public Object getCurrentRecord() throws IOException {
+ if (currentEvent == null) throw new IllegalStateException();
+ return currentEvent;
+ }
+
+ public long size() {
+ if (files.size() == 1) return reader.getNumberOfEvents();
+ throw new UnsupportedOperationException();
+ }
+
+ public Class<?> getRecordClass() {
+ return EventHeader.class;
+ }
+
+ public boolean supportsNext() {
+ return true;
+ }
+
+ public boolean hasNext() {
+ return !atEnd;
+ }
+
+ public void next() throws IOException, NoSuchRecordException {
+ for (;;) {
+ try {
+ for (;;) {
+ StdhepRecord record = reader.nextRecord();
+ if (record instanceof StdhepEvent) {
+ currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
+ currentEvent.put("INPUT_FILE", files.get(currentFile));
+ currentEventNumber++;
+ break;
+ }
+ }
+ } catch (EOFException x) {
+ currentFile++;
+ if (currentFile >= files.size()) {
+ atEnd = true;
+ throw new NoSuchRecordException();
+ } else {
+ reader.close();
+ reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
+ continue;
+ }
+ }
+ return;
+ }
+ }
+
+ public void releaseRecord(Object obj) {
+ currentEvent = null;
+ }
+
+ public boolean supportsRewind() {
+ return true;
+ }
+
+ public boolean hasRewind() {
+ return currentEventNumber != -1L;
+ }
+
+ public void rewind() throws IOException {
+ if (currentFile == 0) {
+ reader.rewind();
+ } else {
+ currentFile = 0;
+ reader.close();
reader = new StdhepReader(files.get(0).getAbsolutePath());
- converter = new StdhepConverter(ParticlePropertyManager.getParticlePropertyProvider(),new LCSimFactory(detectorName));
- }
-
- public Object getCurrentRecord() throws NoSuchRecordException, IOException, EndOfSourceException
- {
- if (atEnd) throw new EndOfSourceException();
- if (currentEvent == null) throw new NoSuchRecordException();
- return currentEvent;
- }
-
- public long getEstimatedSize()
- {
- return files.size() == 1 ? reader.getNumberOfEvents() : -1;
- }
-
- public Class getRecordClass()
- {
- return EventHeader.class;
- }
-
- public String getSourceName()
- {
- return name;
- }
-
- public void next() throws IOException
- {
- for (;;)
- {
- try
- {
- for (;;)
- {
- StdhepRecord record = reader.nextRecord();
- if (record instanceof StdhepEvent)
- {
- currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
- currentEvent.put("INPUT_FILE", files.get(currentFile));
- currentEventNumber++;
- break;
- }
- }
- }
- catch (EOFException x)
- {
- currentFile++;
- if (currentFile >= files.size()) atEnd = true;
- else
- {
- reader.close();
- reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
- continue;
- }
- }
- return;
- }
- }
- public void releaseRecord(Object obj)
- {
- currentEvent = null;
- }
- public void rewind() throws IOException
- {
- if (currentFile == 0)
- {
- reader.rewind();
- }
- else
- {
- currentFile = 0;
- reader.close();
- reader = new StdhepReader(files.get(0).getAbsolutePath());
- }
- atEnd = false;
- currentEventNumber = 0;
- }
- public void close() throws IOException
- {
- if (reader != null)
- {
- reader.close();
- reader = null;
- }
- }
- public void finalize()
- {
- try
- {
- close();
- }
- catch (IOException x)
- {}
- }
-
- public void goToRecord(int target) throws NoSuchRecordException
- {
- try
- {
- for (;;)
- {
- try
- {
- if (target < currentEventNumber) rewind();
- if (target == currentEventNumber) return;
-
- for (;;)
- {
- StdhepRecord record = reader.nextRecord();
- if (record instanceof StdhepEvent)
- {
- currentEventNumber++;
- if (currentEventNumber == target)
- {
- currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
- break;
- }
- }
- }
+ }
+ atEnd = false;
+ currentEventNumber = -1L;
+ currentEvent = null;
+ }
+ public void close() throws IOException {
+ if (reader != null) {
+ reader.close();
+ reader = null;
+ }
+ currentEvent = null;
+ }
+
+ public void finalize() {
+ try {
+ close();
+ } catch (IOException x) {
+ }
+ }
+
+ public boolean supportsIndex() {
+ return true;
+ }
+
+ public boolean hasIndex(long index) {
+ try {
+ return index < size();
+ } catch (UnsupportedOperationException x) {
+ return index >= 0L;
+ }
+ }
+
+ public void jump(long index) throws IOException, NoSuchRecordException {
+ if (index < 0L) throw new NoSuchRecordException();
+ if (index == currentEventNumber) return;
+ if (index < currentEventNumber) rewind();
+ try {
+ for (;;) {
+ try {
+ for (;;) {
+ StdhepRecord record = reader.nextRecord();
+ if (record instanceof StdhepEvent) {
+ currentEventNumber++;
+ if (currentEventNumber == index) {
+ currentEvent = (EventHeader) converter.convert((StdhepEvent) record);
+ currentEvent.put("INPUT_FILE", files.get(currentFile));
+ return;
+ }
}
- catch (EOFException x)
- {
- currentFile++;
- if (currentFile >= files.size())
- {
- atEnd = true;
- NoSuchRecordException xx = new NoSuchRecordException();
- xx.initCause(x);
- throw xx;
- }
- else
- {
- reader.close();
- reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
- continue;
- }
- }
- return;
- }
- }
- catch (IOException x)
- {
- NoSuchRecordException xx = new NoSuchRecordException();
- xx.initCause(x);
- throw xx;
- }
- }
-
- public int currentIndex()
- {
- return currentEventNumber;
- }
+ }
+ } catch (EOFException x) {
+ currentFile++;
+ if (currentFile >= files.size()) {
+ atEnd = true;
+ throw new NoSuchRecordException(x);
+ } else {
+ reader.close();
+ reader = new StdhepReader(files.get(currentFile).getAbsolutePath());
+ continue;
+ }
+ }
+ }
+ } catch (IOException x) {
+ throw new NoSuchRecordException(x);
+ }
+ }
+
+ public long getCurrentIndex() {
+ return currentEventNumber;
+ }
+
}
\ No newline at end of file
lcsim/test/org/lcsim
diff -u -r1.1 -r1.1.2.1
--- CalHitStepPosTest.java 27 Feb 2012 22:09:23 -0000 1.1
+++ CalHitStepPosTest.java 10 May 2012 21:22:32 -0000 1.1.2.1
@@ -11,7 +11,6 @@
import junit.framework.TestCase;
-import org.freehep.record.loop.LoopException;
import org.lcsim.event.EventHeader;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.geometry.IDDecoder;
@@ -38,8 +37,6 @@
}
try {
loop.loop(-1, null);
- } catch (LoopException x) {
- throw new RuntimeException(x);
} catch (IOException x) {
throw new RuntimeException(x);
}
lcsim/test/org/lcsim
diff -u -r1.5 -r1.5.6.1
--- HitMixingTest.java 25 Mar 2009 01:01:15 -0000 1.5
+++ HitMixingTest.java 10 May 2012 21:22:32 -0000 1.5.6.1
@@ -10,7 +10,6 @@
import junit.framework.TestCase;
-import org.freehep.record.loop.LoopException;
import org.lcsim.event.EventHeader;
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.SimCalorimeterHit;
@@ -19,14 +18,13 @@
import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCSimLoop;
-import static java.lang.Math.abs;
public class HitMixingTest extends TestCase
{
private static int nhits;
private static Map<SimCalorimeterHit,LCMetaData> origMeta = new HashMap<SimCalorimeterHit,LCMetaData>();
- public void testMix() throws IOException, LoopException
+ public void testMix() throws IOException
{
FileCache cache = new FileCache();
File events = cache.getCachedFile(new URL("http://www.lcsim.org/test/lcio/muons10_Theta4-176_1-10GeV_SLIC-v2r5p3_geant4-v9r1p2_LCPhys_sid01.slcio"));
lcsim/test/org/lcsim
diff -u -r1.3 -r1.3.8.1
--- LCIOReadTest.java 11 Sep 2007 00:21:00 -0000 1.3
+++ LCIOReadTest.java 10 May 2012 21:22:32 -0000 1.3.8.1
@@ -47,7 +47,7 @@
loop.add(new ReadDriver());
loop.add(new LCIODriver(new TestOutputFile("LCIOReadTest.slcio")));
loop.loop(-1, null);
- assertEquals(200, loop.getTotalCountableSupplied());
+ assertEquals(200, loop.getTotalCountableConsumed());
loop.dispose();
}
@@ -65,7 +65,7 @@
LCSimLoop loop = new LCSimLoop();
loop.setLCIORecordSource(es);
loop.loop(-1, null);
- assertEquals(400, loop.getTotalCountableSupplied());
+ assertEquals(400, loop.getTotalCountableConsumed());
loop.dispose();
}
public void testSkip() throws Exception
@@ -79,7 +79,7 @@
loop.add(new CheatClusterDriver());
loop.skip(150);
loop.loop(-1, null);
- assertEquals(50, loop.getTotalCountableSupplied());
+ assertEquals(50, loop.getTotalCountableConsumed());
loop.dispose();
}
public void testSkip0() throws Exception
@@ -96,7 +96,7 @@
long stop = System.nanoTime();
System.out.println("Skip took "+(stop-start)/1000000.+"ms");
loop.loop(1000, null);
- assertEquals(1000, loop.getTotalCountableSupplied());
+ assertEquals(1000, loop.getTotalCountableConsumed());
loop.dispose();
}
public void testSkipSpeed() throws Exception
@@ -113,7 +113,7 @@
long stop = System.nanoTime();
System.out.println("Skip took "+(stop-start)/1000000.+"ms");
loop.loop(-1, null);
- assertEquals(50, loop.getTotalCountableSupplied());
+ assertEquals(50, loop.getTotalCountableConsumed());
loop.dispose();
}
private class ReadDriver extends Driver
lcsim/test/org/lcsim
diff -u -r1.3 -r1.3.6.1
--- ReferenceIOTest.java 10 Jul 2009 23:22:09 -0000 1.3
+++ ReferenceIOTest.java 10 May 2012 21:22:32 -0000 1.3.6.1
@@ -6,12 +6,10 @@
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
-import org.freehep.record.loop.LoopException;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
import org.lcsim.util.Driver;
import org.lcsim.util.cache.FileCache;
-import org.lcsim.util.lcio.*;
import org.lcsim.util.loop.LCIODriver;
import org.lcsim.util.loop.LCSimLoop;
import org.lcsim.util.test.TestUtil.TestOutputFile;
@@ -26,7 +24,7 @@
{
super(testName);
}
- public void testReferences() throws IOException, LoopException
+ public void testReferences() throws IOException
{
final String detectorName = "sidaug05";
URL url = new URL("http://www.lcsim.org/test/stdhep/pythiaZZ_nunu_bbbar-0-1.stdhep");
@@ -40,7 +38,7 @@
loop.add(new ReferenceDriver());
loop.add(new LCIODriver(outputFile));
loop.loop(1, null);
- assertEquals(1,loop.getTotalCountableSupplied());
+ assertEquals(1,loop.getTotalCountableConsumed());
loop.dispose();
// Now read it back in
lcsim/test/org/lcsim
diff -u -r1.4 -r1.4.6.1
--- StdhepFilterTest.java 17 Mar 2009 22:44:51 -0000 1.4
+++ StdhepFilterTest.java 10 May 2012 21:22:32 -0000 1.4.6.1
@@ -36,14 +36,12 @@
URL url = new URL("http://www.lcsim.org/test/stdhep/pythiaZZ_nunu_bbbar-0-1.stdhep");
FileCache cache = new FileCache();
File stdhep = cache.getCachedFile(url);
-
StdhepDriver writer = new StdhepDriver((new TestOutputFile("filter.stdhep")).getAbsolutePath(),"myTitle","myComment",0);
-
LCSimLoop loop = new LCSimLoop();
loop.setStdhepRecordSource(stdhep,detectorName);
loop.add(writer);
loop.loop(-1, null);
- assertEquals(1,loop.getTotalCountableSupplied());
+ assertEquals(1,loop.getTotalCountableConsumed());
loop.dispose();
}
}
lcsim/test/org/lcsim/recon/cluster/fixedcone
diff -u -r1.13 -r1.13.6.1
--- FixedConeClustererTest.java 17 Aug 2011 22:55:20 -0000 1.13
+++ FixedConeClustererTest.java 10 May 2012 21:22:33 -0000 1.13.6.1
@@ -7,7 +7,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.freehep.record.loop.LoopException;
import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCIODriver;
import org.lcsim.util.loop.LCSimLoop;
@@ -31,7 +30,7 @@
return new TestSuite(FixedConeClustererTest.class);
}
- public static void testNNClusterer() throws IOException, LoopException
+ public static void testNNClusterer() throws IOException
{
URL url = new URL("http://www.lcsim.org/test/lcio/mu_10GeV_Theta90_SLIC-v2r5p3_geant4-v9r1p2_LCPhys_sid01.slcio");
lcsim/test/org/lcsim/recon/cluster/nn
diff -u -r1.8 -r1.8.8.1
--- NearestNeighborClustererTest.java 11 Sep 2007 00:21:03 -0000 1.8
+++ NearestNeighborClustererTest.java 10 May 2012 21:22:33 -0000 1.8.8.1
@@ -11,7 +11,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.freehep.record.loop.LoopException;
import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCIODriver;
import org.lcsim.util.loop.LCSimLoop;
@@ -32,7 +31,7 @@
return new TestSuite(NearestNeighborClustererTest.class);
}
- public static void testNNClusterer() throws IOException, LoopException
+ public static void testNNClusterer() throws IOException
{
URL url = new URL("http://www.lcsim.org/test/lcio/muons_SLIC_v1r9p1_sidmay05.slcio");
FileCache cache = new FileCache();
lcsim/test/org/lcsim/recon/vertexing/billoir
diff -u -r1.7 -r1.7.6.1
--- VertexFitterTest.java 17 Mar 2009 22:44:51 -0000 1.7
+++ VertexFitterTest.java 10 May 2012 21:22:33 -0000 1.7.6.1
@@ -1,7 +1,7 @@
package org.lcsim.recon.vertexing.billoir;
/**
- * @version $Id: VertexFitterTest.java,v 1.7 2009/03/17 22:44:51 jeremy Exp $
+ * @version $Id: VertexFitterTest.java,v 1.7.6.1 2012/05/10 21:22:33 onoprien Exp $
*/
@@ -27,6 +27,7 @@
import Jama.Matrix;
import Jama.util.Maths;
+import java.io.IOException;
/**
* @author jstrube
@@ -56,7 +57,7 @@
fitter = new BilloirFitter(5);
}
- public void testFit() throws org.freehep.record.loop.LoopException, java.io.IOException {
+ public void testFit() throws IOException {
loop.add(new MCFast());
loop.add(new TrackFitDriver());
loop.loop(-1, null);
lcsim/test/org/lcsim/recon/vertexing/zvtop4
diff -u -r1.8 -r1.8.6.1
--- ZvTrackTest.java 25 Mar 2009 01:01:15 -0000 1.8
+++ ZvTrackTest.java 10 May 2012 21:22:33 -0000 1.8.6.1
@@ -5,7 +5,6 @@
import java.net.URL;
import java.util.List;
-import org.freehep.record.loop.LoopException;
import org.lcsim.event.EventHeader;
import org.lcsim.event.Track;
import org.lcsim.mc.fast.MCFast;
@@ -150,7 +149,6 @@
loop.add(new MCFast());
loop.add(new TransformLocationTest());
loop.loop(-1, null);
- } catch (LoopException e) {
} catch (IOException e) {
}
}
CVSspam 0.2.12