Commit in hps-java on MAIN
src/main/java/org/lcsim/hps/evio/ECalEvioWriter.java+2-21.5 -> 1.6
                                /TestRunEvioToLcio.java+26-81.9 -> 1.10
                                /EventConstants.java+22-11.10 -> 1.11
                                /ECalEvioReader.java+2-21.15 -> 1.16
src/main/java/org/lcsim/hps/monitoring/HPSCalibrationListener.java+81added 1.1
                                      /HPSCalibrationDriver.java+23added 1.1
                                      /RunControlDriver.java+7-31.1 -> 1.2
                                      /MonitoringApplication.java+125-1261.46 -> 1.47
src/main/java/org/lcsim/hps/monitoring/ecal/EcalClusterPlots.java+2-11.2 -> 1.3
                                           /EcalWindowPlots.java-11.4 -> 1.5
                                           /EcalDaqPlots.java-11.4 -> 1.5
                                           /EcalEvsX.java+55-51.3 -> 1.4
                                           /EcalHitPlots.java+6-31.1 -> 1.2
src/main/java/org/lcsim/hps/recon/ecal/HPSEcalConditions.java+15-71.6 -> 1.7
                                      /HPSEcalRawConverter.java+2-21.5 -> 1.6
src/main/java/org/lcsim/hps/recon/tracking/HPSSVTCalibrationConstants.java+85-461.7 -> 1.8
src/main/resources/org/lcsim/hps/steering/TestRunEventDisplay.lcsim+3-51.2 -> 1.3
                                         /ECalMonitoring.lcsim+3-31.6 -> 1.7
                                         /TestRunMonitoring.lcsim+2-41.16 -> 1.17
scripts/et_evio_file_producer_test.sh+2-11.14 -> 1.15
src/main/java/org/lcsim/hps/monitoring/svt/SVTHitPulsePlots.java+11.11 -> 1.12
+464-221
2 added + 19 modified, total 21 files
time-dependent calibrations! all calibrations should now be loaded by a driver or by an EtEventListener!

