lcsim/src/org/lcsim/util/loop
diff -u -r1.6 -r1.7
--- LCSimLoop.java 11 Sep 2007 00:20:59 -0000 1.6
+++ LCSimLoop.java 11 Sep 2007 18:41:02 -0000 1.7
@@ -25,6 +25,9 @@
{
private Driver top = new Driver();
+ /**
+ * Create a new LCSimLoop
+ */
public LCSimLoop()
{
LCSimConditionsManagerImplementation.register();
@@ -38,36 +41,73 @@
}
}
+ /**
+ * Add a driver to the loop. The Driver's will be called for each event,
+ * in the order in which they are added.
+ * @param driver The driver to add to the loop.
+ */
public void add(Driver driver)
{
top.add(driver);
}
+ /**
+ * Remove a driver previously added to the loop.
+ * @param driver The driver to be removed.
+ */
public void remove(Driver driver)
{
top.remove(driver);
}
+ /**
+ * Set the event source to be a give LCIO file.
+ * @param file The LCIO file from which to read.
+ * @throws java.io.IOException If the file cannot be opened.
+ */
public void setLCIORecordSource(File file) throws IOException
{
super.setRecordSource(new LCIOEventSource(file));
}
+ /**
+ * Read events from the given LCIO event source
+ * @param src The source from which to read events.
+ * @throws java.io.IOException If an exception occurs while opening the file.
+ */
public void setLCIORecordSource(LCIOEventSource src) throws IOException
{
super.setRecordSource(src);
}
+ /**
+ * Read events from the given stdhep file. Events will be converted to lcsim
+ * events as they are read.
+ * @param file The file to read
+ * @param detectorName The detector name to be added to the lcsim event.
+ * @throws java.io.IOException If an problem occurs when opening the file.
+ * @see org.lcsim.util.loop.StdhepEventSource
+ */
public void setStdhepRecordSource(File file, String detectorName) throws IOException
{
super.setRecordSource(new StdhepEventSource(file, detectorName));
}
+ /**
+ * Set the event source to be an event generator.
+ * @param gen The event generator used to generate events.
+ */
public void setRecordSource(LCSimEventGenerator gen)
{
super.setRecordSource(new EventGeneratorRecordSource(gen, "generator"));
}
+ /**
+ * Skip a given number of events.
+ * @param recordsToSkip The number of events to skip.
+ * @throws org.freehep.record.source.NoSuchRecordException If there are insufficient events available.
+ * @throws java.io.IOException If an IO exception occurs when reading an event
+ */
public void skip(long recordsToSkip) throws NoSuchRecordException, IOException
{
SequentialRecordSource rs = getRecordSource();
@@ -85,11 +125,33 @@
}
}
+ /**
+ * 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
+ * @return The number of events actually iterated over.
+ */
public long loop(long number) throws LoopException, IOException
{
return loop(number,System.out);
}
+ /**
+ * 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
+ * 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.
+ * @return The number of events actually iterated over.
+ */
public long loop(long number, PrintStream out) throws LoopException, IOException
{
top.clearStatistics();
@@ -98,6 +160,10 @@
return result;
}
+ /**
+ * Print the statistics from the last loop call.
+ * @param out The PrintStream on which to print statistics.
+ */
public void printStatistics(PrintStream out)
{
top.printStatistics(out);