Commit in java/trunk/analysis/src/main/java/org/hps/analysis/ecal on MAIN
BasicMonitoringPlotsDriver.java+105added 773
ECalCellIDPrintDriver.java+81added 773
EcalClusterPlots.java+200added 773
EcalDaqPlots.java+117added 773
EcalEventMonitor.java+127added 773
EcalEvsX.java+186added 773
EcalHitPlots.java+268added 773
EcalMonitoringPlots.java+135added 773
+1219
8 added files
Somehow these got missed in first commit.

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
BasicMonitoringPlotsDriver.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/BasicMonitoringPlotsDriver.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/BasicMonitoringPlotsDriver.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,105 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IAnalysisFactory;
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IHistogramFactory;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.util.Driver;
+
+/**
+ * Basic ECal monitoring plots that work on Test Run data.
+ * @author jeremym
+ */
+public class BasicMonitoringPlotsDriver extends Driver {
+	
+	private String calHitsCollectionName = "EcalCalHits"; 
+	private String rawHitsCollectionName = "EcalReadoutHits";
+	private String clustersCollectionName = "EcalClusters";
+	
+	private IHistogram1D calHitEnergyH1D;
+	private IHistogram1D clusterEnergyH1D;
+	private IHistogram1D rawHitAmplitudeH1D;
+	private IHistogram2D calHitEnergyMapH2D;
+	
+	public BasicMonitoringPlotsDriver() {		
+	}
+	
+	public void startOfData() {		
+		
+		IAnalysisFactory.create().createHistogramFactory(null);
+		IPlotterFactory plotFactory = IAnalysisFactory.create().createPlotterFactory("ECAL Monitoring");
+		IHistogramFactory histogramFactory = IAnalysisFactory.create().createHistogramFactory(null);
+		
+		calHitEnergyH1D = histogramFactory.createHistogram1D(calHitsCollectionName + ": Energy", calHitsCollectionName + ": Energy", 200, 0.0, 2.0);
+		calHitEnergyH1D.annotation().addItem("xAxisLabel", "GeV");
+		calHitEnergyH1D.annotation().addItem("yAxisLabel", "Count");
+		IPlotter plotter = plotFactory.create("CalorimeterHits");
+		plotter.createRegion();
+		plotter.style().gridStyle().setVisible(false);
+		plotter.style().dataStyle().errorBarStyle().setVisible(false);
+		plotter.region(0).plot(calHitEnergyH1D);
+		plotter.show();
+		
+		rawHitAmplitudeH1D = histogramFactory.createHistogram1D(rawHitsCollectionName + ": Amplitude", rawHitsCollectionName + ": Amplitude", 150, 0.0, 15000.0);
+		rawHitAmplitudeH1D.annotation().addItem("xAxisLabel", "ADC Value");
+		rawHitAmplitudeH1D.annotation().addItem("yAxisLabel", "Count");
+		plotter = plotFactory.create("RawCalorimeterHits");
+		plotter.createRegion();
+		plotter.style().gridStyle().setVisible(false);
+		plotter.style().dataStyle().errorBarStyle().setVisible(false);
+		plotter.region(0).plot(rawHitAmplitudeH1D);
+		plotter.show();
+		
+		clusterEnergyH1D = histogramFactory.createHistogram1D(clustersCollectionName + ": Energy", clustersCollectionName + ": Energy", 100, 0.0, 3.0);
+		clusterEnergyH1D.annotation().addItem("xAxisLabel", "GeV");
+		clusterEnergyH1D.annotation().addItem("yAxisLabel", "Count");
+		plotter = plotFactory.create("Clusters");
+		plotter.createRegion();
+		plotter.style().gridStyle().setVisible(false);
+		plotter.style().dataStyle().errorBarStyle().setVisible(false);
+		plotter.region(0).plot(clusterEnergyH1D);
+		plotter.show();
+		
+		calHitEnergyMapH2D = histogramFactory.createHistogram2D(calHitsCollectionName + ": Energy Map", calHitsCollectionName + ": Energy Map", 47, -23.5, 23.5, 11, -5.5, 5.5);
+		plotter = plotFactory.create("CalorimeterHit Energy Map");
+		plotter.createRegion();
+		plotter.style().setParameter("hist2DStyle", "colorMap");
+		plotter.style().gridStyle().setVisible(false);
+		plotter.region(0).plot(calHitEnergyMapH2D);
+		plotter.show();
+	}
+	
+	public void process(EventHeader event) {
+		
+		List<CalorimeterHit> calHits = event.get(CalorimeterHit.class, calHitsCollectionName);
+		for (CalorimeterHit hit : calHits) {
+			calHitEnergyH1D.fill(hit.getCorrectedEnergy());
+			calHitEnergyMapH2D.fill(
+					hit.getIdentifierFieldValue("ix"), 
+					hit.getIdentifierFieldValue("iy"), 
+					hit.getCorrectedEnergy());
+		}
+		
+		List<Cluster> clusters = event.get(Cluster.class, clustersCollectionName);
+		for (Cluster cluster : clusters) {
+			clusterEnergyH1D.fill(cluster.getEnergy());
+		}
+		
+		List<RawCalorimeterHit> rawHits = null; 
+		if (event.hasCollection(RawCalorimeterHit.class, rawHitsCollectionName)) {
+			rawHits = event.get(RawCalorimeterHit.class, rawHitsCollectionName); 
+			for (RawCalorimeterHit hit : rawHits) {
+				rawHitAmplitudeH1D.fill(hit.getAmplitude());
+			}
+		}
+	}
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
ECalCellIDPrintDriver.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/ECalCellIDPrintDriver.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/ECalCellIDPrintDriver.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,81 @@
+package org.hps.monitoring.drivers.ecal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.util.Driver;
+
+/**
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: ECalCellIDPrintDriver.java,v 1.1 2012/05/01 15:06:38 meeg Exp $
+ */
+public class ECalCellIDPrintDriver extends Driver {
+
+	Subdetector ecal;
+	IDDecoder dec;
+	String ecalName = "Ecal";
+	String ecalCollectionName = "EcalReadoutHits";
+	String outputFileName;
+	PrintWriter outputStream = null;
+
+	public ECalCellIDPrintDriver() {
+	}
+
+	public void setEcalCollectionName(String ecalCollectionName) {
+		this.ecalCollectionName = ecalCollectionName;
+	}
+
+	public void setEcalName(String ecalName) {
+		this.ecalName = ecalName;
+	}
+
+	public void setOutputFileName(String outputFileName) {
+		this.outputFileName = outputFileName;
+	}
+
+	public void startOfData() {
+		if (outputFileName != null) {
+			try {
+				outputStream = new PrintWriter(outputFileName);
+			} catch (IOException ex) {
+				throw new RuntimeException("Invalid outputFilePath!");
+			}
+		} else {
+			outputStream = new PrintWriter(System.out, true);
+		}
+	}
+
+	public void detectorChanged(Detector detector) {
+		// Get the Subdetector.
+		ecal = (Subdetector) detector.getSubdetector(ecalName);
+		dec = ecal.getIDDecoder();
+	}
+
+	public void process(EventHeader event) {
+		// Get the list of ECal hits.
+		if (event.hasCollection(RawCalorimeterHit.class, ecalCollectionName)) {
+			List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, ecalCollectionName);
+			//outputStream.println("Reading RawCalorimeterHit from event " + event.getEventNumber());
+			for (RawCalorimeterHit hit : hits) {
+				dec.setID(hit.getCellID());
+				outputStream.printf("x=%d\ty=%d\n", dec.getValue("ix"), dec.getValue("iy"));
+			}
+		}
+		if (event.hasCollection(RawTrackerHit.class, ecalCollectionName)) {
+			List<RawTrackerHit> hits = event.get(RawTrackerHit.class, ecalCollectionName);
+			//outputStream.println("Reading RawCalorimeterHit from event " + event.getEventNumber());
+			for (RawTrackerHit hit : hits) {
+				dec.setID(hit.getCellID());
+				outputStream.printf("x=%d\ty=%d\n", dec.getValue("ix"), dec.getValue("iy"));
+			}
+		}
+	}
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalClusterPlots.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,200 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+
+import java.util.List;
+
+import org.apache.commons.math.stat.StatUtils;
+import org.hps.readout.ecal.TriggerData;
+import org.hps.recon.ecal.ECalUtils;
+import org.hps.util.Resettable;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalClusterPlots extends Driver implements Resettable {
+
+	//AIDAFrame plotterFrame;
+    String inputCollection = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter, plotter2, plotter3, plotter4;
+    IHistogram1D clusterCountPlot;
+    IHistogram1D clusterSizePlot;
+    IHistogram1D clusterEnergyPlot;
+    IHistogram1D clusterMaxEnergyPlot;
+    IHistogram1D clusterTimes;
+    IHistogram1D clusterTimeSigma;
+    IHistogram2D edgePlot;
+    int eventn = 0;
+    double maxE = 5000 * ECalUtils.MeV;
+    boolean logScale = false;
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setMaxE(double maxE) {
+        this.maxE = maxE;
+    }
+
+    public void setLogScale(boolean logScale) {
+        this.logScale = logScale;
+    }
+
+    @Override
+    protected void detectorChanged(Detector detector) {
+
+    	//plotterFrame = new AIDAFrame();
+        //plotterFrame.setTitle("HPS ECal Cluster Plots");
+
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory().create("Cluster Counts");
+        plotter.setTitle("Cluster Counts");
+        //plotterFrame.addPlotter(plotter);
+        plotter.style().dataStyle().errorBarStyle().setVisible(false);
+
+        // Setup plots.
+        aida.tree().cd("/");
+        clusterCountPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Count per Event", 10, -0.5, 9.5);
+        clusterSizePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Size", 10, -0.5, 9.5);
+
+        // Create the plotter regions.
+        plotter.createRegions(1, 2);
+        plotter.region(0).plot(clusterCountPlot);
+        plotter.region(1).plot(clusterSizePlot);
+
+
+        // Setup the plotter.
+        plotter2 = aida.analysisFactory().createPlotterFactory().create("Cluster Energies");
+        plotter2.setTitle("Cluster Energies");
+        //plotterFrame.addPlotter(plotter2);
+        plotter2.style().dataStyle().errorBarStyle().setVisible(false);
+
+        if (logScale) {
+            plotter2.style().yAxisStyle().setParameter("scale", "log");
+        }
+
+        clusterEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Energy", 1000, -0.1, maxE);
+        clusterMaxEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Maximum Cluster Energy In Event", 1000, -0.1, maxE);
+
+
+        // Create the plotter regions.
+        plotter2.createRegions(1, 2);
+        plotter2.region(0).plot(clusterEnergyPlot);
+        plotter2.region(1).plot(clusterMaxEnergyPlot);
+
+        plotter3 = aida.analysisFactory().createPlotterFactory().create("Cluster Times");
+        plotter3.setTitle("Cluster Times");
+        //plotterFrame.addPlotter(plotter3);
+        plotter3.style().dataStyle().errorBarStyle().setVisible(false);
+        plotter3.createRegions(1, 2);
+        plotter3.style().yAxisStyle().setParameter("scale", "log");
+
+        clusterTimes = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Times", 100, 0, 4.0 * 100);
+        clusterTimeSigma = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Time Sigma", 100, 0, 50);
+        plotter3.region(0).plot(clusterTimes);
+        plotter3.region(1).plot(clusterTimeSigma);
+
+        plotter4 = aida.analysisFactory().createPlotterFactory().create("Edges");
+        plotter4.setTitle("Edges");
+        //plotterFrame.addPlotter(plotter4);
+        plotter4.style().setParameter("hist2DStyle", "colorMap");
+        plotter4.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter4.style().zAxisStyle().setParameter("scale", "log");
+        plotter4.createRegion();
+
+        edgePlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Pairs Across Crystal Edges", 93, -23.25, 23.25, 21, -5.25, 5.25);
+        plotter4.region(0).plot(edgePlot);
+
+        //plotterFrame.setVisible(true);
+        //plotterFrame.pack();
+    }
+
+    @Override
+    public void process(EventHeader event) {
+        int orTrig = 0;
+        int topTrig = 0;
+        int botTrig = 0;
+        if (event.hasCollection(TriggerData.class, "TriggerBank")) {
+            List<TriggerData> triggerList = event.get(TriggerData.class, "TriggerBank");
+            if (!triggerList.isEmpty()) {
+                TriggerData triggerData = triggerList.get(0);
+
+                orTrig = triggerData.getOrTrig();
+                topTrig = triggerData.getTopTrig();
+                botTrig = triggerData.getBotTrig();
+            }
+        }
+        if (event.hasCollection(Cluster.class, inputCollection)) {
+            List<Cluster> clusters = event.get(Cluster.class, inputCollection);
+            clusterCountPlot.fill(clusters.size());
+            double maxEnergy = 0;
+            for (Cluster cluster : clusters) {
+//                if ((botTrig == 0 && cluster.getEnergy() > 130 && cluster.getPosition()[1] < 0) || (topTrig == 0 && cluster.getEnergy() > 130 && cluster.getPosition()[1] > 0)) {
+//                if ((botTrig == 0 && cluster.getPosition()[1] < 0) || (topTrig == 0 && cluster.getPosition()[1] > 0)) {
+                    clusterEnergyPlot.fill(cluster.getEnergy());
+                if (cluster.getEnergy() > maxEnergy) {
+                    maxEnergy = cluster.getEnergy();
+                }
+                int size = 0;
+                double[] times = new double[cluster.getCalorimeterHits().size()];
+//                    System.out.format("cluster:\n");
+                for (CalorimeterHit hit : cluster.getCalorimeterHits()) {
+                    if (hit.getRawEnergy() != 0) {
+                        times[size] = hit.getTime();
+                        clusterTimes.fill(hit.getTime());
+                        size++;
+//                            System.out.format("x=%d, y=%d, time=%f, energy=%f\n", hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"), hit.getTime(), hit.getRawEnergy());
+                    }
+                }
+                clusterSizePlot.fill(size);
+                clusterTimeSigma.fill(Math.sqrt(StatUtils.variance(times, 0, size)));
+
+                List<CalorimeterHit> hits = cluster.getCalorimeterHits();
+                for (int i = 0; i < hits.size(); i++) {
+                    CalorimeterHit hit1 = hits.get(i);
+                    if (hit1.getRawEnergy() == 0) {
+                        continue;
+                    }
+                    int x1 = hit1.getIdentifierFieldValue("ix");
+                    int y1 = hit1.getIdentifierFieldValue("iy");
+                    for (int j = i + 1; j < hits.size(); j++) {
+                        CalorimeterHit hit2 = hits.get(j);
+                        if (hit2.getRawEnergy() == 0) {
+                            continue;
+                        }
+                        int x2 = hit2.getIdentifierFieldValue("ix");
+                        int y2 = hit2.getIdentifierFieldValue("iy");
+                        if ((Math.abs(x1 - x2) <= 1 || x1 * x2 == -1) && (Math.abs(y1 - y2) <= 1)) {
+                            if (x1 != x2 || y1 != y2) {
+                                edgePlot.fill((x1 + x2) / 2.0, (y1 + y2) / 2.0);
+                            }
+                        }
+                    }
+                }
+//                }
+            }
+            clusterMaxEnergyPlot.fill(maxEnergy);
+        } else {
+            clusterCountPlot.fill(0);
+        }
+    }
+
+    @Override
+    public void reset() {
+        clusterCountPlot.reset();
+        clusterSizePlot.reset();
+        clusterEnergyPlot.reset();
+        clusterMaxEnergyPlot.reset();
+    }
+
+    @Override
+    public void endOfData() {
+    	//plotterFrame.dispose();
+    }
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalDaqPlots.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalDaqPlots.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalDaqPlots.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,117 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+import hep.aida.ref.plotter.PlotterRegion;
+import jas.hist.JASHist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.util.Resettable;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalDaqPlots extends Driver implements Resettable {
+
+	private String subdetectorName = "Ecal";
+	private String inputCollection = "EcalReadoutHits";
+	private IPlotter plotter;
+	private AIDA aida;
+	private Detector detector;
+	private List<IHistogram1D> plots;
+        private static final short[] slots = {10, 13, 9, 14, 8, 15, 7, 16, 6, 17, 5, 18, 4, 19};
+
+	public EcalDaqPlots() {
+	}
+
+	public void setSubdetectorName(String subdetectorName) {
+		this.subdetectorName = subdetectorName;
+	}
+
+	public void setInputCollection(String inputCollection) {
+		this.inputCollection = inputCollection;
+	}
+
+	public void detectorChanged(Detector detector) {
+
+		this.detector = detector;
+
+		if (subdetectorName == null) {
+			throw new RuntimeException("The subdetectorName parameter was not set.");
+		}
+
+		if (inputCollection == null) {
+			throw new RuntimeException("The inputCollection parameter was not set.");
+		}
+
+		Subdetector subdetector = detector.getSubdetector(subdetectorName);
+
+		setupPlots();
+	}
+
+	private void setupPlots() {
+		plots = new ArrayList<IHistogram1D>();
+		aida = AIDA.defaultInstance();
+		aida.tree().cd("/");
+		plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECAL DAQ Plots");
+		IPlotterStyle pstyle = plotter.style();
+		pstyle.dataStyle().fillStyle().setColor("orange");
+		pstyle.dataStyle().markerStyle().setColor("orange");
+		pstyle.dataStyle().errorBarStyle().setVisible(false);
+		plotter.createRegions(7, 4);
+		int region = 0;
+		for (int i = 0; i < 14; i++) { // slot
+			for (int j = 1; j < 3; j++) { // crate                
+				//System.out.println("creating plot: " + "ECAL: Crate " + j + "; Slot " + i + " in region " + region);
+				IHistogram1D hist = aida.histogram1D("ECAL: Crate " + j + "; Slot " + slots[i], 16, 0, 16);
+				plots.add(hist);
+				plotter.region(region).plot(hist);
+				JASHist jhist = ((PlotterRegion) plotter.region(region)).getPlot();
+				jhist.setAllowUserInteraction(false);
+				jhist.setAllowPopupMenus(false);
+				region++;
+			}
+		}
+		plotter.show();
+	}
+
+//	public void endOfData() {
+//		if (plotter != null) {
+//			plotter.hide();
+//		}
+//	}
+
+	public void reset() {
+		if (plotter != null) {
+			plotter.hide();
+			plotter.destroyRegions();
+			for (IHistogram1D plot : plots) {
+				plot.reset();
+			}
+			detectorChanged(detector);
+		}
+	}
+
+	public void process(EventHeader event) {
+		if (event.hasCollection(RawCalorimeterHit.class, inputCollection)) {
+			List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollection);
+			for (RawCalorimeterHit hit : hits) {
+				Long daqId = EcalConditions.physicalToDaqID(hit.getCellID());
+				int crate = EcalConditions.getCrate(daqId);
+				int slot = EcalConditions.getSlot(daqId);
+				int channel = EcalConditions.getChannel(daqId);
+				//System.out.println("crate="+crate+"; slot="+slot+"; channel="+channel);
+				//System.out.println("filling plot: " + "ECAL: Crate " + crate + "; Slot " + slot);
+				aida.histogram1D("ECAL: Crate " + crate + "; Slot " + slot).fill(channel);
+			}
+		}
+	}
+}

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalEventMonitor.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalEventMonitor.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalEventMonitor.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,127 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+import hep.aida.ref.plotter.PlotterRegion;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.List;
+
+import javax.swing.JCheckBox;
+
+import org.hps.recon.ecal.HPSEcalCluster;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalEventMonitor extends Driver implements ItemListener {
+
+    String inputCollectionName = "EcalCalHits";
+    String clusterCollectionName = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter;
+    IHistogram2D hitPlot;
+    IHistogram2D clusterPlot;
+    int eventRefreshRate = 1;
+    int eventn = 0;
+    //private AIDAFrame plotterFrame;
+    private JCheckBox logScaleBox;
+
+    public EcalEventMonitor() {
+    }
+
+    public void setEventRefreshRate(int eventRefreshRate) {
+        this.eventRefreshRate = eventRefreshRate;
+    }
+
+    public void setInputCollectionName(String inputCollectionName) {
+        this.inputCollectionName = inputCollectionName;
+    }
+
+    protected void detectorChanged(Detector detector) {
+        // Setup plots.
+        aida.tree().cd("/");
+        hitPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollectionName + " : Pedestal-Subtracted ADC Value", 47, -23.5, 23.5, 11, -5.5, 5.5);
+
+        clusterPlot = aida.histogram2D(detector.getDetectorName() + " : " + clusterCollectionName + " : Energy", 47, -23.5, 23.5, 11, -5.5, 5.5);
+
+        String title = "HPS ECal Event Monitor";
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory().create();
+        plotter.setTitle(title);
+        //plotterFrame = new AIDAFrame();
+        //plotterFrame.addPlotter(plotter);
+        //plotterFrame.setVisible(true);
+        //plotterFrame.setTitle(title);
+
+        // Create the plotter regions.
+        plotter.createRegions(1, 2);
+        plotter.style().statisticsBoxStyle().setVisible(false);
+
+        for (int i = 0; i < plotter.numberOfRegions(); i++) {
+            IPlotterStyle style = plotter.region(i).style();
+            style.setParameter("hist2DStyle", "colorMap");
+            style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+            style.zAxisStyle().setParameter("scale", "lin");
+        }
+
+        plotter.region(0).plot(hitPlot);
+        ((PlotterRegion) plotter.region(0)).getPlot().setAllowUserInteraction(false);
+        ((PlotterRegion) plotter.region(0)).getPlot().setAllowPopupMenus(false);
+
+        plotter.region(1).plot(clusterPlot);
+        ((PlotterRegion) plotter.region(1)).getPlot().setAllowUserInteraction(false);
+        ((PlotterRegion) plotter.region(1)).getPlot().setAllowPopupMenus(false);
+
+        logScaleBox = new JCheckBox("log scale");
+        logScaleBox.addItemListener(this);
+        //plotterFrame.getControlsPanel().add(logScaleBox);
+
+        //plotterFrame.pack();
+    }
+
+    public void process(EventHeader event) {
+        if (++eventn % eventRefreshRate != 0) {
+            return;
+        }
+        hitPlot.reset();
+        clusterPlot.reset();
+        if (event.hasCollection(CalorimeterHit.class, inputCollectionName)) {
+            List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollectionName);
+            for (CalorimeterHit hit : hits) {
+                hitPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"), hit.getRawEnergy());
+            }
+        }
+        if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
+            List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName);
+            for (HPSEcalCluster cluster : clusters) {
+                CalorimeterHit seedHit = cluster.getSeedHit();
+                clusterPlot.fill(seedHit.getIdentifierFieldValue("ix"), seedHit.getIdentifierFieldValue("iy"), cluster.getEnergy());
+            }
+        }
+    }
+
+    public void endOfData() {
+    	//if (plotterFrame != null) {
+        //    plotterFrame.dispose();
+        //}
+    }
+
+    @Override
+    public void itemStateChanged(ItemEvent ie) {
+        if (ie.getSource() == logScaleBox) {
+            for (int i = 0; i < plotter.numberOfRegions(); i++) {
+                IPlotterStyle style = plotter.region(i).style();
+                if (ie.getStateChange() == ItemEvent.DESELECTED) {
+                    style.zAxisStyle().setParameter("scale", "lin");
+                } else {
+                    style.zAxisStyle().setParameter("scale", "log");
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalEvsX.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalEvsX.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalEvsX.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,186 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.HepLorentzVector;
+import hep.physics.vec.VecOp;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hps.conditions.deprecated.EcalConditions;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.subdetector.HPSEcal3;
+import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalEvsX extends Driver {
+
+    String inputCollection = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter;
+    IHistogram2D EvsXPlot;
+    IHistogram1D invMassPlot;
+    IHistogram2D clusterPairEnergyPlot;
+    IHistogram2D clusterPairPositionPlot;
+    Detector detector;
+    int eventn = 0;
+    double targetZ = 0;
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setTargetZ(double targetZ) {
+        this.targetZ = targetZ;
+    }
+
+    @Override
+    protected void detectorChanged(Detector detector) {
+
+        this.detector = detector;
+
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal E vs X Plot");
+        plotter.style().dataStyle().errorBarStyle().setVisible(false);
+
+        // Setup plots.
+        aida.tree().cd("/");
+//        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -350.0, 400.0, 100, -2000, 2000);
+        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -350.0, 400.0, 100, 0, 2.0);
+        invMassPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Photon Pair Mass", 100, 0.0, 0.250);
+        clusterPairEnergyPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Energies", 1000, -0.1, 2.0, 1000, -0.1, 2.0);
+        clusterPairPositionPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Positions", 50, -350, 350, 50, -350, 350);
+
+        // Create the plotter regions.
+        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);
+        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.region(3).plot(clusterPairPositionPlot);
+        style = plotter.region(3).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style.zAxisStyle().setParameter("scale", "log");
+        plotter.show();
+    }
+
+    @Override
+    public void process(EventHeader event) {
+//        int orTrig = 0;
+//        int topTrig = 0;
+//        int botTrig = 0;
+//        if (event.hasCollection(TriggerData.class, "TriggerBank")) {
+//            List<TriggerData> triggerList = event.get(TriggerData.class, "TriggerBank");
+//            if (!triggerList.isEmpty()) {
+//                TriggerData triggerData = triggerList.get(0);
+//
+//                orTrig = triggerData.getOrTrig();
+//                topTrig = triggerData.getTopTrig();
+//                botTrig = triggerData.getBotTrig();
+//            }
+//        }
+
+        if (event.hasCollection(Cluster.class, inputCollection)) {
+            List<Cluster> clusters = event.get(Cluster.class, inputCollection);
+            List<Cluster> goodClusters = new ArrayList<Cluster>();
+            for (Cluster cluster : clusters) {
+                if (true || isGoodCluster(cluster)) {
+                    goodClusters.add(cluster);
+                }
+            }
+//            boolean left = false;
+//            boolean right = false;
+//            for (Cluster cluster : goodClusters) {
+//                if (cluster.getPosition()[0] > 0) {
+//                    right = true;
+//                }
+//                if (cluster.getPosition()[0] < 0) {
+//                    left = true;
+//                }
+//            }
+//            if (left && right) {
+//            if (goodClusters.size()>1) {
+//                for (Cluster cluster : goodClusters) {
+            for (Cluster cluster : goodClusters) {
+//                EvsXPlot.fill(cluster.getPosition()[0], Math.signum(cluster.getPosition()[1])*cluster.getEnergy());
+                EvsXPlot.fill(cluster.getPosition()[0], cluster.getEnergy());
+            }
+//            }
+//            if (!event.hasCollection(TrackerHit.class, "HelicalTrackHits") || event.get(TrackerHit.class, "HelicalTrackHits").isEmpty()) {
+                for (int i = 0; i < goodClusters.size() - 1; i++) {
+                    Cluster clus1 = goodClusters.get(i);
+                    double e1 = clus1.getEnergy();
+                    double x1 = clus1.getPosition()[0];
+                    if (clus1.getPosition()[1] > 0 && x1 > 0) {
+                        x1 = 350 - x1;
+                    }
+                    for (int j = i + 1; j < goodClusters.size(); j++) {
+                        Cluster clus2 = goodClusters.get(j);
+                        double e2 = clus2.getEnergy();
+                        double x2 = clus2.getPosition()[0];
+                        if (clus2.getPosition()[1] > 0 && x2 > 0) {
+                            x2 = 350 - x2;
+                        }
+//                    if (clusters.get(i).getPosition()[1] * clusters.get(j).getPosition()[1] > 0) {
+//                        continue;
+//                    }
+                        clusterPairEnergyPlot.fill(Math.max(e1, e2), Math.min(e1, e2));
+                        clusterPairPositionPlot.fill(Math.max(x1, x2), Math.min(x1, x2));
+//                    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)));
+                        invMassPlot.fill(VecOp.add(clusterAsPhoton(clus1), clusterAsPhoton(clus2)).magnitude());
+                    }
+                }
+//            }
+
+            ++eventn;
+        }
+    }
+
+    public HepLorentzVector clusterAsPhoton(Cluster cluster) {
+        Hep3Vector position = new BasicHep3Vector(cluster.getPosition());
+        Hep3Vector direction = VecOp.unit(VecOp.add(position, new BasicHep3Vector(41.27, 0, targetZ)));
+        return new BasicHepLorentzVector(cluster.getEnergy(), VecOp.mult(cluster.getEnergy(), direction));
+    }
+
+    public boolean isGoodCluster(Cluster cluster) {
+        NeighborMap map = ((HPSEcal3) EcalConditions.getSubdetector()).getNeighborMap();
+        for (CalorimeterHit hit : cluster.getCalorimeterHits()) {
+            if (map.get(hit.getCellID()).size() > 6) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void endOfData() {
+        if (plotter != null) {
+            plotter.hide();
+            plotter.destroyRegions();
+        }
+    }
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalHitPlots.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,268 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+
+import java.util.List;
+
+import org.hps.readout.ecal.TriggerData;
+import org.hps.recon.ecal.ECalUtils;
+import org.hps.util.Resettable;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalHitPlots extends Driver implements Resettable {
+
+    //AIDAFrame plotterFrame;
+    String inputCollection = "EcalCalHits";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter, plotter2, plotter3, plotter4;
+    IHistogram1D hitCountPlot;
+    IHistogram1D hitTimePlot;
+    IHistogram1D hitEnergyPlot;
+    IHistogram1D hitMaxEnergyPlot;
+    IHistogram1D topTimePlot, botTimePlot, orTimePlot;
+    IHistogram1D topTrigTimePlot, botTrigTimePlot, orTrigTimePlot;
+    IHistogram2D topTimePlot2D, botTimePlot2D, orTimePlot2D;
+//    IHistogram2D topX, botX, topY, botY;
+    IHistogram2D edgePlot;
+    int eventn = 0;
+    double maxE = 5000 * ECalUtils.MeV;
+    boolean logScale = false;
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setMaxE(double maxE) {
+        this.maxE = maxE;
+    }
+
+    public void setLogScale(boolean logScale) {
+        this.logScale = logScale;
+    }
+
+    @Override
+    protected void detectorChanged(Detector detector) {
+
+        //plotterFrame = new AIDAFrame();
+        //plotterFrame.setTitle("HPS ECal Hit Plots");
+
+        aida.tree().cd("/");
+        IPlotterFactory plotterFactory = aida.analysisFactory().createPlotterFactory("Ecal Hit Plots");
+
+        // Setup the plotter.
+        plotter = plotterFactory.create("Hit Counts");
+        plotter.setTitle("Hit Counts");
+        //plotterFrame.addPlotter(plotter);
+        plotter.style().dataStyle().errorBarStyle().setVisible(false);
+
+        // Setup plots.
+        hitCountPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count In Event", 10, -0.5, 9.5);
+        hitTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time", 100, 0 * 4.0, 100 * 4.0);
+
+        // Create the plotter regions.
+        plotter.createRegions(1, 2);
+        plotter.region(0).plot(hitCountPlot);
+        plotter.region(1).plot(hitTimePlot);
+
+
+        // Setup the plotter.
+        plotter2 = plotterFactory.create("Hit Energies");
+        plotter2.setTitle("Hit Energies");
+        //plotterFrame.addPlotter(plotter2);
+        plotter2.style().dataStyle().errorBarStyle().setVisible(false);
+
+        hitEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Energy", 1000, -0.1, maxE);
+        hitMaxEnergyPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Maximum Hit Energy In Event", 1000, -0.1, maxE);
+
+        if (logScale) {
+            plotter2.style().yAxisStyle().setParameter("scale", "log");
+        }
+
+        // Create the plotter regions.
+        plotter2.createRegions(1, 2);
+        plotter2.region(0).plot(hitEnergyPlot);
+        plotter2.region(1).plot(hitMaxEnergyPlot);
+
+        plotter3 = plotterFactory.create("Hit Times");
+        plotter3.setTitle("Hit Times");
+        //plotterFrame.addPlotter(plotter3);
+        plotter3.style().dataStyle().errorBarStyle().setVisible(false);
+        plotter3.createRegions(3, 3);
+
+        topTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : First Hit Time, Top", 100, 0, 100 * 4.0);
+        botTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : First Hit Time, Bottom", 100, 0, 100 * 4.0);
+        orTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : First Hit Time, Or", 100, 0, 100 * 4.0);
+
+        topTrigTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Trigger Time, Top", 32, 0, 32);
+        botTrigTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Trigger Time, Bottom", 32, 0, 32);
+        orTrigTimePlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Trigger Time, Or", 32, 0, 32);
+
+        topTimePlot2D = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time vs. Trig Time, Top", 100, 0, 100 * 4.0, 32, 0, 32);
+        botTimePlot2D = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time vs. Trig Time, Bottom", 100, 0, 100 * 4.0, 32, 0, 32);
+        orTimePlot2D = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time vs. Trig Time, Or", 100, 0, 100 * 4.0, 32, 0, 32);
+
+        // Create the plotter regions.
+        plotter3.region(0).plot(topTimePlot);
+        plotter3.region(1).plot(botTimePlot);
+        plotter3.region(2).plot(orTimePlot);
+        plotter3.region(3).plot(topTrigTimePlot);
+        plotter3.region(4).plot(botTrigTimePlot);
+        plotter3.region(5).plot(orTrigTimePlot);
+        for (int i = 0; i < 6; i++) {
+            if (plotter3.region(i).style() != null) {
+                plotter3.region(i).style().yAxisStyle().setParameter("scale", "log");
+            }
+        }
+        plotter3.region(6).plot(topTimePlot2D);
+        plotter3.region(7).plot(botTimePlot2D);
+        plotter3.region(8).plot(orTimePlot2D);
+        for (int i = 6; i < 9; i++) {
+            if (plotter3.region(i).style() != null) {
+                plotter3.region(i).style().setParameter("hist2DStyle", "colorMap");
+                plotter3.region(i).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+                plotter3.region(i).style().zAxisStyle().setParameter("scale", "log");
+            }
+        }
+
+        plotter4 = plotterFactory.create("Edges");
+        plotter4.setTitle("Edges");
+        //plotterFrame.addPlotter(plotter4);
+        plotter4.style().setParameter("hist2DStyle", "colorMap");
+        plotter4.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter4.style().zAxisStyle().setParameter("scale", "log");
+        plotter4.createRegion();
+
+        edgePlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Pairs Across Crystal Edges", 93, -23.25, 23.25, 21, -5.25, 5.25);
+        plotter4.region(0).plot(edgePlot);
+
+        //plotterFrame.setVisible(true);
+        //plotterFrame.pack();
+    }
+
+    @Override
+    public void process(EventHeader event) {
+        int orTrigTime = -1;
+        int topTrigTime = -1;
+        int botTrigTime = -1;
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            if (!triggerList.isEmpty()) {
+                GenericObject triggerData = triggerList.get(0);
+
+                int orTrig = TriggerData.getOrTrig(triggerData);
+                if (orTrig != 0) {
+                    for (int i = 0; i < 32; i++) {
+                        if ((1 << (31 - i) & orTrig) != 0) {
+                            orTrigTime = i;
+                            orTrigTimePlot.fill(i);
+                            break;
+                        }
+                    }
+                }
+                int topTrig = TriggerData.getTopTrig(triggerData);
+                if (topTrig != 0) {
+                    for (int i = 0; i < 32; i++) {
+                        if ((1 << (31 - i) & topTrig) != 0) {
+                            topTrigTime = i;
+                            topTrigTimePlot.fill(i);
+                            break;
+                        }
+                    }
+                }
+                int botTrig = TriggerData.getBotTrig(triggerData);
+                if (botTrig != 0) {
+                    for (int i = 0; i < 32; i++) {
+                        if ((1 << (31 - i) & botTrig) != 0) {
+                            botTrigTime = i;
+                            botTrigTimePlot.fill(i);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        if (event.hasCollection(CalorimeterHit.class, inputCollection)) {
+            List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection);
+            hitCountPlot.fill(hits.size());
+            double maxEnergy = 0;
+            double topTime = Double.POSITIVE_INFINITY;
+            double botTime = Double.POSITIVE_INFINITY;
+            double orTime = Double.POSITIVE_INFINITY;
+            for (CalorimeterHit hit : hits) {
+//                if (hit.getIdentifierFieldValue("iy") > 0) {
+//                    topX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]);
+//                    topY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]);
+//                } else {
+//                    botX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]);
+//                    botY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]);                    
+//                }
+                hitEnergyPlot.fill(hit.getRawEnergy());
+                hitTimePlot.fill(hit.getTime());
+                if (hit.getTime() < orTime) {
+                    orTime = hit.getTime();
+                }
+                if (hit.getIdentifierFieldValue("iy") > 0 && hit.getTime() < topTime) {
+                    topTime = hit.getTime();
+                }
+                if (hit.getIdentifierFieldValue("iy") < 0 && hit.getTime() < botTime) {
+                    botTime = hit.getTime();
+                }
+                if (hit.getRawEnergy() > maxEnergy) {
+                    maxEnergy = hit.getRawEnergy();
+                }
+            }
+            if (orTime != Double.POSITIVE_INFINITY) {
+                orTimePlot.fill(orTime);
+                orTimePlot2D.fill(orTime, orTrigTime);
+            }
+            if (topTime != Double.POSITIVE_INFINITY) {
+                topTimePlot.fill(topTime);
+                topTimePlot2D.fill(topTime, topTrigTime);
+            }
+            if (botTime != Double.POSITIVE_INFINITY) {
+                botTimePlot.fill(botTime);
+                botTimePlot2D.fill(botTime, botTrigTime);
+            }
+            hitMaxEnergyPlot.fill(maxEnergy);
+            for (int i = 0; i < hits.size(); i++) {
+                CalorimeterHit hit1 = hits.get(i);
+                int x1 = hit1.getIdentifierFieldValue("ix");
+                int y1 = hit1.getIdentifierFieldValue("iy");
+                for (int j = i + 1; j < hits.size(); j++) {
+                    CalorimeterHit hit2 = hits.get(j);
+                    int x2 = hit2.getIdentifierFieldValue("ix");
+                    int y2 = hit2.getIdentifierFieldValue("iy");
+                    if ((Math.abs(x1 - x2) <= 1 || x1 * x2 == -1) && (Math.abs(y1 - y2) <= 1)) {
+                        if (x1 != x2 || y1 != y2) {
+                            edgePlot.fill((x1 + x2) / 2.0, (y1 + y2) / 2.0);
+                        }
+                    }
+                }
+            }
+        } else {
+            hitCountPlot.fill(0);
+        }
+    }
+
+    @Override
+    public void reset() {
+        hitCountPlot.reset();
+        hitTimePlot.reset();
+        hitEnergyPlot.reset();
+        hitMaxEnergyPlot.reset();
+    }
+
+    @Override
+    public void endOfData() {
+        //plotterFrame.dispose();
+    }
+}
\ No newline at end of file

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
EcalMonitoringPlots.java added at 773
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalMonitoringPlots.java	                        (rev 0)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalMonitoringPlots.java	2014-07-15 20:42:49 UTC (rev 773)
@@ -0,0 +1,135 @@
+package org.hps.monitoring.drivers.ecal;
+
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+
+import java.util.List;
+
+import org.hps.recon.ecal.HPSEcalCluster;
+import org.hps.util.Redrawable;
+import org.hps.util.Resettable;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawCalorimeterHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalMonitoringPlots extends Driver implements Resettable, Redrawable {
+
+    String inputCollection = "EcalReadoutHits";
+    String clusterCollection = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter;
+    IHistogram2D hitCountFillPlot;
+    IHistogram2D hitCountDrawPlot;
+    IHistogram2D clusterCountFillPlot;
+    IHistogram2D clusterCountDrawPlot;
+    int eventRefreshRate = 1;
+    int eventn = 0;
+    boolean hide = false;
+
+    public EcalMonitoringPlots() {
+    }
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setClusterCollection(String clusterCollection) {
+        this.clusterCollection = clusterCollection;
+    }
+
+    public void setHide(boolean hide) {
+        this.hide = hide;
+    }
+
+    protected void detectorChanged(Detector detector) {
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory("Ecal Monitoring Plots").create("HPS ECal Monitoring Plots");
+        // Setup plots.
+        aida.tree().cd("/");
+        hitCountDrawPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
+        hitCountFillPlot = makeCopy(hitCountDrawPlot);
+        clusterCountDrawPlot = aida.histogram2D(detector.getDetectorName() + " : " + clusterCollection + " : Cluster Center Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
+        clusterCountFillPlot = makeCopy(clusterCountDrawPlot);
+
+        // Create the plotter regions.
+        plotter.createRegions(1, 2);
+        plotter.style().statisticsBoxStyle().setVisible(false);
+        IPlotterStyle style = plotter.region(0).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(0).plot(hitCountDrawPlot);
+        style = plotter.region(1).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(1).plot(clusterCountDrawPlot);
+        //if (!hide) {
+        //    plotter.show();
+        //}
+    }
+
+    public void process(EventHeader event) {
+        if (event.hasCollection(BaseRawCalorimeterHit.class, inputCollection)) {
+            List<BaseRawCalorimeterHit> hits = event.get(BaseRawCalorimeterHit.class, inputCollection);
+            for (BaseRawCalorimeterHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+            for (RawTrackerHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(CalorimeterHit.class, inputCollection)) {
+            List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection);
+            for (CalorimeterHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(HPSEcalCluster.class, clusterCollection)) {
+            List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollection);
+//if (clusters.size()>1)            
+            for (HPSEcalCluster cluster : clusters) {
+                clusterCountFillPlot.fill(cluster.getSeedHit().getIdentifierFieldValue("ix"), cluster.getSeedHit().getIdentifierFieldValue("iy"));
+            }
+        }
+        if (eventRefreshRate > 0 && ++eventn % eventRefreshRate == 0) {
+            redraw();
+        }
+    }
+
+    public void endOfData() {
+        plotter.hide();
+        plotter.destroyRegions();
+    }
+
+    @Override
+    public void reset() {
+        hitCountFillPlot.reset();
+        hitCountDrawPlot.reset();
+        clusterCountFillPlot.reset();
+        clusterCountDrawPlot.reset();
+    }
+
+    @Override
+    public void redraw() {
+        hitCountDrawPlot.reset();
+        hitCountDrawPlot.add(hitCountFillPlot);
+        clusterCountDrawPlot.reset();
+        clusterCountDrawPlot.add(clusterCountFillPlot);
+    }
+
+    @Override
+    public void setEventRefreshRate(int eventRefreshRate) {
+        this.eventRefreshRate = eventRefreshRate;
+    }
+
+    private IHistogram2D makeCopy(IHistogram2D hist) {
+        return aida.histogram2D(hist.title() + "_copy", hist.xAxis().bins(), hist.xAxis().lowerEdge(), hist.xAxis().upperEdge(), hist.yAxis().bins(), hist.yAxis().lowerEdge(), hist.yAxis().upperEdge());
+    }
+}
\ No newline at end of file
SVNspam 0.1