Commit in java/trunk on MAIN
hps-java/src/main/resources/org/lcsim/hps/steering/users/celentan/EcalMonitoringCelentan.lcsim+13-11285 -> 286
users/src/main/java/org/lcsim/hps/users/celentan/EcalClusterPlots.java+204added 286
                                                /EcalDaqPlots.java+146added 286
                                                /EcalEventMonitor.java+128added 286
                                                /EcalHitPlots.java+22-102285 -> 286
                                                /EcalWindowEventPlots.java+148added 286
                                                /EcalWindowPlots.java+188added 286
                                                /EcalWindowPlotsXY.java+178added 286
+1027-113
6 added + 2 modified, total 8 files
Working on the Ecal monitoring within the monitoring app.
Going trough the existing drivers and see if histograms are fine.

java/trunk/hps-java/src/main/resources/org/lcsim/hps/steering/users/celentan
EcalMonitoringCelentan.lcsim 285 -> 286
--- java/trunk/hps-java/src/main/resources/org/lcsim/hps/steering/users/celentan/EcalMonitoringCelentan.lcsim	2014-03-07 00:16:27 UTC (rev 285)
+++ java/trunk/hps-java/src/main/resources/org/lcsim/hps/steering/users/celentan/EcalMonitoringCelentan.lcsim	2014-03-07 21:43:02 UTC (rev 286)
@@ -12,14 +12,16 @@
         <driver name="EcalRawConverter"/>
         <driver name="EcalClusterer"/>
 <!--        <driver name="EcalPedestalPlots"/>-->
-        <driver name="EcalMonitoringPlots"/>
-        <driver name="EcalHitPlots"/>
-        <driver name="EcalClusterPlots"/>
-        <driver name="EcalEvsX"/>
-<!--        <driver name="TriggerPlots"/>-->
+        <driver name="EcalMonitoringPlots"/>     <!-- General plots -->
+        <driver name="EcalHitPlots"/>            <!-- Single hit distributions -->
+        <driver name="EcalClusterPlots"/>        <!-- Clusters distributions -->
+        <driver name="EcalDaqPlots"/>           <!-- DAQ Plots -->
+<!--      <driver name="EcalWindowPlots"/>   -->    <!-- Window plots -->
+<!--      <driver name="EcalEventMonitor"/>   -->
+<!--   <driver name="EcalEvsX"/>    -->           
+<!--    <driver name="TriggerPlots"/>-->
 <!--
         <driver name="EcalEventMonitor"/>
-        <driver name="EcalWindowPlots"/>
         <driver name="EcalDaqPlots"/>
 -->
 <!--        <driver name="RunControlDriver" />-->
@@ -33,16 +35,16 @@
             <applyBadCrystalMap>false</applyBadCrystalMap>
 <!--            <dropBadFADC>true</dropBadFADC>-->
         </driver>
-        <driver name="EcalDaqPlots" type="org.lcsim.hps.monitoring.ecal.EcalDaqPlots">
+        <driver name="EcalDaqPlots" type="org.lcsim.hps.users.celentan.EcalDaqPlots">
         </driver>
-        <driver name="EcalMonitoringPlots" type="org.lcsim.hps.monitoring.ecal.EcalMonitoringPlots">
+        <driver name="EcalMonitoringPlots" type="org.lcsim.hps.users.celentan.EcalMonitoringPlots">
             <inputCollection>EcalCalHits</inputCollection>
             <eventRefreshRate>100</eventRefreshRate>
         </driver>
-        <driver name="EcalEventMonitor" type="org.lcsim.hps.monitoring.ecal.EcalEventMonitor">
+        <driver name="EcalEventMonitor" type="org.lcsim.hps.users.celentan.EcalEventMonitor">
             <eventRefreshRate>1000</eventRefreshRate>
         </driver>
