Commit in hps-java/src/main/java/org/lcsim/hps/monitoring/ecal on MAIN | |||
EcalDaqPlots.java | +131 | added 1.1 | |
EcalMonitoringPlots.java | +105 | added 1.1 | |
EcalPedestalPlots.java | +219 | added 1.1 | |
EcalWindowPlots.java | +201 | added 1.1 | |
EcalWindowPlotsXY.java | +181 | added 1.1 | |
+837 |
moved from monitoring pkg
diff -N EcalDaqPlots.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalDaqPlots.java 29 Apr 2012 23:17:24 -0000 1.1 @@ -0,0 +1,131 @@
+package org.lcsim.hps.monitoring.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.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.Resettable; +import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +public class EcalDaqPlots extends Driver implements Resettable { + + private String subdetectorName; + private String inputCollection; + private HPSEcalDaqIDConverter idMap; + private IPlotter plotter; + private AIDA aida; + private Detector detector; + private List<IHistogram1D> plots; + + 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); + idMap = new HPSEcalDaqIDConverter(); + idMap.fillDaqCellMap(subdetector); + + 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 " + 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 = idMap.physicalToDaqID(hit.getCellID()); + int crate = HPSEcalDaqIDConverter.getCrate(daqId); + int slot = HPSEcalDaqIDConverter.getSlot(daqId); + int channel = HPSEcalDaqIDConverter.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); + } + } + if (event.hasCollection(RawTrackerHit.class, inputCollection)) { + List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection); + for (RawTrackerHit hit : hits) { + Long daqId = idMap.physicalToDaqID(hit.getCellID()); + int crate = HPSEcalDaqIDConverter.getCrate(daqId); + int slot = HPSEcalDaqIDConverter.getSlot(daqId); + int channel = HPSEcalDaqIDConverter.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); + } + } + } +}
diff -N EcalMonitoringPlots.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalMonitoringPlots.java 29 Apr 2012 23:17:24 -0000 1.1 @@ -0,0 +1,105 @@
+package org.lcsim.hps.monitoring.ecal; + +import hep.aida.IHistogram2D; +import hep.aida.IPlotter; +import hep.aida.IPlotterStyle; +import hep.aida.ref.plotter.PlotterRegion; + +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.hps.monitoring.Resettable; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +public class EcalMonitoringPlots extends Driver implements Resettable { + + String ecalName = "Ecal"; + String rawCalorimeterHitCollectionName = "EcalRawHits"; + AIDA aida = AIDA.defaultInstance(); + IPlotter plotter; + IHistogram2D hitCountPlot; + IDDecoder dec; + Detector detector; + int eventn = 0; + + public EcalMonitoringPlots() { + } + + public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) { + this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + protected void detectorChanged(Detector detector) { + + this.detector = detector; + + if (detector.getSubdetector(ecalName) == null) { + throw new RuntimeException("There is no subdetector called " + ecalName + " in this detector"); + } + + // Cache the IDDecoder for the ECal. + dec = detector.getSubdetector(ecalName).getReadout().getIDDecoder(); + + // Setup the plotter. + plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal Monitoring Plots"); + + // Setup plots. + aida.tree().cd("/"); + hitCountPlot = aida.histogram2D(detector.getDetectorName() + " : " + rawCalorimeterHitCollectionName + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5); + + // Create the plotter regions. + plotter.createRegion(); + 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(hitCountPlot); + ((PlotterRegion) plotter.region(0)).getPlot().setAllowUserInteraction(false); + ((PlotterRegion) plotter.region(0)).getPlot().setAllowPopupMenus(false); + plotter.show(); + } + + public void process(EventHeader event) { + if (event.hasCollection(RawCalorimeterHit.class, rawCalorimeterHitCollectionName)) { + List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName); + for (RawCalorimeterHit hit : hits) { + dec.setID(hit.getCellID()); + hitCountPlot.fill(dec.getValue("ix"), dec.getValue("iy")); + } + ++eventn; + } + if (event.hasCollection(RawTrackerHit.class, rawCalorimeterHitCollectionName)) { + List<RawTrackerHit> hits = event.get(RawTrackerHit.class, rawCalorimeterHitCollectionName); + for (RawTrackerHit hit : hits) { + dec.setID(hit.getCellID()); + hitCountPlot.fill(dec.getValue("ix"), dec.getValue("iy")); + } + ++eventn; + } + } + + public void endOfData() { + if (plotter != null) { + plotter.hide(); + plotter.destroyRegions(); + } + if (hitCountPlot != null) { + hitCountPlot.reset(); + } + } + + public void reset() { + plotter.hide(); + hitCountPlot.reset(); + detectorChanged(detector); + } +}
\ No newline at end of file
diff -N EcalPedestalPlots.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalPedestalPlots.java 29 Apr 2012 23:17:24 -0000 1.1 @@ -0,0 +1,219 @@
+package org.lcsim.hps.monitoring.ecal; + +import hep.aida.ICloud1D; +import hep.aida.IHistogram2D; +import hep.aida.IPlotter; +import hep.aida.IPlotterStyle; +import hep.aida.ref.plotter.PlotterRegion; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.*; + +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.compact.Subdetector; +import org.lcsim.hps.monitoring.AIDAFrame; +import org.lcsim.hps.monitoring.Resettable; +import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +public class EcalPedestalPlots extends Driver implements Resettable, ActionListener { + + private String subdetectorName; + private Subdetector subdetector; + private String inputCollection; + private HPSEcalDaqIDConverter idMap; + private IPlotter plotter; + private AIDA aida = AIDA.defaultInstance(); + private AIDAFrame plotterFrame; + private Detector detector; + private IDDecoder dec; + private List<ICloud1D> plotsList; + private IHistogram2D meanPlot; + private IHistogram2D sigmaPlot; + private ICloud1D[][] plots = new ICloud1D[47][11]; + private JLabel xLabel, yLabel; + private JComboBox xCombo; + private JComboBox yCombo; + private static final Integer[] xList = new Integer[46]; + private static final Integer[] yList = new Integer[10]; + + public EcalPedestalPlots() { + 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 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 = detector.getSubdetector(subdetectorName); + idMap = new HPSEcalDaqIDConverter(); + idMap.fillDaqCellMap(subdetector); + dec = subdetector.getReadout().getIDDecoder(); + + setupPlots(); + } + + private void setupPlots() { + // Setup the plotter. + plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal Pedestal Plots"); + plotterFrame = new AIDAFrame(plotter); + plotterFrame.setVisible(true); + + plotsList = new ArrayList<ICloud1D>(); + aida = AIDA.defaultInstance(); + aida.tree().cd("/"); + sigmaPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Sigma", 47, -23.5, 23.5, 11, -5.5, 5.5); + meanPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Mean", 47, -23.5, 23.5, 11, -5.5, 5.5); + + for (int x = -23; x <= 23; x++) { // slot + for (int y = -5; y <= 5; y++) { // crate + //System.out.println("creating plot: " + "ECAL: Crate " + j + "; Slot " + i + " in region " + region); +// IHistogram1D hist = aida.histogram1D("ECAL: x=" + i + "; y=" + j, 1000, 0, 16); + plots[x + 23][y + 5] = aida.cloud1D("ECAL: x=" + x + "; y=" + y); + plotsList.add(plots[x + 23][y + 5]); + } + } + + // Create the plotter regions. + plotter.createRegions(1, 3); + + 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); + + JMenuBar menuBar = plotterFrame.getMenubar(); + JMenu menu = new JMenu("File"); + JMenuItem item = new JMenuItem("meeg"); + menu.add(item); + menuBar.add(menu); + + + plotterFrame.pack(); + + plotter.style().statisticsBoxStyle().setVisible(false); + plotter.style().zAxisStyle().setParameter("allowZeroSuppression", "true"); + IPlotterStyle style = plotter.region(0).style(); + style.setParameter("hist2DStyle", "colorMap"); + style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + style = plotter.region(1).style(); + style.setParameter("hist2DStyle", "colorMap"); + style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + plotter.region(0).plot(sigmaPlot); + plotter.region(1).plot(meanPlot); + plotter.region(2).plot(plots[17][0]); + ((PlotterRegion) plotter.region(0)).getPlot().setAllowUserInteraction(false); + ((PlotterRegion) plotter.region(0)).getPlot().setAllowPopupMenus(false); + + ((PlotterRegion) plotter.region(1)).getPlot().setAllowUserInteraction(false); + ((PlotterRegion) plotter.region(1)).getPlot().setAllowPopupMenus(false); + } + + public void endOfData() { + if (plotter != null) { + plotter.hide(); + } + } + + public void reset() { + if (plotter != null) { + plotter.hide(); + plotter.destroyRegions(); + for (ICloud1D plot : plotsList) { + plot.reset(); + } + detectorChanged(detector); + } + } + + 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"); + for (int i = 0; i < hit.getADCValues().length; i++) { + plots[x + 23][y + 5].fill(hit.getADCValues()[i]); + } + } + } + + if (event.hasCollection(RawCalorimeterHit.class, inputCollection)) { + List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollection); + for (RawCalorimeterHit hit : hits) { + dec.setID(hit.getCellID()); + int x = dec.getValue("ix"); + int y = dec.getValue("iy"); + plots[x + 23][y + 5].fill(hit.getAmplitude()); + } + } + + sigmaPlot.reset(); + meanPlot.reset(); + for (int x = -23; x <= 23; x++) { // slot + for (int y = -5; y <= 5; y++) { // crate + sigmaPlot.fill(x, y, plots[x + 23][y + 5].rms()); + meanPlot.fill(x, y, plots[x + 23][y + 5].mean()); + //System.out.println("creating plot: " + "ECAL: Crate " + j + "; Slot " + i + " in region " + region); +// IHistogram1D hist = aida.histogram1D("ECAL: x=" + i + "; y=" + j, 1000, 0, 16); + } + } + } + + @Override + public void actionPerformed(ActionEvent ae) { + Integer x, y; + x = (Integer) xCombo.getSelectedItem(); + y = (Integer) yCombo.getSelectedItem(); + plotter.region(2).clear(); + plotter.region(2).plot(plots[x + 23][y + 5]); + ((PlotterRegion) plotter.region(2)).getPlot().setAllowUserInteraction(false); + ((PlotterRegion) plotter.region(2)).getPlot().setAllowPopupMenus(false); + } +}
diff -N EcalWindowPlots.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalWindowPlots.java 29 Apr 2012 23:17:24 -0000 1.1 @@ -0,0 +1,201 @@
+package org.lcsim.hps.monitoring.ecal; + +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.compact.Subdetector; +import org.lcsim.hps.monitoring.AIDAFrame; +import org.lcsim.hps.monitoring.Resettable; +import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +public class EcalWindowPlots extends Driver implements Resettable, ActionListener { + + private String subdetectorName; + private String inputCollection; + private HPSEcalDaqIDConverter idMap; + private IPlotter plotter; + private AIDAFrame plotterFrame; + private AIDA aida; + private Detector detector; + private IHistogram1D windowPlot; + private int window = 10; + 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 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); + idMap = new HPSEcalDaqIDConverter(); + idMap.fillDaqCellMap(subdetector); + + setupPlots(); + } + + private void setupPlots() { + if (plotterFrame != null) { + plotterFrame.dispose(); + } + + aida = AIDA.defaultInstance(); + aida.tree().cd("/"); + plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECAL Window Plots"); + + plotterFrame = new AIDAFrame(plotter); + plotterFrame.setVisible(true); + IPlotterStyle pstyle = plotter.style(); + pstyle.dataStyle().errorBarStyle().setVisible(false); + windowPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 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(); + } + + public void endOfData() { + } + + public void reset() { + 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) { + Long daqId = idMap.physicalToDaqID(hit.getCellID()); + int crate = HPSEcalDaqIDConverter.getCrate(daqId); + int slot = HPSEcalDaqIDConverter.getSlot(daqId); + int channel = HPSEcalDaqIDConverter.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); + } + } +}
diff -N EcalWindowPlotsXY.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalWindowPlotsXY.java 29 Apr 2012 23:17:24 -0000 1.1 @@ -0,0 +1,181 @@
+package org.lcsim.hps.monitoring.ecal; + +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.AIDAFrame; +import org.lcsim.hps.monitoring.Resettable; +import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +public class EcalWindowPlotsXY extends Driver implements Resettable, ActionListener { + + private String subdetectorName; + private String inputCollection; + private HPSEcalDaqIDConverter idMap; + 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); + idMap = new HPSEcalDaqIDConverter(); + idMap.fillDaqCellMap(subdetector); + dec = subdetector.getReadout().getIDDecoder(); + + setupPlots(); + } + + private void setupPlots() { + if (plotterFrame != null) { + plotterFrame.dispose(); + } + + aida = AIDA.defaultInstance(); + aida.tree().cd("/"); + plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECAL Window Plots"); + + plotterFrame = new AIDAFrame(plotter); + plotterFrame.setVisible(true); + IPlotterStyle pstyle = plotter.style(); + pstyle.dataStyle().errorBarStyle().setVisible(false); + windowPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 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(); + } + + public void endOfData() { + } + + public void reset() { + 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); + } + } +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1