hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
diff -N EcalEventMonitor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EcalEventMonitor.java 30 Apr 2012 18:46:59 -0000 1.1
@@ -0,0 +1,113 @@
+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.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalEventMonitor extends Driver {
+
+ String subdetectorName = "Ecal";
+ String inputCollectionName = "EcalReadoutHits";
+ AIDA aida = AIDA.defaultInstance();
+ IPlotter plotter;
+ IHistogram2D hitPlot;
+ IDDecoder dec;
+ Detector detector;
+ int eventRefreshRate = 1;
+ int eventn = 0;
+
+ public EcalEventMonitor() {
+ }
+
+ public void setEventRefreshRate(int eventRefreshRate) {
+ this.eventRefreshRate = eventRefreshRate;
+ }
+
+ public void setInputCollectionName(String inputCollectionName) {
+ this.inputCollectionName = inputCollectionName;
+ }
+
+ public void setSubdetectorName(String subdetectorName) {
+ this.subdetectorName = subdetectorName;
+ }
+
+ protected void detectorChanged(Detector detector) {
+ this.detector = detector;
+
+ if (detector.getSubdetector(subdetectorName) == null) {
+ throw new RuntimeException("There is no subdetector called " + subdetectorName + " in this detector");
+ }
+
+ // Cache the IDDecoder for the ECal.
+ dec = detector.getSubdetector(subdetectorName).getReadout().getIDDecoder();
+
+ // Setup the plotter.
+ plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal Event Monitor");
+
+ // Setup plots.
+ aida.tree().cd("/");
+ hitPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollectionName + " : Mean ADC Value", 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(hitPlot);
+ ((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, inputCollectionName)) {
+ if (++eventn % eventRefreshRate != 0) {
+ return;
+ }
+ hitPlot.reset();
+ List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollectionName);
+ for (RawCalorimeterHit hit : hits) {
+ dec.setID(hit.getCellID());
+ hitPlot.fill(dec.getValue("ix"), dec.getValue("iy"), hit.getAmplitude());
+ }
+ }
+ if (event.hasCollection(RawTrackerHit.class, inputCollectionName)) {
+ if (++eventn % eventRefreshRate != 0) {
+ return;
+ }
+ hitPlot.reset();
+ List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionName);
+ for (RawTrackerHit hit : hits) {
+ dec.setID(hit.getCellID());
+ double mean = 0;
+ for (int i = 0; i < hit.getADCValues().length; i++) {
+ mean += hit.getADCValues()[i];
+ }
+ mean /= hit.getADCValues().length;
+ hitPlot.fill(dec.getValue("ix"), dec.getValue("iy"), mean);
+ }
+ }
+ }
+
+ public void endOfData() {
+ if (plotter != null) {
+ plotter.hide();
+ plotter.destroyRegions();
+ }
+ if (hitPlot != null) {
+ hitPlot.reset();
+ }
+ }
+}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
diff -u -r1.1 -r1.2
--- EcalMonitoringPlots.java 29 Apr 2012 23:17:24 -0000 1.1
+++ EcalMonitoringPlots.java 30 Apr 2012 18:46:59 -0000 1.2
@@ -18,8 +18,8 @@
public class EcalMonitoringPlots extends Driver implements Resettable {
- String ecalName = "Ecal";
- String rawCalorimeterHitCollectionName = "EcalRawHits";
+ String subdetectorName = "Ecal";
+ String inputCollectionName = "EcalReadoutHits";
AIDA aida = AIDA.defaultInstance();
IPlotter plotter;
IHistogram2D hitCountPlot;
@@ -30,31 +30,31 @@
public EcalMonitoringPlots() {
}
- public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) {
- this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName;
+ public void setInputCollectionName(String inputCollectionName) {
+ this.inputCollectionName = inputCollectionName;
}
- public void setEcalName(String ecalName) {
- this.ecalName = ecalName;
+ public void setSubdetectorName(String subdetectorName) {
+ this.subdetectorName = subdetectorName;
}
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");
+ if (detector.getSubdetector(subdetectorName) == null) {
+ throw new RuntimeException("There is no subdetector called " + subdetectorName + " in this detector");
}
// Cache the IDDecoder for the ECal.
- dec = detector.getSubdetector(ecalName).getReadout().getIDDecoder();
+ dec = detector.getSubdetector(subdetectorName).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);
+ hitCountPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollectionName + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
// Create the plotter regions.
plotter.createRegion();
@@ -69,16 +69,16 @@
}
public void process(EventHeader event) {
- if (event.hasCollection(RawCalorimeterHit.class, rawCalorimeterHitCollectionName)) {
- List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCalorimeterHitCollectionName);
+ if (event.hasCollection(RawCalorimeterHit.class, inputCollectionName)) {
+ List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollectionName);
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);
+ if (event.hasCollection(RawTrackerHit.class, inputCollectionName)) {
+ List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionName);
for (RawTrackerHit hit : hits) {
dec.setID(hit.getCellID());
hitCountPlot.fill(dec.getValue("ix"), dec.getValue("iy"));
hps-java/src/main/resources/org/lcsim/hps/steering
diff -u -r1.8 -r1.9
--- TestRunMonitoring.lcsim 29 Apr 2012 23:27:26 -0000 1.8
+++ TestRunMonitoring.lcsim 30 Apr 2012 18:46:59 -0000 1.9
@@ -12,15 +12,15 @@
<driver name="RawTrackerHitMaker"/>
<driver name="EcalDaqPlots"/>
<driver name="EcalMonitoringPlots"/>
+ <driver name="EcalEventMonitor"/>
<driver name="SVTOccupancyPlots"/>
</execute>
<drivers>
<driver name="EcalDaqPlots" type="org.lcsim.hps.monitoring.ecal.EcalDaqPlots">
- <subdetectorName>Ecal</subdetectorName>
- <inputCollection>EcalReadoutHits</inputCollection>
</driver>
- <driver name="EcalMonitoringPlots" type="org.lcsim.hps.monitoring.ecal.EcalMonitoringPlots">
- <rawCalorimeterHitCollectionName>EcalReadoutHits</rawCalorimeterHitCollectionName>
+ <driver name="EcalMonitoringPlots" type="org.lcsim.hps.monitoring.ecal.EcalMonitoringPlots"/>
+ <driver name="EcalEventMonitor" type="org.lcsim.hps.monitoring.ecal.EcalEventMonitor">
+ <eventRefreshRate>10</eventRefreshRate>
</driver>
<driver name="SVTOccupancyPlots" type="org.lcsim.hps.monitoring.svt.SensorOccupancyPlotsDriver">
<rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>
@@ -29,8 +29,7 @@
<driver name="SVTSetupDriver"
type="org.lcsim.hps.recon.tracking.HPSSVTSensorSetup">
</driver>
- <driver name="EventMarkerDriver"
- type="org.lcsim.job.EventMarkerDriver">
+ <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
<eventInterval>1</eventInterval>
</driver>
<driver name="HPSSVTDAQMaps" type="org.lcsim.hps.recon.tracking.HPSSVTDAQMaps"/>