hps-java/src/main/java/org/lcsim/hps/evio
ECalEvioWriter.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- ECalEvioWriter.java	4 May 2012 17:18:57 -0000	1.5
+++ ECalEvioWriter.java	12 May 2012 23:09:05 -0000	1.6
@@ -25,7 +25,7 @@
 /**
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalEvioWriter.java,v 1.5 2012/05/04 17:18:57 meeg Exp $
+ * @version $Id: ECalEvioWriter.java,v 1.6 2012/05/12 23:09:05 meeg Exp $
  */
 public class ECalEvioWriter implements EvioWriter {
 
@@ -68,7 +68,7 @@
     @Override
     public void writeData(EventHeader event, EventBuilder builder) {
         if (!HPSEcalConditions.mapLoaded()) {
-            HPSEcalConditions.fillDaqCellMap(event.getDetector().getSubdetector(ecalName));
+            HPSEcalConditions.subdetectorChanged(event.getDetector().getSubdetector(ecalName));
         }
         LCMetaData meta;
         List<RawCalorimeterHit> rawCalorimeterHits;

hps-java/src/main/java/org/lcsim/hps/evio
TestRunEvioToLcio.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- TestRunEvioToLcio.java	8 May 2012 15:52:52 -0000	1.9
+++ TestRunEvioToLcio.java	12 May 2012 23:09:05 -0000	1.10
@@ -12,6 +12,7 @@
 import org.jlab.coda.jevio.EvioEvent;
 import org.jlab.coda.jevio.EvioReader;
 import org.lcsim.event.EventHeader;
+import org.lcsim.hps.monitoring.HPSCalibrationListener;
 import org.lcsim.job.JobControlManager;
 import org.lcsim.util.lcio.LCIOWriter;
 
@@ -141,6 +142,9 @@
         LCSimEventBuilder eventBuilder = new LCSimTestRunEventBuilder();
         eventBuilder.setDetectorName(detectorName);
 
+        HPSCalibrationListener calibListener = new HPSCalibrationListener();
+        calibListener.begin();
+
         for (String evioFileName : cl.getArgs()) {
             // EVIO input file.
             File evioFile = new File(evioFileName);
@@ -160,7 +164,7 @@
                 EvioEvent evioEvent = null;
                 try {
                     eventLoop:
-                    do {
+                    while (evioEvent == null) {
                         evioEvent = reader.nextEvent();
                         if (evioEvent == null) {
                             break fileLoop;
@@ -171,14 +175,28 @@
                             e.printStackTrace();
                             continue eventLoop;
                         }
-                    } while (!eventBuilder.isPhysicsEvent(evioEvent));
-
-                    EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent);
-                    jobManager.processEvent(lcioEvent);
-                    if (writer != null) {
-                        writer.write(lcioEvent);
-                        writer.flush();
                     }
+                    // Handlers for different event types.
+                    if (EventConstants.isPreStartEvent(evioEvent)) {
+                        int[] data = evioEvent.getIntData();
+                        int seconds = data[0];
+                        int runNumber = data[1];
+                        calibListener.prestart(seconds, runNumber);
+                    } else if (EventConstants.isEndEvent(evioEvent)) {
+                        int[] data = evioEvent.getIntData();
+                        int seconds = data[0];
+                        int nevents = data[2];
+                        calibListener.endRun(seconds, nevents);
+                    } else 
+                        if (eventBuilder.isPhysicsEvent(evioEvent)) {
+                        EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent);
+                        jobManager.processEvent(lcioEvent);
+                        if (writer != null) {
+                            writer.write(lcioEvent);
+                            writer.flush();
+                        }
+                    }
+
                 } catch (Exception e) {
                     // Catch all event processing errors and continue.
                     e.printStackTrace();

hps-java/src/main/java/org/lcsim/hps/evio
EventConstants.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- EventConstants.java	2 May 2012 14:55:52 -0000	1.10
+++ EventConstants.java	12 May 2012 23:09:05 -0000	1.11
@@ -1,5 +1,7 @@
 package org.lcsim.hps.evio;
 
+import org.jlab.coda.jevio.EvioEvent;
+
 public final class EventConstants {
 
     //event type tag
@@ -36,6 +38,25 @@
     public static final int ECAL_PULSE_BANK_TAG = 0xe102;
     // The tag for ECal pulse integral data.
     public static final int ECAL_PULSE_INTEGRAL_BANK_TAG = 0xe103;
-    
     public static final int SVT_TOTAL_NUMBER_FPGAS = 8;
+
+    /**
+     * Check if this event is a Pre Start Event.
+     *
+     * @param event
+     * @return
+     */
+    public static boolean isPreStartEvent(EvioEvent event) {
+        return event.getHeader().getTag() == EventConstants.PRESTART_EVENT_TAG;
+    }
+
+    /**
+     * Check if this event is an End Event.
+     *
+     * @param event
+     * @return True if this event is an End Event; false if not.
+     */
+    public static boolean isEndEvent(EvioEvent event) {
+        return event.getHeader().getTag() == EventConstants.END_EVENT_TAG;
+    }
 }

hps-java/src/main/java/org/lcsim/hps/evio
ECalEvioReader.java 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- ECalEvioReader.java	8 May 2012 15:49:32 -0000	1.15
+++ ECalEvioReader.java	12 May 2012 23:09:05 -0000	1.16
@@ -16,7 +16,7 @@
 /**
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalEvioReader.java,v 1.15 2012/05/08 15:49:32 meeg Exp $
+ * @version $Id: ECalEvioReader.java,v 1.16 2012/05/12 23:09:05 meeg Exp $
  */
 public class ECalEvioReader extends EvioReader {
     // Names of subdetectors.
@@ -39,7 +39,7 @@
         boolean foundHits = false;
         if (!HPSEcalConditions.mapLoaded()) {
             detector = lcsimEvent.getDetector();
-            HPSEcalConditions.fillDaqCellMap(lcsimEvent.getDetector().getSubdetector(ecalName));
+            HPSEcalConditions.subdetectorChanged(lcsimEvent.getDetector().getSubdetector(ecalName));
         }
         List<Object> hits = new ArrayList<Object>();
         hitClass = Object.class;

hps-java/src/main/java/org/lcsim/hps/monitoring
HPSCalibrationListener.java added at 1.1
diff -N HPSCalibrationListener.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HPSCalibrationListener.java	12 May 2012 23:09:05 -0000	1.1
@@ -0,0 +1,81 @@
+package org.lcsim.hps.monitoring;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import org.lcsim.conditions.ConditionsSet;
+import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPSCalibrationListener.java,v 1.1 2012/05/12 23:09:05 meeg Exp $
+ */
+public class HPSCalibrationListener implements EtEventListener {
+
+    @Override
+    public void begin() {
+        HPSSVTCalibrationConstants.loadCalibrationConstants(new Date(System.currentTimeMillis()));
+        HPSEcalConditions.loadPedestals();
+    }
+
+    @Override
+    public void startOfEvent() {
+    }
+
+    @Override
+    public void endOfEvent() {
+    }
+
+    @Override
+    public void errorOnEvent() {
+    }
+
+    @Override
+    public void finish() {
+    }
+
+    @Override
+    public void prestart(int seconds, int runNumber) {
+        HPSSVTCalibrationConstants.loadCalibrationConstants(new Date(((long) seconds) * 1000));
+    }
+
+    @Override
+    public void endRun(int seconds, int nevents) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    //parse specified conditions as a map of times (GMT) to calibration file paths; get the appropriate file
+    public static String getCalibForDate(ConditionsSet calibSet, Date date) {
+        System.out.println("Reading calibrations for date: " + date);
+
+        Date mostRecentValid = null;
+        String filePath = null;
+        for (Object time : calibSet.keySet()) {
+            String[] timeTokens = ((String) time).split("_");
+            Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+            switch (timeTokens.length) {
+                case 3:
+                    calendar.set(Integer.parseInt(timeTokens[0]), Integer.parseInt(timeTokens[1])-1, Integer.parseInt(timeTokens[2]));
+                    break;
+                case 5:
+                    calendar.set(Integer.parseInt(timeTokens[0]), Integer.parseInt(timeTokens[1])-1, Integer.parseInt(timeTokens[2]), Integer.parseInt(timeTokens[3]), Integer.parseInt(timeTokens[4]));
+                    break;
+                case 6:
+                    calendar.set(Integer.parseInt(timeTokens[0]), Integer.parseInt(timeTokens[1])-1, Integer.parseInt(timeTokens[2]), Integer.parseInt(timeTokens[3]), Integer.parseInt(timeTokens[4]), Integer.parseInt(timeTokens[5]));
+                    break;
+                default:
+                    throw new RuntimeException("Invalid timestamp: " + time);
+            }
+//            System.out.println("Available calibration for date: " + calendar.getTime());
+            if ((mostRecentValid == null || calendar.getTime().after(mostRecentValid)) && calendar.getTime().before(date)) {
+                mostRecentValid = calendar.getTime();
+                filePath = calibSet.getString((String) time);
+            }
+        }
+        System.out.println("Use this calibration from " + mostRecentValid + ": " + filePath);
+        return filePath;
+    }
+}

hps-java/src/main/java/org/lcsim/hps/monitoring
HPSCalibrationDriver.java added at 1.1
diff -N HPSCalibrationDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HPSCalibrationDriver.java	12 May 2012 23:09:05 -0000	1.1
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.monitoring;
+
+import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.tracking.HPSSVTDAQMaps;
+import org.lcsim.hps.recon.tracking.HPSSVTSensorSetup;
+import org.lcsim.util.Driver;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPSCalibrationDriver.java,v 1.1 2012/05/12 23:09:05 meeg Exp $
+ */
+public class HPSCalibrationDriver extends Driver {
+    public HPSCalibrationDriver() {
+        add(new HPSEcalConditions());
+        add(new HPSSVTDAQMaps());
+        add(new HPSSVTSensorSetup());
+    }
+}

hps-java/src/main/java/org/lcsim/hps/monitoring
RunControlDriver.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- RunControlDriver.java	10 May 2012 15:55:55 -0000	1.1
+++ RunControlDriver.java	12 May 2012 23:09:05 -0000	1.2
@@ -11,7 +11,7 @@
 /**
  * Lightweight driver for stepping through events in offline analysis, without running the MonitoringApp.
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: RunControlDriver.java,v 1.1 2012/05/10 15:55:55 meeg Exp $
+ * @version $Id: RunControlDriver.java,v 1.2 2012/05/12 23:09:05 meeg Exp $
  */
 public class RunControlDriver extends Driver implements ActionListener {
 
@@ -32,11 +32,15 @@
         runButton.addActionListener(this);
         nextFrame.add(runButton);
 
-        nextFrame.setVisible(true);
         nextFrame.pack();
     }
 
     @Override
+    protected void startOfData() {
+        nextFrame.setVisible(true);
+    }
+
+    @Override
     protected void process(EventHeader event) {
         if (!run) {
             synchronized (nextButton) {
@@ -50,7 +54,7 @@
 
     @Override
     protected void endOfData() {
-        nextFrame.dispose();
+        nextFrame.setVisible(false);
     }
 
     @Override

hps-java/src/main/java/org/lcsim/hps/monitoring
MonitoringApplication.java 1.46 -> 1.47
diff -u -r1.46 -r1.47
--- MonitoringApplication.java	10 May 2012 23:39:37 -0000	1.46
+++ MonitoringApplication.java	12 May 2012 23:09:05 -0000	1.47
@@ -59,11 +59,13 @@
 import org.lcsim.util.aida.AIDA;
 
 /**
- * Monitoring application for HPS Test Run, which can run LCSim steering files on data converted from the ET
- * ring. This class is accessible to users by calling its main() method.
- * 
+ * Monitoring application for HPS Test Run, which can run LCSim steering files
+ * on data converted from the ET ring. This class is accessible to users by
+ * calling its main() method.
+ *
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: MonitoringApplication.java,v 1.46 2012/05/10 23:39:37 jeremy Exp $
+ * @version $Id: MonitoringApplication.java,v 1.46 2012/05/10 23:39:37 jeremy
+ * Exp $
  */
 public class MonitoringApplication {
 
@@ -76,7 +78,6 @@
     private JobPanel jobPanel;
     private JMenuBar menuBar;
     private EventButtonsPanel buttonsPanel;
-
     // References to menu items that will be enabled/disabled depending on application state.
     private JMenuItem connectItem;
     private JMenuItem disconnectItem;
@@ -92,67 +93,58 @@
     private JMenuItem saveJobSettingsItem;
     private JMenuItem loadJobSettingsItem;
     private JMenuItem resetJobSettingsItem;
-
     // Saved references to System.out and System.err in case need to reset.
     private final PrintStream sysOut = System.out;
     private final PrintStream sysErr = System.err;
-
     // ET connection parameters and state.
     private ConnectionParameters connectionParameters;
     private EtConnection connection;
     private int connectionStatus = ConnectionStatus.DISCONNECTED;
-
     // Event processing objects.
     private JobControlManager jobManager;
     private LCSimEventBuilder eventBuilder;
     private EtEventProcessor eventProcessor;
     private Thread eventProcessingThread;
-
+    private HPSCalibrationListener calibListener;
     // Job timing.
     private Timer timer;
     private long jobStartTime;
-
     // ActionListener for GUI event dispatching.
     private ActionListener actionListener;
-
     // Logging objects.
     private static Logger logger;
     private Handler logHandler;
     private DefaultTableModel logTableModel;
     private JTable logTable;
-
     // Some default GUI size parameters.
     private final int logTableWidth = 700;
     private final int logTableHeight = 320;
-
     // Format for screenshots. Hard-coded to PNG.
     private static final String screenshotFormat = "png";
-
     // The AIDA remote server.
     private AIDAServer server;
-
     // Listener for processing EtEvents.
     private EtEventListener etListener = new MonitoringApplicationEtListener();
-
     // Maximum time in millis to wait for the ET system to disconnect.
     // TODO: Make this an option in the JobPanel.
     private int maxCleanupTime = 5000;
-
     // Format of date field for log.
     private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss.SSS");
-
     private static final String LCSIM_FAIL_MESSAGE = "Failed to setup LCSim.";
 
     /**
-     * Constructor for monitoring application. Users should not need to use this; call main() method instead.
+     * Constructor for monitoring application. Users should not need to use
+     * this; call main() method instead.
      */
     private MonitoringApplication() {
 
         // Create and configure the logger.
         setupLogger();
-        
+
         // Create the ActionEventListener for event dispatching.
         actionListener = new MonitoringApplicationActionListener();
+        
+        calibListener = new HPSCalibrationListener();
 
         // Setup the application menus.
         createMenu();
@@ -405,10 +397,10 @@
          * Puts log messages into the application's log table GUI component.
          */
         public void publish(LogRecord record) {
-            Object[] row = new Object[] {record.getLoggerName(), // source
-                    record.getMessage(), // message
-                    dateFormat.format(new Date(record.getMillis())), // date
-                    record.getLevel()}; // level
+            Object[] row = new Object[]{record.getLoggerName(), // source
+                record.getMessage(), // message
+                dateFormat.format(new Date(record.getMillis())), // date
+                record.getLevel()}; // level
             logTableModel.insertRow(logTable.getRowCount(), row);
         }
 
@@ -420,8 +412,8 @@
     }
 
     /**
-     * Creates the application's log table GUI component, which is a JTable containing messages from the
-     * logger.
+     * Creates the application's log table GUI component, which is a JTable
+     * containing messages from the logger.
      */
     private void createLogTable() {
         final String[] logTableColumns = {"Source", "Message", "Date", "Level"};
@@ -443,7 +435,8 @@
     }
 
     /**
-     * Setup the application's Logger object for writing messages to the log table.
+     * Setup the application's Logger object for writing messages to the log
+     * table.
      */
     private void setupLogger() {
         logger = Logger.getLogger(this.getClass().getSimpleName());
@@ -455,12 +448,13 @@
 
     /**
      * Create the monitoring application frame and run it on a separate thread.
-     * 
+     *
      * @return Reference to the created application.
      */
     private static final MonitoringApplication createMonitoringApplication() {
         final MonitoringApplication app = new MonitoringApplication();
         SwingUtilities.invokeLater(new Runnable() {
+
             public void run() {
                 app.createApplicationFrame();
             }
@@ -470,7 +464,7 @@
 
     /**
      * Run the monitoring application from the command line.
-     * 
+     *
      * @param args The command line arguments.
      */
     public static void main(String[] args) {
@@ -486,8 +480,7 @@
         CommandLine cl = null;
         try {
             cl = parser.parse(options, args);
-        }
-        catch (ParseException e) {
+        } catch (ParseException e) {
             throw new RuntimeException("Problem parsing command line options.", e);
         }
 
@@ -524,8 +517,7 @@
             if (jobPanel.logToFile()) {
                 redirectStdOutAndErrToFile(new File(jobPanel.getLogFileName()));
             }
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             throw new RuntimeException(e);
         }
     }
@@ -541,7 +533,8 @@
                 // Log actions performed.  Catch errors in case logging is not initialized yet.
                 try {
                     logger.log(Level.FINEST, "Action performed <" + cmd + ">.");
-                } catch (Exception xx) {}
+                } catch (Exception xx) {
+                }
             }
             if (connectCmd.equals(cmd)) {
                 startSessionThread();
@@ -600,9 +593,9 @@
             } else if (steeringFileCmd.equals(cmd)) {
                 selectSteeringFile();
             }
-        }       
+        }
     }
-    
+
     /**
      * This fires when a steering resource file is selected from the combo box.
      * The Job Settings are changed to use a resource type.
@@ -621,8 +614,7 @@
             try {
                 settings.save(f);
                 logger.log(Level.INFO, "Saved Job Settings to properties file <" + f.getPath() + ">.");
-            }
-            catch (IOException e) {
+            } catch (IOException e) {
                 e.printStackTrace();
                 logger.log(Level.SEVERE, "Error saving Job Settings to properties file <" + f.getPath() + ">.");
                 showDialog("Error saving Job Settings to properties file.");
@@ -639,8 +631,7 @@
             try {
                 jobPanel.setJobSettings(new JobSettings(f));
                 logger.log(Level.INFO, "Loaded Job Settings from properties file <" + f.getPath() + ">.");
-            }
-            catch (IOException e) {
+            } catch (IOException e) {
                 e.printStackTrace();
                 logger.log(Level.SEVERE, "Error loading Job Settings from properties file <" + f.getPath() + ">.");
                 showDialog("Error loading Job Settings from properties file.");
@@ -655,12 +646,13 @@
     }
 
     /**
-     * This is the primary entry point for starting a monitoring session. The session is started on a new
-     * thread so it doesn't block.
+     * This is the primary entry point for starting a monitoring session. The
+     * session is started on a new thread so it doesn't block.
      */
     private void startSessionThread() {
         if (getConnectionStatus() != ConnectionStatus.CONNECTED) {
             Runnable r = new Runnable() {
+
                 public void run() {
                     session();
                 }
@@ -673,7 +665,8 @@
     }
 
     /**
-     * Set a new log level for the application and also forward to the event processor.
+     * Set a new log level for the application and also forward to the event
+     * processor.
      */
     private void setLogLevel() {
         Level newLevel = jobPanel.getLogLevel();
@@ -749,8 +742,7 @@
                     if (jobManager != null) {
                         jobManager.finish();
                     }
-                }
-                catch (Exception e) {
+                } catch (Exception e) {
                     e.printStackTrace();
                     logger.log(Level.WARNING, "Error cleaning up LCSim job.");
                 }
@@ -769,8 +761,7 @@
                     server = null;
                     logger.log(Level.CONFIG, "Remote AIDA server was closed.");
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
                 logger.log(Level.WARNING, "Error in finish() method <" + e.getMessage() + ">.");
             }
@@ -801,7 +792,7 @@
 
     /**
      * Set the connection status.
-     * 
+     *
      * @param status The connection status.
      */
     private void setConnectionStatus(int status) {
@@ -813,7 +804,7 @@
 
     /**
      * Get the current connection status.
-     * 
+     *
      * @return The connection status.
      */
     private int getConnectionStatus() {
@@ -822,7 +813,7 @@
 
     /**
      * Pop-up a modal dialog.
-     * 
+     *
      * @param m The message to display in the dialog box.
      */
     private void showDialog(String m) {
@@ -830,8 +821,8 @@
     }
 
     /**
-     * Setup the frame to run the application. This should be called using Runnable.run() (see
-     * MonitoringExample).
+     * Setup the frame to run the application. This should be called using
+     * Runnable.run() (see MonitoringExample).
      */
     private void createApplicationFrame() {
         mainPanel.setOpaque(true);
@@ -856,8 +847,7 @@
             try {
                 AIDA.defaultInstance().saveAs(fileName);
                 logger.log(Level.INFO, "Plots saved to <" + fileName + ">.");
-            }
-            catch (IOException e) {
+            } catch (IOException e) {
                 e.printStackTrace();
             }
         }
@@ -876,8 +866,7 @@
                 jobPanel.setSteeringFile(fileName.getPath());
                 jobPanel.setSteeringType(JobPanel.FILE);
                 logger.log(Level.INFO, "Steering file set to <" + fileName.getPath() + ">.");
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
                 logger.log(Level.SEVERE, "Failed to read steering file <" + fileName.getPath() + ">.");
                 showDialog("Failed to read the LCSim XML file.");
@@ -887,7 +876,7 @@
 
     /**
      * Get the full title of the application.
-     * 
+     *
      * @return The application title.
      */
     private static String getApplicationTitle() {
@@ -896,21 +885,20 @@
 
     /**
      * Get the hostname, which is used in the application title.
-     * 
+     *
      * @return The hostname.
      */
     private static String getHostname() {
         try {
             return InetAddress.getLocalHost().getHostName();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return "UNKNOWN_HOST";
         }
     }
 
     /**
      * Get the user name, which is used in the application title.
-     * 
+     *
      * @return The user name.
      */
     private static String getUserName() {
@@ -922,7 +910,8 @@
     }
 
     /**
-     * Call the reset() method on Drivers which implement {@link Resettable}. They must implement the
+     * Call the reset() method on Drivers which implement {@link Resettable}.
+     * They must implement the
      * {@link Resettable} interface for this to work.
      */
     private synchronized void resetDrivers() {
@@ -931,8 +920,7 @@
                 if (driver instanceof Resettable) {
                     try {
                         ((Resettable) driver).reset();
-                    }
-                    catch (Exception e) {
+                    } catch (Exception e) {
                         e.printStackTrace();
                     }
                 }
@@ -942,8 +930,9 @@
     }
 
     /**
-     * Redirect System.out and System.err to a file. This is primarily used to capture lengthy debug 
-     * output from event processing.  Messages sent to the Logger are unaffected.
+     * Redirect System.out and System.err to a file. This is primarily used to
+     * capture lengthy debug output from event processing. Messages sent to the
+     * Logger are unaffected.
      */
     private void logToFile() {
         JFileChooser fc = new JFileChooser();
@@ -958,10 +947,11 @@
                     if (!logFile.createNewFile()) {
                         throw new IOException();
                     }
-                    
+
                     redirectStdOutAndErrToFile(logFile);
 
                     SwingUtilities.invokeLater(new Runnable() {
+
                         public void run() {
                             jobPanel.setLogToFile(true);
                             jobPanel.setLogFile(logFile.getPath());
@@ -972,8 +962,7 @@
                     });
 
                     logger.log(Level.INFO, "Redirected System output to file <" + logFile.getPath() + ">.");
-                }
-                catch (IOException e) {
+                } catch (IOException e) {
                     logger.log(Level.SEVERE, "Error redirecting System output to file <" + logFile.getPath() + ">.");
                     showDialog("Error redirecting System output to log file.");
                 }
@@ -988,13 +977,15 @@
     }
 
     /**
-     * Redirect System.out and System.err back to the terminal, e.g. if they were previously sent to a file.
-     * This is independent of messages that are sent to the application's log table.
+     * Redirect System.out and System.err back to the terminal, e.g. if they
+     * were previously sent to a file. This is independent of messages that are
+     * sent to the application's log table.
      */
     private void logToTerminal() {
         System.setOut(sysOut);
         System.setErr(sysErr);
         SwingUtilities.invokeLater(new Runnable() {
+
             public void run() {
                 jobPanel.setLogFile("");
                 jobPanel.setLogToFile(false);
@@ -1017,15 +1008,15 @@
             }
             eventPanel.setEventRefresh(newEventRefresh);
             logger.log(Level.INFO, "Event refresh set to <" + newEventRefresh + ">.");
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             logger.log(Level.WARNING, "Ignored invalid event refresh setting.");
             showDialog("The value " + inputValue + " is not valid for Event Refresh Rate.");
         }
     }
 
     /**
-     * Using a modal dialog, set the maximum number of events to process before an automatic disconnect.
+     * Using a modal dialog, set the maximum number of events to process before
+     * an automatic disconnect.
      */
     private void setMaxEvents() {
         String inputValue = JOptionPane.showInputDialog("Max Events:", eventPanel.getMaxEvents());
@@ -1038,18 +1029,19 @@
             // Set max events in panel.
             eventPanel.setMaxEvents(newMaxEvents);
             // Set max events in event processor.
-            if (eventProcessor != null)
+            if (eventProcessor != null) {
                 eventProcessor.setMaxEvents(newMaxEvents);
+            }
             logger.log(Level.INFO, "Max events set to <" + newMaxEvents + ">.");
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             logger.log(Level.WARNING, "Ignored invalid max events setting <" + inputValue + ">.");
             showDialog("The value " + inputValue + " is not valid for Max Events.");
         }
     }
 
     /**
-     * Set the GUI state to disconnected, which will enable/disable applicable GUI components and menu items.
+     * Set the GUI state to disconnected, which will enable/disable applicable
+     * GUI components and menu items.
      */
     private void setDisconnectedGuiState() {
 
@@ -1079,7 +1071,8 @@
     }
 
     /**
-     * Set the GUI to connected state, which will enable/disable appropriate components and menu items.
+     * Set the GUI to connected state, which will enable/disable appropriate
+     * components and menu items.
      */
     private void setConnectedGuiState() {
 
@@ -1138,7 +1131,7 @@
 
     /**
      * Save a screenshot to an output file.
-     * 
+     *
      * @param fileName The name of the output file.
      */
     private void takeScreenshot(String fileName) {
@@ -1148,18 +1141,17 @@
             Robot robot = new Robot();
             BufferedImage image = robot.createScreenCapture(screenRectangle);
             ImageIO.write(image, screenshotFormat, new File(fileName));
-        }
-        catch (AWTException e) {
+        } catch (AWTException e) {
             showDialog(e.getMessage());
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             showDialog(e.getMessage());
         }
     }
 
     /**
-     * Get the fully qualified class name of the current event builder for converting from EVIO to LCIO.
-     * 
+     * Get the fully qualified class name of the current event builder for
+     * converting from EVIO to LCIO.
+     *
      * @return The class name of the event builder.
      */
     private String getEventBuilderClassName() {
@@ -1168,7 +1160,7 @@
 
     /**
      * Get the type of steering file being used.
-     * 
+     *
      * @return The type of the steering file.
      */
     private int getSteeringType() {
@@ -1177,7 +1169,7 @@
 
     /**
      * Get the current max events setting.
-     * 
+     *
      * @return The maximum number of events to process before disconnect.
      */
     private int getMaxEvents() {
@@ -1212,25 +1204,22 @@
             // Wait for the event processing thread to finish.
             try {
                 eventProcessingThread.join();
-            }
-            catch (InterruptedException e) {
+            } catch (InterruptedException e) {
             }
             logger.log(Level.INFO, "Event processor finished with status <" + ConnectionStatus.toString(eventProcessor.getStatus()) + ">.");
             endStatus = eventProcessor.getStatus();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             logger.log(Level.SEVERE, "Fatal error in monitoring session.");
             endStatus = ConnectionStatus.ERROR;
-        }
-        finally {
+        } finally {
             logHandler.flush();
             // Disconnect if needed.
             if (getConnectionStatus() != ConnectionStatus.DISCONNECTED) {
                 disconnect(endStatus);
             }
         }
-        
+
         logger.log(Level.INFO, "Finished monitoring session.");
     }
 
@@ -1252,7 +1241,8 @@
     }
 
     /**
-     * Create the thread that will execute the EtEvent processing chain.     
+     * Create the thread that will execute the EtEvent processing chain.
+     *
      * @return The thread on which event processing will occur.
      */
     private void createEventProcessingThread() {
@@ -1263,26 +1253,31 @@
         // Add the application's listener for callback to the GUI.
         eventProcessor.addListener(this.etListener);
 
+        // Add listener for loading calibration files.
+        eventProcessor.addListener(this.calibListener);
+        
         // Set pause mode from JobPanel, after which it can be toggled using the event buttons.
         eventProcessor.pauseMode(this.jobPanel.pauseMode());
 
         // Create a new thread for event processing.
         Runnable run = new Runnable() {
+
             public void run() {
                 eventProcessor.process();
             }
         };
         eventProcessingThread = new Thread(run, "Event Processing Thread");
-        
+
         // Start the event processing thread.
         eventProcessingThread.start();
-        
+
         logger.log(Level.FINEST, "Started event processing thread.");
         logHandler.flush();
     }
 
     /**
-     * Connect to the ET system specified in the GUI's connection panel settings.
+     * Connect to the ET system specified in the GUI's connection panel
+     * settings.
      */
     private void connect() {
 
@@ -1300,8 +1295,9 @@
     }
 
     /**
-     * Get the steering parameter, which is either a file path or resource string.
-     * 
+     * Get the steering parameter, which is either a file path or resource
+     * string.
+     *
      * @return The steering parameter.
      */
     private String getSteering() {
@@ -1310,7 +1306,7 @@
 
     /**
      * Get the name of the detector for conditions data.
-     * 
+     *
      * @return The name of the detector.
      */
     private String getDetectorName() {
@@ -1319,7 +1315,7 @@
 
     /**
      * Get the connection parameter settings from the connection panel.
-     * 
+     *
      * @return The connection parameters.
      */
     private ConnectionParameters getConnectionParameters() {
@@ -1328,7 +1324,7 @@
 
     /**
      * Get whether a warning dialog will open before disconnect.
-     * 
+     *
      * @return True if warning will occur before disconnect; false if no.
      */
     private boolean warnOnDisconnect() {
@@ -1337,7 +1333,7 @@
 
     /**
      * Get whether errors in event processing will cause automatic disconnect.
-     * 
+     *
      * @return True if disconnect on event processing error; false to continue.
      */
     private boolean disconnectOnError() {
@@ -1350,7 +1346,7 @@
 
     /**
      * Disconnect from the current ET session with a particular status.
-     * 
+     *
      * @param status The connection status.
      */
     synchronized private void disconnect(int status) {
@@ -1391,9 +1387,10 @@
     }
 
     /**
-     * This is a thread for cleaning up the ET connection.  This is executed under a separate
-     * path of execution, because it could potentially block forever.  So we need to be able
-     * to kill it after waiting for X amount of time.
+     * This is a thread for cleaning up the ET connection. This is executed
+     * under a separate path of execution, because it could potentially block
+     * forever. So we need to be able to kill it after waiting for X amount of
+     * time.
      */
     class EtCleanupThread extends Thread {
 
@@ -1433,8 +1430,7 @@
             try {
                 // Wait for cleanup thread to finish.
                 cleanupThread.join(this.maxCleanupTime);
-            }
-            catch (InterruptedException e) {
+            } catch (InterruptedException e) {
             }
 
             if (cleanupThread.succeeded()) {
@@ -1479,7 +1475,7 @@
             // Create job manager and configure based on steering type of resource or file.
             jobManager = new JobControlManager();
             jobManager.setPerformDryRun(true);
-            if (steeringType == JobPanel.RESOURCE) {                
+            if (steeringType == JobPanel.RESOURCE) {
                 logger.log(Level.FINE, "Setting up steering resource <" + steering + ">.");
                 InputStream is = this.getClass().getClassLoader().getResourceAsStream(steering);
                 jobManager.setup(is);
@@ -1491,8 +1487,7 @@
 
             // Reset the reference to the event builder.
             createEventBuilder();
-        }
-        // Catch all other setup exceptions and re-throw them as RuntimeExceptions.
+        } // Catch all other setup exceptions and re-throw them as RuntimeExceptions.
         catch (Exception e) {
             e.printStackTrace();
             logger.log(Level.SEVERE, LCSIM_FAIL_MESSAGE);
@@ -1514,8 +1509,7 @@
 
         try {
             eventBuilder = (LCSimEventBuilder) Class.forName(eventBuilderClassName).newInstance();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new RuntimeException("Failed to create LCSimEventBuilder class.", e);
         }
 
@@ -1524,12 +1518,13 @@
 
         logger.log(Level.CONFIG, "Successfully initialized event builder <" + eventBuilderClassName + ">.");
     }
-    
+
     /**
      * Disconnect from the ET system using a separate thread of execution.
      */
     private void startDisconnectThread() {
         Runnable r = new Runnable() {
+
             public void run() {
                 disconnect();
             }
@@ -1539,8 +1534,9 @@
     }
 
     /**
-     * Create a connection to an ET system using current parameters from the GUI. 
-     * If successful, the application's ConnectionStatus is changed to CONNECTED.
+     * Create a connection to an ET system using current parameters from the
+     * GUI. If successful, the application's ConnectionStatus is changed to
+     * CONNECTED.
      */
     private void createEtConnection() {
 
@@ -1599,7 +1595,8 @@
     }
 
     /**
-     * Save the accumulated log messages to a tab-delimited text file selected using a file chooser.
+     * Save the accumulated log messages to a tab-delimited text file selected
+     * using a file chooser.
      */
     private void saveLogToFile() {
         JFileChooser fc = new JFileChooser();
@@ -1621,8 +1618,7 @@
                     out.write(buf.toString());
                     out.close();
                     logger.log(Level.FINE, "Saved log to file <" + logFile.getPath() + ">.");
-                }
-                catch (IOException e) {
+                } catch (IOException e) {
                     logger.log(Level.SEVERE, "Failed to save log to file <" + logFile.getPath() + ">.");
                     showDialog("Failed to save log file.");
                 }
@@ -1639,8 +1635,9 @@
     }
 
     /**
-     * Get whether or not connected to the ET system with an active monitoring session.
-     * 
+     * Get whether or not connected to the ET system with an active monitoring
+     * session.
+     *
      * @return True if connected to ET system; false if not.
      */
     private boolean connected() {
@@ -1660,7 +1657,8 @@
     }
 
     /**
-     * Notify the event processor to resume processing events in real-time mode, if paused.
+     * Notify the event processor to resume processing events in real-time mode,
+     * if paused.
      */
     private void resume() {
         if (connected()) {
@@ -1679,7 +1677,8 @@
     }
 
     /**
-     * Notify the event processor to start pause mode, which will pause between events.
+     * Notify the event processor to start pause mode, which will pause between
+     * events.
      */
     private void pause() {
         if (connected()) {

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalClusterPlots.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EcalClusterPlots.java	10 May 2012 15:55:55 -0000	1.2
+++ EcalClusterPlots.java	12 May 2012 23:09:05 -0000	1.3
@@ -62,11 +62,12 @@
         clusterEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Energy", 1000, -100, 5000);
         clusterMaxEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Maximum Cluster Energy In Event", 1000, -100, 5000);
 
+
         // Create the plotter regions.
         plotter2.createRegions(1, 2);
         plotter2.region(0).plot(clusterEnergyPlot);
         plotter2.region(1).plot(clusterMaxEnergyPlot);
-        
+
         plotterFrame.setVisible(true);
         plotterFrame.pack();
     }

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalWindowPlots.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EcalWindowPlots.java	8 May 2012 15:49:31 -0000	1.4
+++ EcalWindowPlots.java	12 May 2012 23:09:05 -0000	1.5
@@ -87,7 +87,6 @@
         }
 
         Subdetector subdetector = detector.getSubdetector(subdetectorName);
-        HPSEcalConditions.fillDaqCellMap(subdetector);
 
         setupPlots();
     }

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalDaqPlots.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EcalDaqPlots.java	2 May 2012 14:55:52 -0000	1.4
+++ EcalDaqPlots.java	12 May 2012 23:09:05 -0000	1.5
@@ -53,7 +53,6 @@
 		}
 
 		Subdetector subdetector = detector.getSubdetector(subdetectorName);
-		HPSEcalConditions.fillDaqCellMap(subdetector);
 
 		setupPlots();
 	}

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalEvsX.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- EcalEvsX.java	8 May 2012 15:49:31 -0000	1.3
+++ EcalEvsX.java	12 May 2012 23:09:05 -0000	1.4
@@ -1,9 +1,11 @@
 package org.lcsim.hps.monitoring.ecal;
 
+import hep.aida.IHistogram1D;
 import hep.aida.IHistogram2D;
 import hep.aida.IPlotter;
 import hep.aida.IPlotterStyle;
 import hep.aida.ref.plotter.PlotterRegion;
+import hep.physics.vec.BasicHepLorentzVector;
 
 import java.util.List;
 import org.lcsim.event.Cluster;
@@ -21,8 +23,11 @@
     AIDA aida = AIDA.defaultInstance();
     IPlotter plotter;
     IHistogram2D EvsXPlot;
+    IHistogram1D invMassPlot;
+    IHistogram2D clusterPairEnergyPlot;
     Detector detector;
     int eventn = 0;
+    double targetZ = 0;
 
     public void setInputCollection(String inputCollection) {
         this.inputCollection = inputCollection;
@@ -32,6 +37,10 @@
         this.subdetectorName = subdetectorName;
     }
 
+    public void setTargetZ(double targetZ) {
+        this.targetZ = targetZ;
+    }
+
     protected void detectorChanged(Detector detector) {
 
         this.detector = detector;
@@ -45,17 +54,26 @@
 
         // Setup plots.
         aida.tree().cd("/");
-        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X",50,-400.0,400.0,200,-500,10000);
+        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -400.0, 400.0, 200, -500, 10000);
+        invMassPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Photon Pair Mass", 1000, 0.0, 5000.0);
+        clusterPairEnergyPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Energies", 1000, -100, 2000, 1000, -100, 2000);
 
         // Create the plotter regions.
-        plotter.createRegion();
-        plotter.style().statisticsBoxStyle().setVisible(false);
+        plotter.createRegions(2, 2);
+//        plotter.style().statisticsBoxStyle().setVisible(false);
         IPlotterStyle style = plotter.region(0).style();
         style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
         style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(1).style().yAxisStyle().setParameter("scale", "log");
         plotter.region(0).plot(EvsXPlot);
-        ((PlotterRegion) plotter.region(0)).getPlot().setAllowUserInteraction(false);
-        ((PlotterRegion) plotter.region(0)).getPlot().setAllowPopupMenus(false);
+        plotter.region(1).plot(invMassPlot);
+        plotter.region(2).plot(clusterPairEnergyPlot);
+        style = plotter.region(2).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style.zAxisStyle().setParameter("scale", "log");
         plotter.show();
     }
 
@@ -77,6 +95,38 @@
                     EvsXPlot.fill(cluster.getPosition()[0], cluster.getEnergy());
                 }
             }
+            double[] totalP = new double[3];
+            double totalE = 0;
+            if (clusters.size() == 2) {
+                for (Cluster cluster : clusters) {
+//                    double[] pos = cluster.getPosition();
+//                    double[] direction = new double[3];
+//                    direction[0] = pos[0];
+//                    direction[1] = pos[1];
+//                    direction[2] = pos[2] + targetZ;
+//                    double length = Math.sqrt(direction[0] * direction[0] + direction[1] * direction[1] + direction[2] * direction[2]);
+//                    direction[0] *= cluster.getEnergy() / length;
+//                    direction[1] *= cluster.getEnergy() / length;
+//                    direction[2] *= cluster.getEnergy() / length;
+//                    totalE += cluster.getEnergy();
+//                    totalP[0] += direction[0];
+//                    totalP[1] += direction[1];
+//                    totalP[2] += direction[2];
+                }
+//                double invariantMass = (new BasicHepLorentzVector(totalE, totalP)).magnitude();
+//                invMassPlot.fill(invariantMass);
+            }
+            for (int i = 0; i < clusters.size() - 1; i++) {
+                double e1 = clusters.get(i).getEnergy();
+                for (int j = i + 1; j < clusters.size(); j++) {
+                    double e2 = clusters.get(j).getEnergy();
+                    clusterPairEnergyPlot.fill(Math.max(e1, e2), Math.min(e1, e2));
+                    double e1e2 = clusters.get(i).getEnergy() * clusters.get(j).getEnergy();
+                    double dx2 = Math.pow(clusters.get(i).getPosition()[0] - clusters.get(j).getPosition()[0], 2) + Math.pow(clusters.get(i).getPosition()[1] - clusters.get(j).getPosition()[1], 2);
+                    invMassPlot.fill(Math.sqrt(e1e2 * dx2 / (135 * 135)));
+                }
+            }
+
             ++eventn;
         }
     }

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalHitPlots.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EcalHitPlots.java	10 May 2012 15:55:55 -0000	1.1
+++ EcalHitPlots.java	12 May 2012 23:09:05 -0000	1.2
@@ -21,7 +21,7 @@
     IPlotter plotter;
     IPlotter plotter2;
     IHistogram1D hitCountPlot;
-    IHistogram1D clusterSizePlot;
+    IHistogram1D hitTimePlot;
     IHistogram1D hitEnergyPlot;
     IHistogram1D hitMaxEnergyPlot;
     int eventn = 0;
@@ -42,11 +42,13 @@
 
         // Setup plots.
         aida.tree().cd("/");
-        hitCountPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 10, -0.5, 9.5);
+        hitCountPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count In Event", 10, -0.5, 9.5);
+        hitTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time", 1000, 0*64,100*64);
 
         // Create the plotter regions.
-        plotter.createRegion();
+        plotter.createRegions(1,2);
         plotter.region(0).plot(hitCountPlot);
+        plotter.region(1).plot(hitTimePlot);
 
 
         // Setup the plotter.
@@ -75,6 +77,7 @@
             double maxEnergy = 0;
             for (CalorimeterHit hit : hits) {
                 hitEnergyPlot.fill(hit.getRawEnergy());
+                hitTimePlot.fill(hit.getTime());
                 if (hit.getRawEnergy() > maxEnergy) {
                     maxEnergy = hit.getRawEnergy();
                 }

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcalConditions.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- HPSEcalConditions.java	10 May 2012 15:55:56 -0000	1.6
+++ HPSEcalConditions.java	12 May 2012 23:09:05 -0000	1.7
@@ -17,7 +17,7 @@
 /**
  *
  * @author meeg
- * @version $Id: HPSEcalConditions.java,v 1.6 2012/05/10 15:55:56 meeg Exp $
+ * @version $Id: HPSEcalConditions.java,v 1.7 2012/05/12 23:09:05 meeg Exp $
  */
 public class HPSEcalConditions extends Driver {
 
@@ -32,18 +32,27 @@
     //set of bad channels to ignore
     private static HashSet<Long> badChannelsSet = new HashSet<Long>();
     private static boolean badChannelsLoaded = false;
-    private String subdetectorName = "Ecal";
     private static IIdentifierHelper helper = null;
+    //subdetector name (for when this is used as a driver)
+    private String subdetectorName = "Ecal";
 
     public HPSEcalConditions() {
     }
 
     @Override
     public void detectorChanged(Detector detector) {
-        if (detector.getSubdetector(subdetectorName) == null) {
+        Subdetector subdetector = detector.getSubdetector(subdetectorName);
+        if (subdetector == null) {
             throw new RuntimeException("Subdetector " + subdetectorName + " not found");
         }
-        helper = detector.getSubdetector(subdetectorName).getDetectorElement().getIdentifierHelper();
+        subdetectorChanged(subdetector);
+    }
+
+    public static void subdetectorChanged(Subdetector subdetector) {
+        helper = subdetector.getDetectorElement().getIdentifierHelper();
+//        loadBadChannels(subdetector);
+        fillDaqCellMap(subdetector);
+
     }
 
     public void setSubdetectorName(String subdetectorName) {
@@ -113,11 +122,10 @@
         }
     }
 
-    public static void loadBadChannels(Subdetector ecal) {
+    private static void loadBadChannels(Subdetector ecal) {
 
         System.out.println("reading ECal bad channels");
 
-        IIdentifierHelper helper = ecal.getDetectorElement().getIdentifierHelper();
         IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
         expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
         ConditionsManager conditions = ConditionsManager.defaultInstance();
@@ -163,7 +171,7 @@
         return badChannelsSet.contains(id);
     }
 
-    public static void fillDaqCellMap(Subdetector ecal) {
+    private static void fillDaqCellMap(Subdetector ecal) {
 
         System.out.println("reading DAQ map");
 

hps-java/src/main/java/org/lcsim/hps/recon/ecal
HPSEcalRawConverter.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- HPSEcalRawConverter.java	10 May 2012 15:55:56 -0000	1.5
+++ HPSEcalRawConverter.java	12 May 2012 23:09:05 -0000	1.6
@@ -56,7 +56,7 @@
     }
 
     public CalorimeterHit HitDtoA(RawTrackerHit hit) {
-        double time = 0.0;
+        double time = hit.getTime();
         long id = hit.getCellID();
         double rawEnergy = gain*sumADC(hit);
         double[] pos = hit.getDetectorElement().getGeometry().getPosition().v();
@@ -70,7 +70,7 @@
     }
 
     public CalorimeterHit HitDtoA(BaseRawCalorimeterHit hit, int window) {
-        double time = 0.0;
+        double time = hit.getTimeStamp();
         long id = hit.getCellID();
         double rawEnergy = gain*(hit.getAmplitude() - window * getPedestal(hit));
 //                Hep3Vector pvec = hit.getDetectorElement().getGeometry().getPosition();

hps-java/src/main/java/org/lcsim/hps/recon/tracking
HPSSVTCalibrationConstants.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- HPSSVTCalibrationConstants.java	3 May 2012 20:50:29 -0000	1.7
+++ HPSSVTCalibrationConstants.java	12 May 2012 23:09:05 -0000	1.8
@@ -7,11 +7,11 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
+import java.util.*;
 import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
 import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.hps.monitoring.HPSCalibrationListener;
 import org.lcsim.hps.util.Pair;
 
 /**
@@ -20,28 +20,27 @@
  */
 public class HPSSVTCalibrationConstants {
 
-    // Map from Sensor to Hybrid/FPGA pair
-    private static Map<Pair<SiSensor /*
-             * Sensor
-             */, Integer> /*
-             * Channel Number
-             */, Double /*
-             * constant
-             */> noiseMap = new HashMap<Pair<SiSensor, Integer>, Double>();
-    private static Map<Pair<SiSensor /*
-             * Sensor
-             */, Integer> /*
-             * Channel Number
-             */, Double /*
-             * constant
-             */> pedestalMap = new HashMap<Pair<SiSensor, Integer>, Double>();
-    private static Map<Pair<SiSensor /*
-             * Sensor
-             */, Integer> /*
-             * Channel Number
-             */, Double /*
-             * constant
-             */> tpMap = new HashMap<Pair<SiSensor, Integer>, Double>();
+    public static Map<Pair<Integer /*
+             * Hybrid
+             */, Integer /*
+             * FPGA
+             */>, double[] /*
+             * constants
+             */> noiseMap = new HashMap<Pair<Integer, Integer>, double[]>();
+    public static Map<Pair<Integer /*
+             * Hybrid
+             */, Integer /*
+             * FPGA
+             */>, double[] /*
+             * constants
+             */> pedestalMap = new HashMap<Pair<Integer, Integer>, double[]>();
+    public static Map<Pair<Integer /*
+             * Hybrid
+             */, Integer /*
+             * FPGA
+             */>, double[] /*
+             * constants
+             */> tpMap = new HashMap<Pair<Integer, Integer>, double[]>();
     private static boolean calibrationLoaded = false;
 
     /**
@@ -51,14 +50,31 @@
     }
 
     public static void loadCalibrationConstants() {
-        //write something here to read in constants from calibration fiel
+        loadCalibrationConstants(null);
+    }
+
+    public static void loadCalibrationConstants(Date date) {
+        //write something here to read in constants from calibration file
         ConditionsManager conditions = ConditionsManager.defaultInstance();
+
+        String filePath = null;
+
+        if (date != null) {
+            ConditionsSet calibSet = conditions.getConditions("calibSVT/base");
+            filePath = HPSCalibrationListener.getCalibForDate(calibSet, date);
+        }
+
+        if (filePath == null) {
+            filePath = "calibSVT/default.base";
+        }
+
         try {
-            Reader baselineReader = conditions.getRawConditions("calibSVT/default.base").getReader();
+            Reader baselineReader = conditions.getRawConditions(filePath).getReader();
             loadBaseline(baselineReader);
         } catch (IOException e) {
             throw new RuntimeException("couldn't get baseline file", e);
         }
+
     }
 
     public static void loadBaseline(Reader baselineReader) {
@@ -89,13 +105,22 @@
                     int channel = Integer.valueOf(lineTok.nextToken());
                     double pedestal = Double.valueOf(lineTok.nextToken());
                     double noise = Double.valueOf(lineTok.nextToken());
-                    SiSensor sensor = HPSSVTDAQMaps.daqPairToSensor.get(new Pair(hybrid, fpga));
-                    if (sensor == null) {
-                        throw new RuntimeException("invalid DAQ ID: FPGA " + fpga + ", hybrid " + hybrid);
+
+                    Pair<Integer, Integer> daqPair = new Pair(hybrid, fpga);
+
+                    double[] pedestals = pedestalMap.get(daqPair);
+                    if (pedestals == null) {
+                        pedestals = new double[HPSSVTConstants.TOTAL_APV25_CHANNELS * HPSSVTConstants.TOTAL_APV25_PER_HYBRID];
+                        pedestalMap.put(daqPair, pedestals);
+                    }
+                    pedestals[channel] = pedestal;
+
+                    double[] noises = noiseMap.get(daqPair);
+                    if (noises == null) {
+                        noises = new double[HPSSVTConstants.TOTAL_APV25_CHANNELS * HPSSVTConstants.TOTAL_APV25_PER_HYBRID];
+                        noiseMap.put(daqPair, noises);
                     }
-                    Pair<SiSensor, Integer> sensorChannel = new Pair(sensor, channel);
-                    pedestalMap.put(sensorChannel, pedestal);
-                    noiseMap.put(sensorChannel, noise);
+                    noises[channel] = noise;
                 }
             }
         }
@@ -106,41 +131,55 @@
         return calibrationLoaded;
     }
 
-    public static double getNoise(SiSensor sensor, int channel) {
-        Pair<SiSensor, Integer> sensorChannel = new Pair(sensor, channel);
-        return noiseMap.get(sensorChannel);
+    public static Double getNoise(SiSensor sensor, int channel) {
+        Pair<Integer, Integer> daqPair = HPSSVTDAQMaps.sensorToDAQPair.get(sensor);
+        double[] noises = noiseMap.get(daqPair);
+        if (noises == null) {
+            return null;
+        } else {
+            return noises[channel];
+        }
     }
 
-    public static double getPedestal(SiSensor sensor, int channel) {
-        Pair<SiSensor, Integer> sensorChannel = new Pair(sensor, channel);
-        return pedestalMap.get(sensorChannel);
+    public static Double getPedestal(SiSensor sensor, int channel) {
+        Pair<Integer, Integer> daqPair = HPSSVTDAQMaps.sensorToDAQPair.get(sensor);
+        double[] pedestals = pedestalMap.get(daqPair);
+        if (pedestals == null) {
+            return null;
+        } else {
+            return pedestals[channel];
+        }
     }
 
-    public static double getTShaping(SiSensor sensor, int channel) {
-        Pair<SiSensor, Integer> sensorChannel = new Pair(sensor, channel);
-        return tpMap.get(sensorChannel);
+    public static Double getTShaping(SiSensor sensor, int channel) {
+        Pair<Integer, Integer> daqPair = HPSSVTDAQMaps.sensorToDAQPair.get(sensor);
+        double[] tps = tpMap.get(daqPair);
+        if (tps == null) {
+            return null;
+        } else {
+            return tps[channel];
+        }
     }
 
     public static ChannelConstants getChannelConstants(SiSensor sensor, int channel) {
-        Pair<SiSensor, Integer> sensorChannel = new Pair(sensor, channel);
         ChannelConstants constants = new ChannelConstants();
 
         Double value;
-        value = noiseMap.get(sensorChannel);
+        value = getNoise(sensor, channel);
         if (value != null) {
             constants.setNoise(value);
         } else {
             System.out.println("Couldn't get noise for sensor " + sensor.getName() + ", channel " + channel);
             constants.setNoise(20.0);
         }
-        value = pedestalMap.get(sensorChannel);
+        value = getPedestal(sensor, channel);
         if (value != null) {
             constants.setPedestal(value);
         } else {
             System.out.println("Couldn't get pedestal for sensor " + sensor.getName() + ", channel " + channel);
             constants.setPedestal(1638.0);
         }
-        value = tpMap.get(sensorChannel);
+        value = getTShaping(sensor, channel);
         if (value != null) {
             constants.setTp(value);
         } else {

hps-java/src/main/resources/org/lcsim/hps/steering
TestRunEventDisplay.lcsim 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TestRunEventDisplay.lcsim	10 May 2012 23:26:54 -0000	1.2
+++ TestRunEventDisplay.lcsim	12 May 2012 23:09:05 -0000	1.3
@@ -8,11 +8,10 @@
     </control>    
     <execute>
 <!--        <driver name="RunControlDriver"/>-->
+        <driver name="HPSCalibrationDriver"/>
         <driver name="EventMarkerDriver"/>
-        <driver name="SVTSetupDriver"/>
         <driver name="EcalRawConverter"/>
         <driver name="EcalClusterer"/>
-        <driver name="HPSSVTDAQMaps"/>
         <driver name="RawTrackerHitMaker"/>
 <!--        <driver name="RawTrackerHitFitterDriver"/>  -->
 <!--        <driver name="TrackerHitDriver"/>-->
@@ -22,7 +21,8 @@
 
     </execute>    
     <drivers>
-<!--        <driver name="RunControlDriver" type="org.lcsim.hps.monitoring.RunControlDriver"/>-->
+        <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"/>   
+        <driver name="RunControlDriver" type="org.lcsim.hps.monitoring.RunControlDriver"/>
         <driver name="SVTEventDisplay" type="org.lcsim.hps.monitoring.svt.SVTSimpleEventDisplay">
             <inputCollection>SVTRawTrackerHits</inputCollection>
         </driver>
@@ -49,11 +49,9 @@
         <driver name="EcalEventMonitor" type="org.lcsim.hps.monitoring.ecal.EcalEventMonitor">
             <eventRefreshRate>1</eventRefreshRate>
         </driver>
-        <driver name="SVTSetupDriver" type="org.lcsim.hps.recon.tracking.HPSSVTSensorSetup"/>
         <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
             <eventInterval>1</eventInterval>
         </driver>
-        <driver name="HPSSVTDAQMaps" type="org.lcsim.hps.recon.tracking.HPSSVTDAQMaps"/>   
         <driver name="RawTrackerHitMaker" type="org.lcsim.hps.recon.tracking.SVTDataToRawTrackerHitDriver"/>
     </drivers>
 </lcsim>

hps-java/src/main/resources/org/lcsim/hps/steering
ECalMonitoring.lcsim 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ECalMonitoring.lcsim	10 May 2012 15:55:55 -0000	1.6
+++ ECalMonitoring.lcsim	12 May 2012 23:09:05 -0000	1.7
@@ -8,20 +8,20 @@
     </control>    
     <execute>
         <driver name="EventMarkerDriver"/>
-        <driver name="HPSEcalConditions"/>
+        <driver name="HPSCalibrationDriver"/>
         <driver name="EcalRawConverter"/>
         <driver name="EcalClusterer"/>
         <driver name="EcalPedestalPlots"/>
         <driver name="EcalMonitoringPlots"/>
-<!--
         <driver name="EcalEvsX"/>
+<!--
         <driver name="EcalEventMonitor"/>
         <driver name="EcalWindowPlots"/>
         <driver name="EcalDaqPlots"/>
 -->
     </execute>    
     <drivers>
-        <driver name="HPSEcalConditions" type="org.lcsim.hps.recon.ecal.HPSEcalConditions"/>
+        <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"/>   
         <driver name="EcalRawConverter" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver">
             <integralWindow>35</integralWindow>
         </driver>

hps-java/src/main/resources/org/lcsim/hps/steering
TestRunMonitoring.lcsim 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- TestRunMonitoring.lcsim	10 May 2012 15:55:55 -0000	1.16
+++ TestRunMonitoring.lcsim	12 May 2012 23:09:05 -0000	1.17
@@ -8,10 +8,9 @@
     </control>    
     <execute>
         <driver name="EventMarkerDriver"/>
-        <driver name="SVTSetupDriver"/>
+        <driver name="HPSCalibrationDriver"/>
         <driver name="EcalRawConverter"/>
         <driver name="EcalClusterer"/>
-        <driver name="HPSSVTDAQMaps"/>
         <driver name="RawTrackerHitMaker"/>
         <driver name="RawTrackerHitFitterDriver"/>  
         <driver name="TrackerHitDriver"/>
@@ -25,6 +24,7 @@
 
     </execute>    
     <drivers>
+        <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"/>   
         <driver name="EcalRawConverter" 
                 type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver">
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
@@ -55,7 +55,6 @@
             <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>
             <eventRefreshRate>100</eventRefreshRate>
         </driver>
-        <driver name="SVTSetupDriver" type="org.lcsim.hps.recon.tracking.HPSSVTSensorSetup"/>
         <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
             <eventInterval>1</eventInterval>
         </driver>
@@ -68,7 +67,6 @@
             <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>   
             <fittedTrackerHitCollectionName>SVTFittedRawTrackerHits</fittedTrackerHitCollectionName>   
         </driver>
-        <driver name="HPSSVTDAQMaps" type="org.lcsim.hps.recon.tracking.HPSSVTDAQMaps"/>   
         <driver name="RawTrackerHitMaker" type="org.lcsim.hps.recon.tracking.SVTDataToRawTrackerHitDriver"/>
     </drivers>
 </lcsim>

hps-java/scripts
et_evio_file_producer_test.sh 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- et_evio_file_producer_test.sh	10 May 2012 20:52:25 -0000	1.14
+++ et_evio_file_producer_test.sh	12 May 2012 23:09:06 -0000	1.15
@@ -5,11 +5,12 @@
 
 # Single argument is name of EVIO file.
 eviofile=$1
+shift
 
 # Classpath pointing to the hps-java jar.
 classpath=`pwd`/target/hps-java-*-bin.jar
 
 # Run it.
-prod="java -classpath $classpath org.lcsim.hps.evio.EvioFileProducer -e ${eviofile} -f ETBuffer -host $(hostname) -s 10000"
+prod="java -classpath $classpath org.lcsim.hps.evio.EvioFileProducer -e ${eviofile} -f ETBuffer -host $(hostname) -s 10000 $@"
 echo $prod
 exec $prod

hps-java/src/main/java/org/lcsim/hps/monitoring/svt
SVTHitPulsePlots.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- SVTHitPulsePlots.java	10 May 2012 15:55:56 -0000	1.11
+++ SVTHitPulsePlots.java	12 May 2012 23:09:06 -0000	1.12
@@ -73,6 +73,7 @@
         plotter2.setTitle("HPS SVT Hit vs Channel");
         plotter2.style().setParameter("hist2DStyle", "colorMap");
         plotter2.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter2.style().zAxisStyle().setParameter("scale", "log");
         plotterFrame.addPlotter(plotter2);
         plotters.add(plotter2);
         IPlotterStyle style2 = plotter2.style();
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1