Print

Print


Commit in java/trunk/record-util/src on MAIN
main/java/org/hps/record/EndRunException.java+3-2919 -> 920
                        /EndRunProcessor.java-21919 removed
                        /EtProcessingStep.java-53919 removed
                        /EventProcessingChain.java-272919 removed
                        /EventProcessingConfiguration.java-91919 removed
                        /EventProcessingException.java+9added 920
                        /EventProcessingThread.java-27919 removed
                        /EvioProcessingStep.java-143919 removed
                        /LcioProcessingStep.java-122919 removed
main/java/org/hps/record/composite/CompositeRecordLoop.java+45-10919 -> 920
                                  /CompositeRecordLoopAdapter.java+4-1919 -> 920
main/java/org/hps/record/lcio/LcioLoop.java+9-1919 -> 920
test/java/org/hps/record/EventProcessingChainTest.java-78919 removed
                        /EventProcessingErrorTest.java-104919 removed
                        /EvioEventProcessingTest.java-74919 removed
+70-999
1 added + 10 removed + 4 modified, total 15 files
Reorganization of this package's classes and some rewriting of event processing chain.  Tests okay but there is a problem with ignoring event processing errors.  (Will talk to Dima about it.)

java/trunk/record-util/src/main/java/org/hps/record
EndRunException.java 919 -> 920
--- java/trunk/record-util/src/main/java/org/hps/record/EndRunException.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EndRunException.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -5,8 +5,9 @@
 /**
  * An Exception thrown when an end run occurs.
  */