-        <driver name="EcalWindowPlots" type="org.lcsim.hps.monitoring.ecal.EcalWindowPlotsXY">
+        <driver name="EcalWindowPlots" type="org.lcsim.hps.users.celentan.EcalWindowPlots">
             <inputCollection>EcalReadoutHits</inputCollection>
         </driver>
         <driver name="EcalPedestalPlots" type="org.lcsim.hps.monitoring.ecal.EcalPedestalPlots">
@@ -63,7 +65,7 @@
             <maxE>2.0</maxE>
             <logScale>true</logScale>
         </driver>
-        <driver name="EcalClusterPlots" type="org.lcsim.hps.monitoring.ecal.EcalClusterPlots">
+        <driver name="EcalClusterPlots" type="org.lcsim.hps.users.celentan.EcalClusterPlots">
             <maxE>2.0</maxE>
             <logScale>false</logScale>
         </driver>

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalClusterPlots.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalClusterPlots.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalClusterPlots.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,204 @@
+package org.lcsim.hps.users.celentan;
+
+
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+
+import java.util.List;
+
+import org.apache.commons.math.stat.StatUtils;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.evio.TriggerData;
+import org.lcsim.hps.monitoring.deprecated.Resettable;
+import org.lcsim.hps.recon.ecal.ECalUtils;
+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 plotter1, 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;
+    boolean hide = 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 factory.
+    	IPlotterFactory plotterFactory = aida.analysisFactory().createPlotterFactory("Ecal Cluster Plots");
+    	plotter1 = plotterFactory.create("Cluster Counts");
+        plotter1.setTitle("Cluster Counts");
+        //plotterFrame.addPlotter(plotter);
+        plotter1.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.
+        plotter1.createRegions(1, 2);
+        plotter1.region(0).plot(clusterCountPlot);
+        plotter1.region(1).plot(clusterSizePlot);
+
+
+        // Setup the plotter.
+        plotter2 = plotterFactory.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 = plotterFactory.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 Time Mean", 400, 0, 4.0 * 100);
+        clusterTimeSigma = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Time Sigma", 100, 0, 40);
+        plotter3.region(0).plot(clusterTimes);
+        plotter3.region(1).plot(clusterTimeSigma);
+
+        plotter4 = plotterFactory.create("Cluster Center");
+        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 + " : Cluster center from hits", 93, -23.25, 23.25, 21, -5.25, 5.25);
+        plotter4.region(0).plot(edgePlot);
+
+        //plotterFrame.setVisible(true);
+        //plotterFrame.pack();
+        
+        if (!hide){
+        	plotter1.show();
+        	plotter2.show();
+        	plotter3.show();
+        	plotter4.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);
+            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()];
+                double[] energies = new double[cluster.getCalorimeterHits().size()];
+                
+                double X = 0;
+                double Y = 0;
+//                    System.out.format("cluster:\n");
+                for (CalorimeterHit hit : cluster.getCalorimeterHits()) {
+                    if (hit.getRawEnergy() != 0) {
+                    	energies[size] = hit.getRawEnergy();
+                        times[size] = hit.getTime();
+                        X += energies[size] * hit.getIdentifierFieldValue("ix");
+                        Y += energies[size] * hit.getIdentifierFieldValue("iy");
+                        //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());
+                    }
+                }
+                X/=size;
+                Y/=size;
+                clusterTimes.fill(StatUtils.mean(times, 0, size));
+                clusterSizePlot.fill(size); //The number of "hits" in a "cluster"
+                clusterTimeSigma.fill(Math.sqrt(StatUtils.variance(times, 0, size)));
+                edgePlot.fill(X,Y);
+            
+             
+//                }
+            }
+            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/users/src/main/java/org/lcsim/hps/users/celentan
EcalDaqPlots.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalDaqPlots.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalDaqPlots.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,146 @@
+package org.lcsim.hps.users.celentan;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+import hep.aida.IPlotterStyle;
+import hep.aida.ref.plotter.PlotterRegion;
+import jas.hist.JASHist;
+
+import java.util.ArrayList;
+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.compact.Subdetector;
+import org.lcsim.hps.monitoring.deprecated.Resettable;
+import org.lcsim.hps.recon.ecal.EcalConditions;
+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);
+
+		plots = new ArrayList<IHistogram1D>();
+		aida = AIDA.defaultInstance();
+		aida.tree().cd("/");
+		IPlotterFactory factory= aida.analysisFactory().createPlotterFactory("ECAL DAQ Plots");
+		plotter =factory.create("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);
+				int id = (i)*2+(j-1);
+				plots.add(aida.histogram1D("ECAL: Crate " + j + "; Slot " + slots[i], 16, 0, 16));
+				plotter.region(region).plot(plots.get(id));
+				/*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);
+				int id = getSlotIndex(slot)*2+(crate-1);
+				
+				//System.out.println("crate="+crate+"; slot="+slot+"; channel="+channel);
+				System.out.println("filling plot: " + "ECAL: Crate " + crate + "; Slot " + slot+ "(" + getSlotIndex(slot)+ ")"+" id: "+id );	
+				plots.get(id).fill(channel);
+			}
+		}
+		if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+			List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+			for (RawTrackerHit 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);
+				int id = getSlotIndex(slot)*2+(crate-1);
+				plots.get(id).fill(channel);
+			}
+		}
+	}
+	
+	
+	
+	public int getSlotIndex(int slot){
+		int ret=-1;
+		for (int ii=0;ii<14;ii++){
+			if (slots[ii]==slot) ret=ii;
+		}
+		return ret;
+	}
+	
+	
+	
+	
+	
+}

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalEventMonitor.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalEventMonitor.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalEventMonitor.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,128 @@
+package org.lcsim.hps.users.celentan;
+
+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.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.recon.ecal.HPSEcalCluster;
+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.
+    	System.out.println("ECAL Event Monitor: detector changed");
+        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/users/src/main/java/org/lcsim/hps/users/celentan
EcalHitPlots.java 285 -> 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalHitPlots.java	2014-03-07 00:16:27 UTC (rev 285)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalHitPlots.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -30,7 +30,7 @@
 import javax.swing.JPanel;
 //import org.jfree.chart.ChartPanel;
 
-public class EcalHitPlots extends Driver implements Resettable, MouseListener, Redrawable{
+public class EcalHitPlots extends Driver implements Resettable, MouseListener{
 
     //AIDAFrame plotterFrame;
     String inputCollection = "EcalCalHits";
@@ -46,16 +46,13 @@
     IHistogram2D topTimePlot2D, botTimePlot2D, orTimePlot2D;
    // IHistogram2D topX, botX, topY, botY;
     IHistogram2D edgePlot;
-    
-    PlotterUtilities thePlotterUtilities;
+   
   
     //Plotter5
-    IPlotter plotter5;
     ArrayList<IHistogram1D> channelEnergyPlot;
-    IHistogram2D channelMeanEnergy; 
-    GlobalMouseListener plotter5listener;
-    boolean isPlotter5zoomed=false;
+    ArrayList<IHistogram1D> channelTimePlot;
     
+  
     int eventn = 0;
     int eventRefreshRate = 1;
     int dummy = 0;
@@ -126,30 +123,22 @@
         plotter2.region(0).plot(hitEnergyPlot);
         plotter2.region(1).plot(hitMaxEnergyPlot);
 
-        //A. Celentano
-        plotter5 = plotterFactory.create("Hit Energies - per channel");
-        plotter5.setTitle("Hit Energies - per channel");
-        plotter5.style().dataStyle().errorBarStyle().setVisible(false);
-        plotter5.createRegions(1, 2);
+    
   
-        
-        plotter5listener=new GlobalMouseListener(thePlotterUtilities.componentForPlotter(plotter5));
-        plotter5listener.addMouseListener(this);
-        
-        channelMeanEnergy = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
+      
         channelEnergyPlot=new ArrayList<IHistogram1D>();
-         
+        channelTimePlot=new ArrayList<IHistogram1D>();
         for(int id = 0; id < (47*11); id = id +1){
-        	  
         	  int row=this.getRowFromHistoID(id);
         	  int column=this.getColumnFromHistoID(id);      
         	  //create the histograms
-        	  channelEnergyPlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Energy : " + (row) + " "+ (column)+ ": "+id, 1000, -0.1, maxEch));     
-        	 }
+        	  channelEnergyPlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Energy : " + (row) + " "+ (column)+ ": "+id, 1000, -0.1, maxEch));  
+        	  channelTimePlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Time : " + (row) + " "+ (column)+ ": "+id, 100, 0, 400));     
+        }
          
-        plotter5.region(0).plot(channelMeanEnergy);
         
         
+        
         plotter3 = plotterFactory.create("Hit Times");
         plotter3.setTitle("Hit Times");
       //  plotterFrame.addPlotter(plotter3);
@@ -196,19 +185,19 @@
       //  plotterFrame.addPlotter(plotter4);
         plotter4.style().setParameter("hist2DStyle", "colorMap");
         plotter4.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-        plotter4.style().zAxisStyle().setParameter("scale", "log");
+       // 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);
+        edgePlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count");        
         plotter4.region(0).plot(edgePlot);
 
         
         if (!hide) {
         	plotter.show();
         	plotter2.show();
-        	plotter3.show();
-        	plotter4.show();
-        	plotter5.show();
+        	plotter3.show(); 
+        	plotter4.show(); 
+        //	plotter5.show(); Andrea: not yet.
         }
         //plotterFrame.setVisible(true);
         //plotterFrame.pack();
@@ -286,7 +275,6 @@
                 row=hit.getIdentifierFieldValue("iy"); 
                 if ((hit.getIdentifierFieldValue("ix")!=0)&&(hit.getIdentifierFieldValue("iy")!=0)){
                   	id = this.getHistoIDFromRowColumn(row,column);
-                	//System.out.println("HIT: "+column+" "+row+" "+id);
                 	channelEnergyPlot.get(id).fill(hit.getCorrectedEnergy());
                 }
                 
@@ -316,6 +304,7 @@
                 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");
@@ -326,7 +315,7 @@
                     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);
+                         //  edgePlot.fill((x1 + x2) / 2.0, (y1 + y2) / 2.0);
                         }
                     }
                 }
@@ -335,9 +324,7 @@
             hitCountPlot.fill(0);
         }
         
-        if (eventRefreshRate > 0 && ++eventn % eventRefreshRate == 0) {
-            redraw();
-        }
+       
         
     }
 
@@ -392,59 +379,7 @@
         	  System.out.println(e.getSource().getClass().getName());
         	  if (e.getSource().getClass().getName() == "org.jfree.chart.ChartPanel"){
         		  	 JPanel panel=(JPanel)e.getSource();  
-        		  	 JPanel father=(JPanel)panel.getParent();
-        			 if (!isPlotter5zoomed){
-        			
-        				 isPlotter5zoomed=true;   
-        			  	 int x=panel.getX();
-            		  	 int y=panel.getY();
-            		  	 int w=panel.getWidth();
-            		  	 int h=panel.getHeight();
-            		  	 System.out.println(x+" "+y+" "+w+" "+h);
-            		     
-            		  	 int column=x/w;
-            		  	 column=column-23;
-            		  	 int row=y/h;
-            		  	 row=-row+5;
-            		  	 int id=getHistoIDFromRowColumn(row, column);
-            			 System.out.println("ZOOM IN histo "+id);
-            		  	 System.out.println(row+" "+column+" "+id+" ");   
-            	      	 plotter5.destroyRegions();
-            		  	 plotter5.clearRegions();
-        				
-            		  	 //	plotter5.destroyRegions();
-        				/*
-            		  	 System.out.println(plotter5.numberOfRegions());
-        				 */
-            		  	 plotter5.createRegion();
-        				 plotter5.region(0).plot(channelEnergyPlot.get(id));
-        				 System.out.println(plotter5.numberOfRegions());      				
-        				 plotter5.show();
-        				  
-        			 }
-        			 else {
-        				 this.isPlotter5zoomed=false;
-        				 System.out.println("ZOOM out");
-        				 System.out.println(plotter5.numberOfRegions());
-        				 plotter5.clearRegions();
-        				 /*plotter5.destroyRegions();
-        				 System.out.println(plotter5.numberOfRegions());
-        				 
-        				 plotter5.createRegions(47,11); //1 more, to have raw 0 and column 0 empty.
-        				
-        			
-        				 System.out.println(Arrays.toString(plotter5.availableParameters()));
-        			     for(int id = 0; id < (47*11); id = id +1){			        	  
-        			       int row=getRowFromHistoID(id);
-        			       int column=getColumnFromHistoID(id);       			        	  
-        			        	  if ((row!=0)&&(column!=0)&&(!isInHole(row,column))){
-        			        		  plotter5.region(id).plot(channelEnergyPlot.get(id));       	
-        			        	  }
-        			     }*/
-        			     plotter5.region(0).plot(hitCountPlot);
-        				
-        				 plotter5.show();          				
-        			}
+        		  	 JPanel father=(JPanel)panel.getParent(); 
         	  }
             break;
             }