-class EndRunException extends IOException {
-    EndRunException(String message) {
+// TODO: Add run number to this class.
+public class EndRunException extends IOException {
+    public EndRunException(String message) {
         super(message);
     }
 }

java/trunk/record-util/src/main/java/org/hps/record
EndRunProcessor.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EndRunProcessor.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EndRunProcessor.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,21 +0,0 @@
-package org.hps.record;
-
-import org.hps.evio.EventConstants;
-import org.hps.record.composite.CompositeRecord;
-import org.hps.record.composite.CompositeRecordProcessor;
-
-/**
- * This is a CompositeRecordProcessor for ending the run when an EVIO
- * end event is received.  It should be placed last in the chain of
- * processors so that all the other registered processors are executed
- * beforehand because it throws an Exception.
- */
-public class EndRunProcessor extends CompositeRecordProcessor {
-    
-    @Override
-    public void processEvent(CompositeRecord event) throws EndRunException {
-        if (event.getEvioEvent() != null)
-            if (EventConstants.isEndEvent(event.getEvioEvent()))
-                throw new EndRunException("EVIO end event received.");
-    }
-}

java/trunk/record-util/src/main/java/org/hps/record
EtProcessingStep.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EtProcessingStep.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EtProcessingStep.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,53 +0,0 @@
-package org.hps.record;
-
-import static org.freehep.record.loop.RecordLoop.Command.NEXT;
-
-import org.freehep.record.loop.RecordLoop.Command;
-import org.freehep.record.source.NoSuchRecordException;
-import org.hps.record.composite.CompositeRecord;
-import org.hps.record.composite.CompositeRecordProcessor;
-import org.hps.record.etevent.EtEventLoop;
-import org.jlab.coda.et.EtEvent;
-
- /**
-  * ET processing step to load an <tt>EtEvent</tt> from the ET ring
-  * using a {@link org.hps.monitoring.record.etevent.EtEventLoop}.
-  */
-class EtProcessingStep extends CompositeRecordProcessor {
- 
-    EtEventLoop loop = new EtEventLoop();
-    
-    EtProcessingStep() {
-    }
-    
-    EtEventLoop getLoop() {
-        return loop;
-    }
-    
-    public void startJob() {        
-        if (loop == null)
-            throw new RuntimeException();
-    }
-    
-    public void processEvent(CompositeRecord record) throws Exception {
-            
-        // Load the next EtEvent, which calls getEvents() on the ET connection
-        // and feeds records to any loop listeners like status monitors.
-        loop.execute(NEXT);
-            
-        // Get the current EtEvent from the loop, which should have been cached.
-        EtEvent nextEtEvent = (EtEvent) loop.getRecordSource().getCurrentRecord();
-            
-        // Failed to read an EtEvent from the ET server.
-        if (nextEtEvent == null)
-            throw new NoSuchRecordException("No current EtEvent is available.");
-            
-        // Update the CompositeRecord with reference to the current EtEvent.
-        record.setEtEvent(nextEtEvent);
-     }
-    
-    public void endJob() {
-        System.out.println("EtProcessingStep.endJob");
-        loop.execute(Command.STOP);
-    }        
-}
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record
EventProcessingChain.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EventProcessingChain.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EventProcessingChain.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,272 +0,0 @@
-package org.hps.record;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.freehep.record.loop.AbstractLoopListener;
-import org.freehep.record.loop.LoopEvent;
-import org.freehep.record.loop.LoopListener;
-import org.freehep.record.loop.RecordLoop.Command;
-import org.hps.record.composite.CompositeRecordLoop;
-import org.hps.record.composite.CompositeRecordLoopAdapter;
-import org.hps.record.composite.CompositeRecordProcessor;
-import org.hps.record.etevent.EtEventProcessor;
-import org.hps.record.etevent.EtEventSource;
-import org.hps.record.evio.EvioEventProcessor;
-import org.hps.record.evio.EvioEventQueue;
-import org.hps.record.evio.EvioFileSource;
-import org.hps.record.lcio.LcioEventQueue;
-import org.lcsim.util.Driver;
-import org.lcsim.util.loop.LCIOEventSource;
-
-/**
- * This class provides a serial implementation of the event processing chain
- * for the monitoring app.  Implementations of FreeHep's <tt>RecordLoop</tt> 
- * are chained together via a <tt>CompositeRecordLoop</tt>.  The processing for 
- * each record type is done by activating registered processors on their
- * individual loop implementations.  Essentially, the class is a facade that
- * hides the complexity of configuring all the different record loops.
- * 
- * The processing chain can be configured to execute the ET, EVIO event building,
- * or LCIO event building stages.  The source can be set to an ET ring,
- * EVIO file source, or LCIO file source.  Any number of event processors
- * can be registered with the three different loops for processing the different 
- * record types, in order to plot, update a GUI component, or analyze the events.
- */
-public class EventProcessingChain extends AbstractLoopListener {
-             
-    /**
-     * Processing stages to execute.
-     */
-    public enum ProcessingStage {
-        ET,
-        EVIO,
-        LCIO
-    }
-    
-    protected int totalEventsProcessed;
-    protected Throwable lastError;
-    protected boolean done;
-    protected boolean paused;
-    
-    protected EtProcessingStep etStep = new EtProcessingStep();
-    protected EvioProcessingStep evioStep = new EvioProcessingStep();
-    protected LcioProcessingStep lcioStep = new LcioProcessingStep();
-    protected CompositeRecordLoop compositeLoop = new CompositeRecordLoop();
-                  
-    /**
-     * A configuration object must be supplied to use this class.
-     * @param configuration The configuration of the event processing.
-     */
-    public EventProcessingChain(EventProcessingConfiguration configuration) {                
-        configure(configuration);
-    }
-
-    private void configure(EventProcessingConfiguration configuration) {
-        
-        // Add this class as a loop listener.
-        compositeLoop.addLoopListener(this);
-        
-        // Was there no RecordSource provided explicitly?
-        if (configuration.recordSource == null) {
-            // Using an ET server connection?
-            if (configuration.sourceType.equals(DataSourceType.ET_SERVER)) {
-                if (configuration.connection != null)
-                    etStep.getLoop().setRecordSource(new EtEventSource(configuration.connection));
-                else
-                    throw new IllegalArgumentException("Configuration is missing a valid ET connection.");
-            // Using an EVIO file?
-            } else if (configuration.sourceType.equals(DataSourceType.EVIO_FILE)) {
-                if (configuration.filePath != null)
-                    evioStep.getLoop().setRecordSource(new EvioFileSource(new File(configuration.filePath)));
-                else
-                    throw new IllegalArgumentException("Configuration is missing a file path.");
-            // Using an LCIO file?
-            } else if (configuration.sourceType.equals(DataSourceType.LCIO_FILE)) {
-                if (configuration.filePath != null)
-                    try {
-                        lcioStep.getLoop().setLCIORecordSource(new LCIOEventSource(new File(configuration.filePath)));
-                    } catch (IOException e) {
-                        throw new RuntimeException("Error configuring LCIOEventSource.", e);
-                    }
-                else
-                    throw new IllegalArgumentException("Configuration is missing a file path.");
-            }
-        } else {           
-            // User provided an EtEventSource?
-            if (configuration.recordSource instanceof EtEventSource) {
-                etStep.getLoop().setRecordSource((EtEventSource) configuration.recordSource);
-            // User provided an EvioFileSource?
-            } else if (configuration.recordSource instanceof EvioFileSource) {
-                evioStep.getLoop().setRecordSource((EvioFileSource) configuration.recordSource);
-            // User provided an LCIOEventSource?
-            } else if (configuration.recordSource instanceof LCIOEventSource) {
-                try {
-                    lcioStep.getLoop().setLCIORecordSource((LCIOEventSource)configuration.recordSource);
-                } catch (IOException e) {
-                    throw new RuntimeException("Error setting up LCIORecordSource.", e);
-                }
-            } else {
-                throw new IllegalArgumentException("Unknown RecordSource type was supplied.");
-            }
-        }
-                
-        // Using the ET server for events?
-        if (configuration.sourceType == DataSourceType.ET_SERVER) {
-            // Add the ET event processing step.
-            compositeLoop.addProcessor(etStep);
-        }
-   
-        // Building EVIO events?
-        if (configuration.processingStage.ordinal() >= ProcessingStage.EVIO.ordinal()) {
-            // Using EVIO event source?
-            if (configuration.sourceType.ordinal() <= DataSourceType.EVIO_FILE.ordinal()) {
-                // Using ET event source?
-                if (configuration.sourceType == DataSourceType.ET_SERVER) {
-                    // Use dynamic event queue.
-                    evioStep.setEvioEventQueue(new EvioEventQueue());
-                }
-                // Add EVIO processing step.
-                compositeLoop.addProcessor(evioStep);
-            }
-        }
-        
-        // Building LCIO events?
-        if (configuration.processingStage.ordinal() >= ProcessingStage.LCIO.ordinal()) {
-            // Set detector on event builder.
-            if (configuration.eventBuilder != null) 
-                configuration.eventBuilder.setDetectorName(configuration.detectorName);
-            else
-                throw new IllegalArgumentException("The eventBuilder was not set in the configuration.");
-            
-            if (configuration.sourceType.ordinal() != DataSourceType.LCIO_FILE.ordinal()) {
-                // Use dynamic event queue.
-                lcioStep.setLcioEventQueue(new LcioEventQueue());
-            }
-            // Set event builder.
-            lcioStep.setEventBuilder(configuration.eventBuilder);
-            
-            // Add LCIO processing step.
-            compositeLoop.addProcessor(lcioStep);
-        }
-        
-        // Set whether to stop on event processing errors.
-        compositeLoop.setStopOnErrors(configuration.stopOnErrors);
-        
-        // Add EtEventProcessors to loop.
-        for (EtEventProcessor processor : configuration.etProcessors) {
-            etStep.getLoop().addEtEventProcessor(processor);
-        }
-        
-        // Add EvioEventProcessors to loop.
-        for (EvioEventProcessor processor : configuration.evioProcessors) {
-            evioStep.getLoop().addEvioEventProcessor(processor);
-        }
-        
-        // Add Drivers to loop.
-        for (Driver driver : configuration.drivers) {
-            lcioStep.getLoop().add(driver);
-        }
-        
-        // Add CompositeRecordProcessors to loop.
-        for (CompositeRecordProcessor processor : configuration.compositeProcessors) {
-            compositeLoop.addProcessor(processor);
-        }
-
-        // Stop on end run?
-        if (configuration.stopOnEndRun) {
-            // Add the CompositeRecordProcessor that will throw the EndRunException.
-            compositeLoop.addProcessor(new EndRunProcessor());
-        }
-    }
-                                 
-    /**
-     * Resume event processing from pause mode.
-     */
-    public void resume() {
-        this.paused = false;
-    }
-    
-    /**
-     * Suspend event processing e.g. when pausing.
-     * @param loopEvent The loop event.
-     */
-    public void suspend(LoopEvent loopEvent) {
-        if (loopEvent.getException() != null) {
-            loopEvent.getException().printStackTrace();
-            lastError = (Exception) loopEvent.getException();
-        }
-    }
-    
-    /**
-     * Loop over events until processing ends for some reason.
-     */
-    public void loop() {
-        // Keep looping until the event processing is flagged as done.
-        while (!done) {
-            // Go into loop mode if the system is not paused.
-            if (!paused) {
-                try {
-                    compositeLoop.execute(Command.GO, true);
-                } catch (Exception exception) {
-                    setLastError(exception);
-                } 
-                
-                // When an exception occurs, which can sometimes just be control flow,
-                // the event processing should stop.
-                if (lastError != null) {
-                    if (!done) {
-                        // Call finish manually here as the loop was suspended.                        
-                        finish();
-                    }
-                } 
-            }
-        }
-    }
-        
-    void setLastError(Throwable error) {
-        this.lastError = error;
-    }
-    
-    public Throwable getLastError() {
-        return lastError;
-    }
-
-    /**
-     * Pause the event processing.
-     */
-    public void pause() {
-        compositeLoop.execute(Command.PAUSE);
-        paused = true;
-    }
-        
-    /**
-     * Finish the event processing.
-     */
-    public void finish() {
-        compositeLoop.execute(Command.STOP);
-        
-        // FIXME: Ugly hack because Command.STOP doesn't activate the finish() method
-        // on the CompositeRecordLoopAdapter when errors occur.
-        for (LoopListener listener : compositeLoop.getLoopListeners()) {
-            if (listener instanceof CompositeRecordLoopAdapter)
-                ((CompositeRecordLoopAdapter)listener).finish(null);
-        }
-        done = true;
-    }    
-        
-    /**
-     * Get the next event e.g. while in pause mode.
-     */
-    public void next() {
-        compositeLoop.execute(Command.GO_N, 1L, true);
-    }
-            
-    /** 
-     * Get the total number of events processed.
-     * @return The number of events processed.
-     */
-    public int getTotalEventsProcessed() {
-        return this.totalEventsProcessed;
-    }           
-}
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record
EventProcessingConfiguration.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EventProcessingConfiguration.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EventProcessingConfiguration.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,91 +0,0 @@
-package org.hps.record;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.freehep.record.source.RecordSource;
-import org.hps.evio.LCSimEventBuilder;
-import org.hps.record.EventProcessingChain.ProcessingStage;
-import org.hps.record.composite.CompositeRecordProcessor;
-import org.hps.record.etevent.EtConnection;
-import org.hps.record.etevent.EtEventProcessor;
-import org.hps.record.evio.EvioEventProcessor;
-import org.lcsim.util.Driver;
-
-/**
- * A configuration object for the {@link EventProcessingChain}.
- * The instance variables are readable within this package, but
- * must be set through the public set methods when used
- * outside of it, e.g. from MonitoringApplication.
- */
-public class EventProcessingConfiguration {
-        
-    boolean stopOnErrors = true;
-    boolean stopOnEndRun = true;
-
-    DataSourceType sourceType = DataSourceType.ET_SERVER;
-    ProcessingStage processingStage = ProcessingStage.LCIO;
-    
-    String filePath = null;
-    EtConnection connection = null;
-    RecordSource recordSource = null;
-    LCSimEventBuilder eventBuilder = null;
-    String detectorName = null;
-    
-    List<EvioEventProcessor> evioProcessors = new ArrayList<EvioEventProcessor>();
-    List<Driver> drivers = new ArrayList<Driver>();
-    List<CompositeRecordProcessor> compositeProcessors = new ArrayList<CompositeRecordProcessor>();
-    List<EtEventProcessor> etProcessors = new ArrayList<EtEventProcessor>();
-                 
-    public void setFilePath(String filePath) {
-        this.filePath = filePath;
-    }
-    
-    public void setEtConnection(EtConnection connection) {
-        this.connection = connection;
-    }
-    
-    public void setDataSourceType(DataSourceType sourceType) {
-        this.sourceType = sourceType;
-    }
-    
-    public void setProcessingStage(ProcessingStage processingStage) {
-        this.processingStage = processingStage;
-    }
-    
-    public void setRecordSource(RecordSource recordSource) {
-        this.recordSource = recordSource;
-    }
-    
-    public void setLCSimEventBuild(LCSimEventBuilder eventBuilder) {
-        this.eventBuilder = eventBuilder;
-    }
-    
-    public void setDetectorName(String detectorName) {
-        this.detectorName = detectorName;
-    }
-    
-    public void setStopOnErrors(boolean stopOnErrors) {
-        this.stopOnErrors = stopOnErrors;
-    }
-    
-    public void setStopOnEndRun(boolean stopOnEndRun) {
-        this.stopOnEndRun = stopOnEndRun;
-    }
-    
-    public void add(EtEventProcessor processor) {
-        etProcessors.add(processor);
-    }
-    
-    public void add(EvioEventProcessor processor) {
-        evioProcessors.add(processor);
-    }
-    
-    public void add(Driver processor) {
-        drivers.add(processor);
-    }
-    
-    public void add(CompositeRecordProcessor processor) {
-        compositeProcessors.add(processor);
-    }
-}

java/trunk/record-util/src/main/java/org/hps/record
EventProcessingException.java added at 920
--- java/trunk/record-util/src/main/java/org/hps/record/EventProcessingException.java	                        (rev 0)
+++ java/trunk/record-util/src/main/java/org/hps/record/EventProcessingException.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -0,0 +1,9 @@
+package org.hps.record;
+
+public class EventProcessingException extends RuntimeException {
+    
+    public EventProcessingException(String message, Throwable x) {
+        super(message, x);
+    }
+    
+}

java/trunk/record-util/src/main/java/org/hps/record
EventProcessingThread.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EventProcessingThread.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EventProcessingThread.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,27 +0,0 @@
-package org.hps.record;
-
-/**
- * Thread for running the event processing chain.
- */
-public final class EventProcessingThread extends Thread {
-    
-    EventProcessingChain processing;
-           
-    public EventProcessingThread(EventProcessingChain processing) {
-        super("EventProcessingThread");
-        this.processing = processing;
-    }
-    
-    public EventProcessingChain getEventProcessingChain() {
-        return processing;
-    }
-    
-    @Override
-    public void run() {
-        try {
-            processing.loop();
-        } catch (Exception e) {
-            throw new RuntimeException("Error in event processing.", e);
-        } 
-    }
-}
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record
EvioProcessingStep.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/EvioProcessingStep.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/EvioProcessingStep.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,143 +0,0 @@
-package org.hps.record;
-
-import static org.freehep.record.loop.RecordLoop.Command.NEXT;
-
-import java.io.IOException;
-import java.nio.BufferUnderflowException;
-
-import org.freehep.record.loop.RecordLoop.Command;
-import org.freehep.record.source.NoSuchRecordException;
-import org.hps.evio.EventConstants;
-import org.hps.record.composite.CompositeRecord;
-import org.hps.record.composite.CompositeRecordProcessor;
-import org.hps.record.evio.EvioEventLoop;
-import org.hps.record.evio.EvioEventQueue;
-import org.jlab.coda.et.EtEvent;
-import org.jlab.coda.jevio.BaseStructure;
-import org.jlab.coda.jevio.EvioEvent;
-import org.jlab.coda.jevio.EvioException;
-import org.jlab.coda.jevio.EvioReader;
-
-/**
- * EVIO processing step to build an <tt>EvioEvent</tt> from the <tt>EtEvent</tt>
- * or load the next <tt>EvioEvent</tt> from a file, if using an EVIO file source.
- */
-class EvioProcessingStep extends CompositeRecordProcessor {
-   
-    EvioEventLoop loop = new EvioEventLoop();
-    DataSourceType sourceType;
-    EvioEventQueue evioEventQueue;
-    boolean stopOnEndRun;
-    
-    /**
-     * Get the <tt>EvioEventLoop</tt> associated with this processing step.
-     * @return The <tt>EvioEventLoop</tt> associated with this processing step.
-     */
-    EvioEventLoop getLoop() {
-        return loop;
-    }
-
-    /**
-     * Set the EVIO event queue.
-     * @param evioEventQueue The EVIO event queue.
-     */
-    void setEvioEventQueue(EvioEventQueue evioEventQueue) {
-        this.evioEventQueue = evioEventQueue;
-        loop.setRecordSource(this.evioEventQueue);
-    }
-    
-    /**
-     * Set whether an end of run record will throw a control Exception.
-     */
-    void setStopOnEndRun() {
-        stopOnEndRun = true;
-    }
-    
-    /**
-     * Set the <tt>EvioEventLoop</tt> for this processing step.
-     * @param loop The <tt>EvioEventLoop</tt> for this processing step.
-     */
-    void setEvioEventLoop(EvioEventLoop loop) {
-        this.loop = loop;
-    }
-    
-    /**
-     * Set the type of event source.
-     * @param sourceType The type of event source.
-     */
-    void setSourceType(DataSourceType sourceType) {
-        this.sourceType = sourceType;
-    }
-    
-    /**
-     * Load the next <tt>EvioEvent</tt>, either from a record source
-     * or from the <tt>EtEvent</tt> data.
-     */
-    public void processEvent(CompositeRecord record) throws Exception {
-                
-        if (evioEventQueue != null) {
-            EvioEvent evioEvent = null;
-            try {
-                evioEvent = createEvioEvent(record.getEtEvent());                    
-                if (evioEvent == null)
-                    throw new IOException("Failed to create EvioEvent from current EtEvent.");
-                setEventNumber(evioEvent);
-            } catch (EvioException e) {
-                throw new IOException(e);
-            }
-        
-            // Add EvioEvent to the queue for loop.
-            evioEventQueue.addRecord(evioEvent);
-        }
-
-        // Process one EvioEvent.
-        loop.execute(NEXT);         
-        EvioEvent nextEvioEvent = (EvioEvent) loop.getRecordSource().getCurrentRecord();
-        
-        // The call to loop did not create a current record.
-        if (nextEvioEvent == null)
-            throw new NoSuchRecordException("No current EVIO event.");
-        
-        // Update the CompositeRecord.
-        record.setEvioEvent(nextEvioEvent);
-        record.setEventNumber(nextEvioEvent.getEventNumber());
-    }
-    
-    /**
-     * Create an <tt>EvioEvent</tt> from the current <tt>EtEvent</tt>.
-     * @param etEvent
-     * @return The created EVIO event.
-     * @throws IOException
-     * @throws EvioException
-     * @throws BufferUnderflowException
-     */
-    private EvioEvent createEvioEvent(EtEvent etEvent) 
-            throws IOException, EvioException, BufferUnderflowException {
-        return (new EvioReader(etEvent.getDataBuffer())).parseNextEvent();
-    }
-    
-    /**
-     * Set the EVIO event number manually from the event ID bank.
-     * @param evioEvent The <tt>EvioEvent</tt> on which to set the event number.
-     */
-    private void setEventNumber(EvioEvent evioEvent) {
-        int eventNumber = -1;
-        if (evioEvent.getChildren() != null) {
-            for (BaseStructure bank : evioEvent.getChildren()) {
-                if (bank.getHeader().getTag() == EventConstants.EVENTID_BANK_TAG) {
-                    eventNumber = bank.getIntData()[0];
-                    break;
-                }
-            }
-        }
-        if (eventNumber != -1)
-            evioEvent.setEventNumber(eventNumber);
-    }
-    
-    /**
-     * End the job by calling stop on the EVIO processing loop.
-     */
-    public void endJob() {
-        this.loop.execute(Command.STOP);
-    }
-}
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record
LcioProcessingStep.java removed after 919
--- java/trunk/record-util/src/main/java/org/hps/record/LcioProcessingStep.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/LcioProcessingStep.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,122 +0,0 @@
-package org.hps.record;
-
-import static org.freehep.record.loop.RecordLoop.Command.NEXT;
-
-import org.freehep.record.loop.RecordLoop.Command;
-import org.freehep.record.source.NoSuchRecordException;
-import org.hps.evio.LCSimEventBuilder;
-import org.hps.record.composite.CompositeRecord;
-import org.hps.record.composite.CompositeRecordProcessor;
-import org.hps.record.lcio.LcioEventQueue;
-import org.hps.record.lcio.LcioLoop;
-import org.jlab.coda.jevio.EvioEvent;
-import org.lcsim.event.EventHeader;
-import org.lcsim.util.loop.LCSimLoop;
-
-/**
- * Processing step for building LCIO events from EVIO
- * or reading them directly from an input event file.
- */
-class LcioProcessingStep extends CompositeRecordProcessor {
-
-    LcioLoop loop = new LcioLoop();
-    LCSimEventBuilder builder;
-    LcioEventQueue lcioEventQueue;
-    
-    /**
-     * Get the <code>LcioLoop</code> associated with this processing step.
-     * @return The <code>LcioLoop</code> associated with this processing step.
-     */
-    LCSimLoop getLoop() {
-        return this.loop;
-    }
-        
-    /**
-     * Set the <code>LCSimEventBuilder</code> for converting from EVIO to LCIO.
-     * @param builder The converter for EVIO to LCIO.
-     */
-    void setEventBuilder(LCSimEventBuilder builder) {
-        this.builder = builder;
-    }
-    
-    /**
-     * Set the <code>LcioEventQueue</code> event source, to be used when there
-     * is no direct LCIO record source from a file.
-     * @param lcioEventQueue The <code>LcioEventQueue</code> to be used as a record source.
-     */
-    void setLcioEventQueue(LcioEventQueue lcioEventQueue) {
-        this.lcioEventQueue = lcioEventQueue;
-        loop.setRecordSource(lcioEventQueue);
-    }
-    
-    /**
-     * Start of job hook.
-     */
-    public void startJob() {
-        if (builder == null)
-            throw new RuntimeException("No LCSimEventBuilder was setup.");
-    }
-    
-    /**
-     * Process a <code>CompositeRecord</code> event by creating an LCIO event
-     * and adding it to the record.
-     */
-    public void processEvent(CompositeRecord record) throws Exception {
-        
-        // When the loop does not have a direct LCIO file source, 
-        // the events need to be built from the EVIO input.
-        if (lcioEventQueue != null) {
-            
-            EvioEvent currentEvioEvent = record.getEvioEvent();
-            
-            // Set state on LCIO event builder.
-            builder.readEvioEvent(currentEvioEvent);
-            
-            // The LCIO event will be built if processing an EVIO physics event.
-            if (builder.isPhysicsEvent(currentEvioEvent)) {
-                
-                // Use the event builder to create the next LCIO event.
-                EventHeader lcioEvent = builder.makeLCSimEvent(currentEvioEvent);
-    
-                // Add LCIO event to the queue.
-                lcioEventQueue.addRecord(lcioEvent);
-            } else {
-                // The LCIO processing ignores non-physics events coming from EVIO.
-                return;
-            }
-        }
-            
-        // Is there a next record?
-        if (!loop.getRecordSource().hasNext())
-            // The next record does not exist.
-            throw new NoSuchRecordException("No next LCIO event.");
-        
-        // Load the next LCIO event, triggering Driver process methods.
-        loop.execute(NEXT);
-            
-        // Is there a current record?
-        if (loop.getRecordSource().getCurrentRecord() == null) {
-            // The last call to the loop did not create a current record.
-            throw new NoSuchRecordException("No current LCIO event.");
-        }
-        
-        // Get the current LCIO event.
-        EventHeader lcioEvent = (EventHeader) loop.getRecordSource().getCurrentRecord();
-                
-        // Update the CompositeRecord with a reference to the LCIO event.
-        record.setLcioEvent(lcioEvent);
-        // Was there an EVIO event set?
-        if (record.getEvioEvent() == null) {
-            // Set event number from LCIO if no EVIO event was set.
-            record.setEventNumber(lcioEvent.getEventNumber());
-        }
-    }
-    
-    /**
-     * End of job hook.
-     */
-    public void endJob() {
-        // Execute STOP on the LCIO record loop.
-        loop.execute(Command.STOP);
-    }
-}
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record/composite
CompositeRecordLoop.java 919 -> 920
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordLoop.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordLoop.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,8 +1,9 @@
 package org.hps.record.composite;
 
 import org.freehep.record.loop.DefaultRecordLoop;
-import org.freehep.record.source.NoSuchRecordException;
 import org.freehep.record.source.RecordSource;
+import org.hps.record.EndRunException;
+import org.hps.record.EventProcessingException;
 
 /**
  * Implementation of a composite record loop for processing
@@ -12,6 +13,7 @@
 
     CompositeRecordSource recordSource = new CompositeRecordSource();
     CompositeRecordLoopAdapter adapter = new CompositeRecordLoopAdapter();
+    
     boolean stopOnErrors = true;
     
     public CompositeRecordLoop() {
@@ -42,17 +44,50 @@
     public void addProcessor(CompositeRecordProcessor processor) {
         adapter.addProcessor(processor);
     }
-    
+            
     protected void handleClientError(Throwable x) {
-        if (stopOnErrors || x instanceof NoSuchRecordException) {
-            //this.execute(Command.STOP);
-            throw new RuntimeException("Error during event processing.", x);
-        } else {
-            x.printStackTrace();
-        }                
+        System.out.println("CompositeRecordLoop.handleClientError");
+        System.out.println("  error: " + x.getClass().getCanonicalName());
+        System.out.println("  cause: " + x.getCause().getClass().getCanonicalName());
+        System.out.println("  loop state: " + this.getState().toString());
+        x.printStackTrace();
+        if (isIgnorable(x)) {
+            System.out.println("  error is ignored");
+            return;
+        }        
+        adapter.finish(null);
+        this.execute(Command.STOP);
+        
+        // Rethrow so the loop caller can catch and handle this error.
+        throw new RuntimeException("Error from client during event processing.", x);
     }
 
-    protected void handleSourceError(Throwable x) {
-        throw new RuntimeException("Error during event processing.", x);
+    protected void handleSourceError(Throwable x) {     
+        System.out.println("CompositeRecordLoop.handleSourceError");
+        System.out.println("error: " + x.getClass().getCanonicalName());
+        System.out.println("cause: " + x.getCause().getClass().getCanonicalName());
+        x.printStackTrace();
+        if (isIgnorable(x)) {
+            System.out.println("error is ignored");
+            return;
+        }
+        adapter.finish(null);
+        this.execute(Command.STOP);
+        
+        // Rethrow so the loop caller can catch and handle this error.
+        throw new RuntimeException("Error from record source during event processing.", x);
     }        
+    
+    private boolean isIgnorable(Throwable x) {
+        if (!stopOnErrors) {
+            if ((x instanceof EventProcessingException) 
+                    && !(x.getCause() instanceof EndRunException)
+                    && !(x.getCause() instanceof IllegalStateException))
+                return true;
+        } else {
+            return false;
+        }
+        return false;
+    }
 }
+ 
\ No newline at end of file

java/trunk/record-util/src/main/java/org/hps/record/composite
CompositeRecordLoopAdapter.java 919 -> 920
--- java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordLoopAdapter.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/composite/CompositeRecordLoopAdapter.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -7,6 +7,7 @@
 import org.freehep.record.loop.LoopEvent;
 import org.freehep.record.loop.RecordEvent;
 import org.freehep.record.loop.RecordListener;
+import org.hps.record.EventProcessingException;
 
 /**
  * Adapter for listening on the {@link CompositeRecordLoop} for records and loop events.
@@ -20,6 +21,7 @@
      * @param loopEvent 
      */
     public void finish(LoopEvent loopEvent) {
+        System.out.println("CompositeRecordLoopAdapter.finish");
         for (CompositeRecordProcessor processor : processors) {
             // Call end job hook on all registered processors, which are 
             // responsible for sending the stop command to their loops.
@@ -51,6 +53,7 @@
      * @param loopEvent
      */
     public void suspend(LoopEvent loopEvent) { 
+        System.out.println("CompositeRecordLoopAdapter.suspend");
         //if (loopEvent.getException() != null) {
         //    throw new RuntimeException("Error in event processing.", loopEvent.getException());
         //}
@@ -66,7 +69,7 @@
             try {
                 processor.processEvent((CompositeRecord) record.getRecord());
             } catch (Exception e) {                
-                throw new RuntimeException("Error processing CompositeRecord.", e);
+                throw new EventProcessingException("Error processing CompositeRecord.", e);
             }
         }
     }    

java/trunk/record-util/src/main/java/org/hps/record/lcio
LcioLoop.java 919 -> 920
--- java/trunk/record-util/src/main/java/org/hps/record/lcio/LcioLoop.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/main/java/org/hps/record/lcio/LcioLoop.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -9,13 +9,21 @@
 public final class LcioLoop extends LCSimLoop {
 
     protected void handleClientError(Throwable x) {
-        if (x != null) {
+        System.out.println("LcioLoop.handleClientError");
+        System.out.println("  initial loop state: " + this.getState().toString());
+        if (x != null) {            
+            this.execute(Command.STOP);
+            System.out.println("  loop state after stop: " + this.getState().toString());
             throw new RuntimeException(x);
         }
     }
 
     protected void handleSourceError(Throwable x) {
+        System.out.println("LcioLoop.handleSourceError");
+        System.out.println("  initial loop state: " + this.getState().toString());
         if (x != null) {
+            this.execute(Command.STOP);
+            System.out.println("  loop state after stop: " + this.getState().toString());
             throw new RuntimeException(x);
         }
     }

java/trunk/record-util/src/test/java/org/hps/record
EventProcessingChainTest.java removed after 919
--- java/trunk/record-util/src/test/java/org/hps/record/EventProcessingChainTest.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/test/java/org/hps/record/EventProcessingChainTest.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,78 +0,0 @@
-package org.hps.record;
-
-import org.hps.evio.LCSimTestRunEventBuilder;
-import org.hps.record.evio.EvioEventProcessor;
-import org.jlab.coda.jevio.EvioEvent;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.util.Driver;
-
-public class EventProcessingChainTest {
-    
-    //static String evioFilePath = "/work/data/hps/hps_001351.evio.0";
-    static String evioFilePath = "/nfs/slac/g/hps3/data/testrun/runs/evio/hps_001351.evio.0";
-    //static String lcioFilePath = "/work/data/hps/hps_001351.evio.0_recon.slcio";
-    static String lcioFilePath = "/nfs/slac/g/hps3/data/testrun/runs/recon_new/hps_001351.evio.0_recon.slcio";
-    static String detectorName = "HPS-TestRun-v8-5";
-    
-    // ET ring with streaming EVIO file must be running for this to work.
-    /*
-    public void testEtSource() {
-        EventProcessingChain processing = new EventProcessingChain();
-        processing.setRecordSource(new EtEventSource());
-        processing.setEventBuilder(new LCSimTestRunEventBuilder());
-        processing.setDetectorName(detectorName);
-        processing.add(new DummyEvioProcessor());
-        processing.add(new DummyDriver());
-        processing.setStopOnEndRun();
-        processing.configure();
-        processing.loop();
-    }
-    */
-    
-    public void testEvioFile() {
-        
-        EventProcessingConfiguration config = new EventProcessingConfiguration();
-        config.setDataSourceType(DataSourceType.EVIO_FILE);
-        config.setFilePath(evioFilePath);
-        config.setLCSimEventBuild(new LCSimTestRunEventBuilder());
-        config.setDetectorName(detectorName);
-        config.add(new DummyEvioProcessor());
-        config.add(new DummyDriver());     
-        EventProcessingChain processing = new EventProcessingChain(config);
-        processing.loop();
-    }
-    
-    /*
-    public void testLcioFile() {
-        EventProcessingChain processing = new EventProcessingChain();
-        try {
-            processing.setRecordSource(new LCIOEventSource(new File(lcioFilePath)));
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        processing.setEventBuilder(new LCSimTestRunEventBuilder());
-        processing.setDetectorName(detectorName);
-        processing.add(new DummyDriver());
-        processing.configure();
-        processing.loop();
-    }
-    */
-    
-    static class DummyDriver extends Driver {
-        public void process(EventHeader event) {
-            System.out.println(this.getClass().getSimpleName() + " got LCIO event #" + event.getEventNumber());
-            for (LCMetaData metaData : event.getMetaData()) {
-                String collectionName = metaData.getName();
-                Class type = metaData.getType();
-                System.out.println (collectionName + " " + event.get(type, collectionName).size());
-            }
-        }
-    }
-    
-    static class DummyEvioProcessor extends EvioEventProcessor {
-        public void processEvent(EvioEvent event) {
-            System.out.println(this.getClass().getSimpleName() + " got EVIO event #" + event.getEventNumber());
-        }
-    }
-}

java/trunk/record-util/src/test/java/org/hps/record
EventProcessingErrorTest.java removed after 919
--- java/trunk/record-util/src/test/java/org/hps/record/EventProcessingErrorTest.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/test/java/org/hps/record/EventProcessingErrorTest.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,104 +0,0 @@
-package org.hps.record;
-
-import junit.framework.TestCase;
-
-import org.freehep.record.loop.RecordLoop.Command;
-import org.hps.evio.LCSimTestRunEventBuilder;
-import org.hps.record.evio.EvioEventProcessor;
-import org.lcsim.event.EventHeader;
-import org.lcsim.util.Driver;
-
-
-public class EventProcessingErrorTest extends TestCase {
-       
-    static String evioFilePath = "/nfs/slac/g/hps3/data/testcase/hps_000975.evio.0";
-    
-    public void testEventProcessingError() {
-                
-        EventProcessingConfiguration config = new EventProcessingConfiguration();
-        config.setFilePath(evioFilePath);
-        config.setDataSourceType(DataSourceType.EVIO_FILE);
-        config.setLCSimEventBuild(new LCSimTestRunEventBuilder());
-        config.setDetectorName("HPS-TestRun-v8-5");
-        config.add(new DummyErrorDriver());
-        config.add(new DummyEvioDriver());
-        
-        EventProcessingChain processing = new EventProcessingChainOverride(config);
-        processing.loop();
-    }
-    
-    public void testEventProcessingNoError() {
-        
-        EventProcessingConfiguration config = new EventProcessingConfiguration();
-        config.setFilePath(evioFilePath);
-        config.setDataSourceType(DataSourceType.EVIO_FILE);
-        config.setLCSimEventBuild(new LCSimTestRunEventBuilder());
-        config.setDetectorName("HPS-TestRun-v8-5");
-        config.add(new DummyDriver());
-        config.add(new DummyEvioDriver());
-        
-        EventProcessingChain processing = new EventProcessingChainOverride(config);
-        processing.loop();
-    }
-
-    static class DummyDriver extends Driver {
-        public void process(EventHeader event) {
-            System.out.println("DummyDriver.process");
-        }
-        
-        public void endOfData() {
-            System.out.println("DummyErrorDriver.endOfData");
-        }
-    }
-    
-    static class DummyErrorDriver extends Driver {
-        
-        public void process(EventHeader event) {
-            throw new RuntimeException("Dummy error.");
-        }
-        
-        public void endOfData() {
-            System.out.println("DummyErrorDriver.endOfData");
-        }
-    }
-    
-    static class DummyEvioDriver extends EvioEventProcessor {
-        public void endJob() {
-            System.out.println("DummyEvioDriver.endJob");
-        }        
-    }
-    
-    static class EventProcessingChainOverride extends EventProcessingChain {
-
-        EventProcessingChainOverride(EventProcessingConfiguration config) {
-            super(config);
-        }
-        
-        /**
-         * Loop over events until processing ends for some reason.
-         */
-        public void loop() {
-            while (!done) {
-                if (!paused) {
-                    try {
-                        compositeLoop.execute(Command.GO, true);
-                    } catch (Exception exception) {
-                        System.out.println("error occurred - " + exception.getMessage());
-                        setLastError(exception);
-                    } 
-                    if (lastError != null) {                        
-                        if (!done) {
-                            System.out.println(this.getClass().getSimpleName() + " - executing STOP ...");
-                            System.out.println("CompositeRecordLoop.getState - " + compositeLoop.getState().toString());
-                            compositeLoop.execute(Command.STOP);
-                            System.out.println(this.getClass().getSimpleName() + " - done executing STOP");
-                            done = true;
-                        }
-                    } 
-                }
-            }
-        }
-        
-        
-    }
-}

java/trunk/record-util/src/test/java/org/hps/record
EvioEventProcessingTest.java removed after 919
--- java/trunk/record-util/src/test/java/org/hps/record/EvioEventProcessingTest.java	2014-08-28 15:31:06 UTC (rev 919)
+++ java/trunk/record-util/src/test/java/org/hps/record/EvioEventProcessingTest.java	2014-08-28 20:22:29 UTC (rev 920)
@@ -1,74 +0,0 @@
-package org.hps.record;
-
-import org.hps.evio.LCSimTestRunEventBuilder;
-import org.hps.record.evio.EvioEventProcessor;
-import org.jlab.coda.jevio.EvioEvent;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.geometry.Detector;
-import org.lcsim.util.Driver;
-
-public class EvioEventProcessingTest {
-    
-    static String evioFilePath = "/nfs/slac/g/hps3/data/testrun/runs/evio/hps_001351.evio.0";   
-    static String detectorName = "HPS-TestRun-v8-5";
-         
-    public void testEvioFile() {        
-        EventProcessingConfiguration config = new EventProcessingConfiguration();
-        config.setDataSourceType(DataSourceType.EVIO_FILE);
-        config.setFilePath(evioFilePath);
-        config.setLCSimEventBuild(new LCSimTestRunEventBuilder());
-        config.setDetectorName(detectorName);
-        config.add(new DummyEvioProcessor());
-        config.add(new DummyDriver());
-        EventProcessingChain processing = new EventProcessingChain(config);
-        processing.loop();
-    }
-        
-    static class DummyDriver extends Driver {
-        
-        public void detectorChanged(Detector detector) {
-            System.out.println(this.getClass().getSimpleName() + ".detectorChanged - " + detector.getDetectorName());
-        }
-        
-        public void startOfData() {
-            System.out.println(this.getClass().getSimpleName() + ".startOfData");
-        }
-        
-        public void process(EventHeader event) {
-            System.out.println(this.getClass().getSimpleName() + " got LCIO event #" + event.getEventNumber());
-            for (LCMetaData metaData : event.getMetaData()) {
-                String collectionName = metaData.getName();
-                Class type = metaData.getType();
-                System.out.println (collectionName + " " + event.get(type, collectionName).size());
-            }
-        }
-        
-        public void endOfData() {
-            System.out.println(this.getClass().getSimpleName() + ".endOfData");
-        }
-    }
-    
-    static class DummyEvioProcessor extends EvioEventProcessor {
-        
-        public void startRun(EvioEvent event) {
-            System.out.println(this.getClass().getSimpleName() + ".startRun");
-        }
-        
-        public void endRun(EvioEvent event) {
-            System.out.println(this.getClass().getSimpleName() + ".endRun");
-        }
-        
-        public void startJob() {
-            System.out.println(this.getClass().getSimpleName() + ".startJob");
-        }
-        
-        public void endJob() {
-            System.out.println(this.getClass().getSimpleName() + ".endJob");
-        }
-        
-        public void processEvent(EvioEvent event) {
-            System.out.println(this.getClass().getSimpleName() + " got EVIO event #" + event.getEventNumber());
-        }
-    }
-}
SVNspam 0.1