@@ -456,23 +391,8 @@
         }   
 
 
-    @Override
-    public void redraw() {
-         channelMeanEnergy.reset();
-         for(int id = 0; id < (47*11); id = id +1){			        	  
-		       int row=getRowFromHistoID(id);
-		       int column=getColumnFromHistoID(id);       			        	  
-		        	  if ((row!=0)&&(column!=0)&&(!isInHole(row,column))){
-		        		 if (channelEnergyPlot.get(id).mean()>0) channelMeanEnergy.fill(row,column,channelEnergyPlot.get(id).mean());	
-		        	  }
-		     }
-    
-    }
-    @Override
-    public void setEventRefreshRate(int eventRefreshRate) {
-        this.eventRefreshRate = eventRefreshRate;
-    }
-
+   
+ 
 }
 
    
\ No newline at end of file

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalWindowEventPlots.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowEventPlots.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowEventPlots.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,148 @@
+package org.lcsim.hps.users.celentan;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalWindowEventPlots extends Driver implements ActionListener {
+
+    private String inputCollection;
+    private IPlotter plotter;
+    private AIDA aida = AIDA.defaultInstance();
+    //private AIDAFrame plotterFrame;
+    private IHistogram1D[][] plots = new IHistogram1D[47][11];
+    private JLabel xLabel, yLabel;
+    private JComboBox xCombo;
+    private JComboBox yCombo;
+    private JButton blankButton;
+    private static final Integer[] xList = new Integer[46];
+    private static final Integer[] yList = new Integer[10];
+    boolean hide = false;
+    int window = 100;
+
+    public void setWindow(int window) {
+        this.window = window;
+    }
+
+    public EcalWindowEventPlots() {
+        int count = 0;
+        for (int i = -23; i <= 23; i++) {
+            if (i != 0) {
+                xList[count] = i;
+                count++;
+            }
+        }
+        count = 0;
+        for (int i = -5; i <= 5; i++) {
+            if (i != 0) {
+                yList[count] = i;
+                count++;
+            }
+        }
+    }
+
+    public void setHide(boolean hide) {
+        this.hide = hide;
+    }
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    @Override
+    public void detectorChanged(Detector detector) {
+        if (inputCollection == null) {
+            throw new RuntimeException("The inputCollection parameter was not set.");
+        }
+
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory().create();
+        plotter.setTitle("HPS ECal Window Event Plots");
+        //plotterFrame = new AIDAFrame();
+        //plotterFrame.addPlotter(plotter);
+
+        aida = AIDA.defaultInstance();
+        aida.tree().cd("/");
+
+        for (int x = -23; x <= 23; x++) { // slot
+            for (int y = -5; y <= 5; y++) { // crate                
+                plots[x + 23][y + 5] = aida.histogram1D("ECAL window: x=" + x + "; y=" + y, window, -0.5, window - 0.5);
+            }
+        }
+
+        // Create the plotter regions.
+        plotter.createRegion();
+
+        xCombo = new JComboBox(xList);
+        xCombo.addActionListener(this);
+        xLabel = new JLabel("x");
+        xLabel.setLabelFor(xCombo);
+        //plotterFrame.getControlsPanel().add(xLabel);
+        //plotterFrame.getControlsPanel().add(xCombo);
+        yCombo = new JComboBox(yList);
+        yCombo.addActionListener(this);
+        yLabel = new JLabel("y");
+        yLabel.setLabelFor(yCombo);
+        //plotterFrame.getControlsPanel().add(yLabel);
+        //plotterFrame.getControlsPanel().add(yCombo);
+        blankButton = new JButton("Hide histogram");
+        //plotterFrame.getControlsPanel().add(blankButton);
+        blankButton.addActionListener(this);
+
+        //plotterFrame.pack();
+
+        plotter.style().statisticsBoxStyle().setVisible(false);
+        plotter.style().zAxisStyle().setParameter("allowZeroSuppression", "true");
+        plotter.style().dataStyle().errorBarStyle().setVisible(false);
+
+        plotter.region(0).plot(plots[-5 + 23][2 + 5]);
+        xCombo.setSelectedIndex((-5 + 23));
+        yCombo.setSelectedIndex((2 + 5 - 1));
+
+        //if (!hide) {
+        //    plotterFrame.setVisible(true);
+        //}
+    }
+
+    @Override
+    public void process(EventHeader event) {
+        for (int x = -23; x <= 23; x++) { // slot
+            for (int y = -5; y <= 5; y++) { // crate                
+                plots[x + 23][y + 5].reset();
+            }
+        }
+
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+            for (RawTrackerHit hit : hits) {
+                int x = hit.getIdentifierFieldValue("ix");
+                int y = hit.getIdentifierFieldValue("iy");
+                for (int i = 0; i < window; i++) {
+                    plots[x + 23][y + 5].fill(i, hit.getADCValues()[i]);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        Integer x, y;
+        x = (Integer) xCombo.getSelectedItem();
+        y = (Integer) yCombo.getSelectedItem();
+        plotter.region(0).clear();
+        plotter.region(0).plot(plots[x + 23][y + 5]);
+    }
+}
\ No newline at end of file

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalWindowPlots.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowPlots.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowPlots.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,188 @@
+package org.lcsim.hps.users.celentan;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.monitoring.deprecated.AIDAFrame;
+import org.lcsim.hps.recon.ecal.EcalConditions;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalWindowPlots extends Driver implements ActionListener {
+
+    private String inputCollection = "EcalReadoutHits";
+    private IPlotter plotter;
+    private AIDAFrame plotterFrame;
+    private AIDA aida;
+    private Detector detector;
+    private IHistogram1D windowPlot;
+    private int window = 100;
+    private JLabel crateLabel, slotLabel, channelLabel;
+    private JComboBox crateCombo;
+    private JComboBox slotCombo;
+    private JComboBox channelCombo;
+    private static final String[] crateList = new String[3];
+    private static final String[] slotList = new String[17];
+    private static final String[] channelList = new String[17];
+    private boolean testCrate = false;
+    private boolean testSlot = false;
+    private boolean testChannel = false;
+    private int plotCrate, plotSlot, plotChannel;
+
+    public EcalWindowPlots() {
+        int count = 0;
+        crateList[0] = "all";
+        for (int i = 1; i <= 2; i++) {
+            count++;
+            crateList[count] = Integer.toString(i);
+        }
+        count = 0;
+        slotList[0] = "all";
+        for (int i = 0; i <= 15; i++) {
+            count++;
+            slotList[count] = Integer.toString(i);
+        }
+        count = 0;
+        channelList[0] = "all";
+        for (int i = 0; i <= 15; i++) {
+            count++;
+            channelList[count] = Integer.toString(i);
+        }
+    }
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setWindow(int window) {
+        this.window = window;
+    }
+
+    @Override
+    public void detectorChanged(Detector detector) {
+
+        this.detector = detector;
+
+        if (inputCollection == null) {
+            throw new RuntimeException("The inputCollection parameter was not set.");
+        }
+
+        setupPlots();
+    }
+
+    private void setupPlots() {
+        if (plotterFrame != null) {
+            plotterFrame.dispose(); //this clears the plotterFrame
+        }
+
+        aida = AIDA.defaultInstance();
+        aida.tree().cd("/");
+        plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECAL Window Plots");
+
+        plotterFrame = new AIDAFrame();
+        plotterFrame.addPlotter(plotter);
+        plotterFrame.setVisible(true);
+        IPlotterStyle pstyle = plotter.style();
+        pstyle.dataStyle().errorBarStyle().setVisible(false);
+        windowPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Window Mode Data", window, -0.5, window - 0.5);
+        plotter.region(0).plot(windowPlot);
+
+        crateCombo = new JComboBox(crateList);
+        crateCombo.addActionListener(this);
+        crateLabel = new JLabel("crate");
+        crateLabel.setLabelFor(crateCombo);
+        plotterFrame.getControlsPanel().add(crateLabel);
+        plotterFrame.getControlsPanel().add(crateCombo);
+        slotCombo = new JComboBox(slotList);
+        slotCombo.addActionListener(this);
+        slotLabel = new JLabel("slot");
+        slotLabel.setLabelFor(slotCombo);
+        plotterFrame.getControlsPanel().add(slotLabel);
+        plotterFrame.getControlsPanel().add(slotCombo);
+        channelCombo = new JComboBox(channelList);
+        channelCombo.addActionListener(this);
+        channelLabel = new JLabel("channel");
+        channelLabel.setLabelFor(channelCombo);
+        plotterFrame.getControlsPanel().add(channelLabel);
+        plotterFrame.getControlsPanel().add(channelCombo);
+        plotterFrame.pack();
+    }
+
+    @Override
+    public void endOfData() {
+        if (plotterFrame != null) {
+            plotterFrame.dispose();
+        }
+    }
+
+    @Override
+    public void process(EventHeader event) {
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+            for (RawTrackerHit 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("got hit: crate " + crate + ", slot " + slot + ", channel " + channel);
+                if (hit.getADCValues().length != window) {
+                    throw new RuntimeException("Hit has unexpected window length " + hit.getADCValues().length + ", not " + window);
+                }
+                if (testCrate && crate != plotCrate) {
+                    continue;
+                }
+                if (testSlot && slot != plotSlot) {
+                    continue;
+                }
+                if (testChannel && channel != plotChannel) {
+                    continue;
+                }
+                windowPlot.reset();
+                for (int i = 0; i < window; i++) {
+                    windowPlot.fill(i, hit.getADCValues()[i]);
+
+                }
+            }
+        }
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        String selItem;
+        selItem = (String) crateCombo.getSelectedItem();
+        if (selItem.equals("all")) {
+            testCrate = false;
+        } else {
+            testCrate = true;
+            plotCrate = Integer.decode(selItem);
+        }
+
+        selItem = (String) slotCombo.getSelectedItem();
+        if (selItem.equals("all")) {
+            testSlot = false;
+        } else {
+            testSlot = true;
+            plotSlot = Integer.decode(selItem);
+        }
+
+        selItem = (String) channelCombo.getSelectedItem();
+        if (selItem.equals("all")) {
+            testChannel = false;
+        } else {
+            testChannel = true;
+            plotChannel = Integer.decode(selItem);
+        }
+    }
+}
+

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalWindowPlotsXY.java added at 286
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowPlotsXY.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalWindowPlotsXY.java	2014-03-07 21:43:02 UTC (rev 286)
@@ -0,0 +1,178 @@
+package main.java.org.lcsim.hps.users.celentan;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.hps.monitoring.deprecated.AIDAFrame;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalWindowPlotsXY extends Driver implements ActionListener {
+
+    private String subdetectorName= "Ecal";
+    private String inputCollection;
+    private IPlotter plotter;
+    private AIDAFrame plotterFrame;
+    private AIDA aida;
+    private Detector detector;
+    private IDDecoder dec;
+    private IHistogram1D windowPlot;
+    private int window = 10;
+    private JLabel xLabel, yLabel;
+    private JComboBox xCombo;
+    private JComboBox yCombo;
+    private static final String[] xList = new String[47];
+    private static final String[] yList = new String[11];
+    private boolean testX = false;
+    private boolean testY = false;
+    private int plotX, plotY;
+
+    public EcalWindowPlotsXY() {
+        int count = 0;
+        xList[0] = "all";
+        for (int i = -23; i <= 23; i++) {
+            if (i != 0) {
+                count++;
+                xList[count] = Integer.toString(i);
+            }
+        }
+        count = 0;
+        yList[0] = "all";
+        for (int i = -5; i <= 5; i++) {
+            if (i != 0) {
+                count++;
+                yList[count] = Integer.toString(i);
+            }
+        }
+    }
+
+    public void setSubdetectorName(String subdetectorName) {
+        this.subdetectorName = subdetectorName;
+    }
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setWindow(int window) {
+        this.window = window;
+    }
+
+    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);
+        dec = subdetector.getReadout().getIDDecoder();
+
+        setupPlots();
+    }
+
+    private void setupPlots() {
+    	System.out.println("ECAL WINDOW PLOTS START");
+        if (plotterFrame != null) {
+            plotterFrame.dispose();
+        }
+
+        aida = AIDA.defaultInstance();
+        aida.tree().cd("/");
+        plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECAL Window Plots");
+
+        plotterFrame = new AIDAFrame();
+        plotterFrame.addPlotter(plotter);
+        plotterFrame.setVisible(true);
+        IPlotterStyle pstyle = plotter.style();
+        pstyle.dataStyle().errorBarStyle().setVisible(false);
+        windowPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Window Mode Data", window, -0.5, window - 0.5);
+        plotter.region(0).plot(windowPlot);
+
+        xCombo = new JComboBox(xList);
+        xCombo.addActionListener(this);
+        xLabel = new JLabel("x");
+        xLabel.setLabelFor(xCombo);
+        plotterFrame.getControlsPanel().add(xLabel);
+        plotterFrame.getControlsPanel().add(xCombo);
+        yCombo = new JComboBox(yList);
+        yCombo.addActionListener(this);
+        yLabel = new JLabel("y");
+        yLabel.setLabelFor(yCombo);
+        plotterFrame.getControlsPanel().add(yLabel);
+        plotterFrame.getControlsPanel().add(yCombo);
+        plotterFrame.pack();
+        
+        plotterFrame.show();
+    }
+
+    public void endOfData() {
+        if (plotterFrame != null) {
+            plotterFrame.dispose();
+        }
+    }
+
+    public void process(EventHeader event) {
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+            for (RawTrackerHit hit : hits) {
+                dec.setID(hit.getCellID());
+                int x = dec.getValue("ix");
+                int y = dec.getValue("iy");
+//				System.out.println("got hit: x= " + x + ", y= " + y);
+                if (hit.getADCValues().length != window) {
+                    throw new RuntimeException("Hit has unexpected window length " + hit.getADCValues().length + ", not " + window);
+                }
+                if (testX && x != plotX) {
+                    continue;
+                }
+                if (testY && y != plotY) {
+                    continue;
+                }
+                windowPlot.reset();
+                for (int i = 0; i < window; i++) {
+                    windowPlot.fill(i, hit.getADCValues()[i]);
+
+                }
+            }
+        }
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent ae) {
+        String selItem;
+        selItem = (String) xCombo.getSelectedItem();
+        if (selItem.equals("all")) {
+            testX = false;
+        } else {
+            testX = true;
+            plotX = Integer.decode(selItem);
+        }
+
+        selItem = (String) yCombo.getSelectedItem();
+        if (selItem.equals("all")) {
+            testY = false;
+        } else {
+            testY = true;
+            plotY = Integer.decode(selItem);
+        }
+    }
+}
SVNspam 0.1