18 modified files
hps-java/src/main/java/org/lcsim/hps/users/meeg
diff -u -r1.8 -r1.9
--- EvioFileReader.java 26 Apr 2012 21:16:50 -0000 1.8
+++ EvioFileReader.java 27 Apr 2012 22:13:52 -0000 1.9
@@ -53,8 +53,9 @@
} else if (args[i].equalsIgnoreCase("-v")) {
debug = true;
} else if (args[i].equalsIgnoreCase("-s")) {
- steeringFile = new String(args[++i]);
is = new FileInputStream(steeringFile);
+ } else if (args[i].equalsIgnoreCase("-r")) {
+ steeringFile = new String(args[++i]);
} else if (args[i].equalsIgnoreCase("-d")) {
detectorName = new String(args[++i]);
} else if (args[i].equalsIgnoreCase("-m")) {
@@ -101,21 +102,24 @@
// Loop until event source is exhausted.
//int eventCount = 0;
- EvioEvent evioEvent = reader.parseNextEvent();
- while (evioEvent != null) {
+ do {
+ EvioEvent evioEvent = null;
EventHeader lcsimEvent = null;
- // Create LCSim event from EVIO data.
-
do {
- evioEvent = reader.parseNextEvent();
- } while (!eventBuilder.isPhysicsEvent(evioEvent));
+ try {
+ evioEvent = reader.parseNextEvent();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ } while (evioEvent == null || !eventBuilder.isPhysicsEvent(evioEvent));
+
+ // Create LCSim event from EVIO data.
lcsimEvent = eventBuilder.makeLCSimEvent(evioEvent);
// Supply record to Driver Adapter.
driverAdapter.recordSupplied(new RecordSuppliedEvent(new Object(), lcsimEvent));
- evioEvent = reader.parseNextEvent();
Thread.currentThread().sleep(delay);
- }
+ } while (reader.getNumEventsRemaining() != 0);
// Cleanup.
driverAdapter.finish(null);
reader.close();
hps-java/src/main/java/org/lcsim/hps/users/meeg
diff -u -r1.2 -r1.3
--- HPSEcalAnalogPrintDriver.java 10 Apr 2012 01:00:13 -0000 1.2
+++ HPSEcalAnalogPrintDriver.java 27 Apr 2012 22:13:52 -0000 1.3
@@ -17,7 +17,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalAnalogPrintDriver.java,v 1.2 2012/04/10 01:00:13 meeg Exp $
+ * @version $Id: HPSEcalAnalogPrintDriver.java,v 1.3 2012/04/27 22:13:52 meeg Exp $
*/
public class HPSEcalAnalogPrintDriver extends Driver {
@@ -78,11 +78,6 @@
if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) {
//outputStream.println("Reading RawTrackerHits from event " + event.getEventNumber());
List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
-
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!hits.isEmpty() && !CalorimeterHit.class.isInstance(hits.get(0))) {
- return;
- }
for (CalorimeterHit hit : hits) {
dec.setID(hit.getCellID());
outputStream.printf("%d\t%d\t%f\t%f\n", dec.getValue("ix"), dec.getValue("iy"), hit.getTime(), hit.getRawEnergy());
hps-java/src/main/java/org/lcsim/hps/users/meeg
diff -u -r1.4 -r1.5
--- HPSEcalDigitalPrintDriver.java 10 Apr 2012 01:00:13 -0000 1.4
+++ HPSEcalDigitalPrintDriver.java 27 Apr 2012 22:13:52 -0000 1.5
@@ -17,7 +17,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalDigitalPrintDriver.java,v 1.4 2012/04/10 01:00:13 meeg Exp $
+ * @version $Id: HPSEcalDigitalPrintDriver.java,v 1.5 2012/04/27 22:13:52 meeg Exp $
*/
public class HPSEcalDigitalPrintDriver extends Driver {
@@ -80,12 +80,6 @@
// Get the list of ECal hits.
if (event.hasCollection(RawCalorimeterHit.class, ecalCollectionName)) {
List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, ecalCollectionName);
-
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!hits.isEmpty() && !RawCalorimeterHit.class.isInstance(hits.get(0))) {
- return;
- }
-
//outputStream.println("Reading RawCalorimeterHit from event " + event.getEventNumber());
for (RawCalorimeterHit hit : hits) {
dec.setID(hit.getCellID());
hps-java/src/main/java/org/lcsim/hps/users/meeg
diff -u -r1.2 -r1.3
--- HPSEcalRawTrackerHitPrintDriver.java 10 Apr 2012 01:00:13 -0000 1.2
+++ HPSEcalRawTrackerHitPrintDriver.java 27 Apr 2012 22:13:52 -0000 1.3
@@ -17,7 +17,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalRawTrackerHitPrintDriver.java,v 1.2 2012/04/10 01:00:13 meeg Exp $
+ * @version $Id: HPSEcalRawTrackerHitPrintDriver.java,v 1.3 2012/04/27 22:13:52 meeg Exp $
*/
public class HPSEcalRawTrackerHitPrintDriver extends Driver {
@@ -76,11 +76,6 @@
if (event.hasCollection(RawTrackerHit.class, ecalCollectionName)) {
//outputStream.println("Reading RawTrackerHits from event " + event.getEventNumber());
List<RawTrackerHit> hits = event.get(RawTrackerHit.class, ecalCollectionName);
-
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!hits.isEmpty() && !RawTrackerHit.class.isInstance(hits.get(0))) {
- return;
- }
for (RawTrackerHit hit : hits) {
dec.setID(hit.getCellID());
outputStream.printf("%d\t%d\t%d\t%d\n", dec.getValue("ix"), dec.getValue("iy"), hit.getTime(), hit.getADCValues().length);
hps-java/src/main/java/org/lcsim/hps/users/meeg
diff -u -r1.1 -r1.2
--- HPSGenericRawTrackerHitPrintDriver.java 10 Apr 2012 01:00:13 -0000 1.1
+++ HPSGenericRawTrackerHitPrintDriver.java 27 Apr 2012 22:13:52 -0000 1.2
@@ -14,7 +14,8 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSGenericRawTrackerHitPrintDriver.java,v 1.1 2012/04/10 01:00:13 meeg Exp $
+ * @version $Id: HPSGenericRawTrackerHitPrintDriver.java,v 1.1 2012/04/10
+ * 01:00:13 meeg Exp $
*/
public class HPSGenericRawTrackerHitPrintDriver extends Driver {
@@ -46,14 +47,9 @@
//outputStream.println("Reading RawTrackerHits from event " + event.getEventNumber());
List<List<RawTrackerHit>> listOfLists = event.get(RawTrackerHit.class);
for (List<RawTrackerHit> hits : listOfLists) {
-
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!hits.isEmpty() && !RawTrackerHit.class.isInstance(hits.get(0))) {
- return;
- }
- outputStream.printf("List with %d RawTrackerHits:\n", hits.size());
+ outputStream.printf("List with %d RawTrackerHits:\n", hits.size());
for (RawTrackerHit hit : hits) {
- outputStream.printf("%d\t%d\n", hit.getCellID() , hit.getADCValues().length);
+ outputStream.printf("%d\t%d\n", hit.getCellID(), hit.getADCValues().length);
for (int i = 0; i < hit.getADCValues().length; i++) {
outputStream.printf("%d\n", hit.getADCValues()[i]);
}
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.13 -r1.14
--- LCSimTestRunEventBuilder.java 26 Apr 2012 21:16:50 -0000 1.13
+++ LCSimTestRunEventBuilder.java 27 Apr 2012 22:13:52 -0000 1.14
@@ -109,7 +109,8 @@
EventHeader lcsimEvent = new BaseLCSimEvent(0, eventID[0], detector.getDetectorName());
// Make RawCalorimeterHit collection, combining top and bottom section of ECal into one list.
- ecalReader.makeHits(evioEvent, lcsimEvent);
+ if (!ecalReader.makeHits(evioEvent, lcsimEvent))
+ System.out.println();
// Make SVT RawTrackerHits
svtReader.makeHits(evioEvent, lcsimEvent);
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.6 -r1.7
--- TestRunReconToEvio.java 7 Apr 2012 00:07:24 -0000 1.6
+++ TestRunReconToEvio.java 27 Apr 2012 22:13:52 -0000 1.7
@@ -2,19 +2,15 @@
import java.io.IOException;
-import org.jlab.coda.jevio.DataType;
-import org.jlab.coda.jevio.EventBuilder;
-import org.jlab.coda.jevio.EventWriter;
-import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.*;
import org.lcsim.event.EventHeader;
import org.lcsim.util.Driver;
/**
- * This class takes raw data generated from MC and converts
- * it to EVIO. The goal is to make this look like data
- * which will come off the actual ET ring during the
- * test run.
- *
+ * This class takes raw data generated from MC and converts it to EVIO. The goal
+ * is to make this look like data which will come off the actual ET ring during
+ * the test run.
+ *
* @author Jeremy McCormick <[log in to unmask]>
*/
public class TestRunReconToEvio extends Driver {
@@ -95,6 +91,18 @@
}
private void writeEvioEvent() {
+ EvioBank eventIDBank = new EvioBank(EventConstants.EVENTID_BANK_TAG, DataType.UINT32, 0);
+ int[] eventID = new int[3];
+ eventID[0] = eventsWritten;
+ eventID[1] = 0; //trigger type
+ eventID[2] = 0; //status
+
+ try {
+ eventIDBank.appendIntData(eventID);
+ builder.addChild(builder.getEvent(), eventIDBank);
+ } catch (EvioException e) {
+ throw new RuntimeException(e);
+ }
builder.setAllHeaderLengths();
try {
writer.writeEvent(builder.getEvent());
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.2 -r1.3
--- SVTEvioReader.java 26 Apr 2012 21:16:50 -0000 1.2
+++ SVTEvioReader.java 27 Apr 2012 22:13:52 -0000 1.3
@@ -21,7 +21,7 @@
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: SVTEvioReader.java,v 1.2 2012/04/26 21:16:50 meeg Exp $
+ * @version $Id: SVTEvioReader.java,v 1.3 2012/04/27 22:13:52 meeg Exp $
*
*/
public class SVTEvioReader extends EvioReader {
@@ -87,7 +87,7 @@
// Get the hybrid temperature data associated with this FPGA
int[] temperatureData = new int[6];
- System.arraycopy(data, 0, temperatureData, 0, 6);
+ System.arraycopy(data, 1, temperatureData, 0, 6);
if(debug){
System.out.println(this.getClass().getSimpleName() + ": The temperatures are: ");
@@ -98,9 +98,9 @@
}
// Get all of the samples
- int sampleLength = data.length - temperatureData.length - 1; // Tail length
+ int sampleLength = data.length - temperatureData.length - 2; // Tail length
int[] allSamples = new int[sampleLength];
- System.arraycopy(data, 6, allSamples, 0, sampleLength);
+ System.arraycopy(data, 7, allSamples, 0, sampleLength);
if(debug){
for(int index = 0; index < allSamples.length; index++){
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.5 -r1.6
--- ECalEvioReader.java 26 Apr 2012 21:16:50 -0000 1.5
+++ ECalEvioReader.java 27 Apr 2012 22:13:52 -0000 1.6
@@ -17,7 +17,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalEvioReader.java,v 1.5 2012/04/26 21:16:50 meeg Exp $
+ * @version $Id: ECalEvioReader.java,v 1.6 2012/04/27 22:13:52 meeg Exp $
*/
public class ECalEvioReader extends EvioReader {
// Names of subdetectors.
@@ -71,12 +71,12 @@
BaseStructureHeader header = bank.getHeader();
int crateBankTag = header.getTag();
if (crateBankTag == EventConstants.ECAL_TOP_BANK_TAG || crateBankTag == EventConstants.ECAL_BOTTOM_BANK_TAG) {
+ foundHits = true;
if (bank.getChildCount() > 0) {
if (debug) {
System.out.println("ECal bank tag: " + header.getTag() + "; childCount: " + bank.getChildCount());
}
for (BaseStructure slotBank : bank.getChildren()) {
- foundHits = true;
CompositeData cdata = null;
try {
cdata = slotBank.getCompositeData();
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.8 -r1.9
--- EventConstants.java 26 Apr 2012 21:16:50 -0000 1.8
+++ EventConstants.java 27 Apr 2012 22:13:53 -0000 1.9
@@ -11,6 +11,7 @@
public static final int END_EVENT_TAG = 20;
//event type tag
public static final int EVENTID_BANK_TAG = 0xC000;
+ public static final int EVENT_BANK_NUM = 0xCC;
// These correspond to ROC (readout crate) IDs from the DAQ.
// TODO Double check that these match the actual values.
public static final int ECAL_TOP_BANK_TAG = 0x1;
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.7 -r1.8
--- TestRunTriggeredReconToEvio.java 26 Apr 2012 21:16:50 -0000 1.7
+++ TestRunTriggeredReconToEvio.java 27 Apr 2012 22:13:53 -0000 1.8
@@ -6,20 +6,16 @@
import java.util.List;
import java.util.Queue;
-import org.jlab.coda.jevio.DataType;
-import org.jlab.coda.jevio.EventBuilder;
-import org.jlab.coda.jevio.EventWriter;
-import org.jlab.coda.jevio.EvioException;
+import org.jlab.coda.jevio.*;
import org.lcsim.event.EventHeader;
import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter;
import org.lcsim.util.Driver;
/**
- * This class takes raw data generated from MC and converts
- * it to EVIO. The goal is to make this look like data
- * which will come off the actual ET ring during the
- * test run.
- *
+ * This class takes raw data generated from MC and converts it to EVIO. The goal
+ * is to make this look like data which will come off the actual ET ring during
+ * the test run.
+ *
* @author Jeremy McCormick <[log in to unmask]>
*/
public class TestRunTriggeredReconToEvio extends Driver {
@@ -103,7 +99,7 @@
protected void process(EventHeader event) {
if (triggerBit) {
// Make a new EVIO event.
- EventBuilder builder = new EventBuilder(EventConstants.PHYSICS_EVENT_TAG, DataType.BANK, event.getEventNumber());
+ EventBuilder builder = new EventBuilder(EventConstants.PHYSICS_EVENT_TAG, DataType.BANK, EventConstants.EVENT_BANK_NUM);
builderQueue.add(new QueuedEtEvent(builder, writers.size()));
triggerBit = false;
}
@@ -138,6 +134,19 @@
}
private void writeEvioEvent(EventBuilder builder) {
+ EvioBank eventIDBank = new EvioBank(EventConstants.EVENTID_BANK_TAG, DataType.UINT32, 0);
+ int[] eventID = new int[3];
+ eventID[0] = eventsWritten;
+ eventID[1] = 0; //trigger type
+ eventID[2] = 0; //status
+
+ try {
+ eventIDBank.appendIntData(eventID);
+ builder.addChild(builder.getEvent(), eventIDBank);
+ } catch (EvioException e) {
+ throw new RuntimeException(e);
+ }
+
builder.setAllHeaderLengths();
System.out.printf("Writing event with %d bytes\n", builder.getEvent().getTotalBytes());
try {
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.4 -r1.5
--- HPSSVTDataBuffer.java 25 Apr 2012 05:11:37 -0000 1.4
+++ HPSSVTDataBuffer.java 27 Apr 2012 22:13:53 -0000 1.5
@@ -13,7 +13,7 @@
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSVTDataBuffer.java,v 1.4 2012/04/25 05:11:37 omoreno Exp $
+ * @version $Id: HPSSVTDataBuffer.java,v 1.5 2012/04/27 22:13:53 meeg Exp $
*/
public class HPSSVTDataBuffer {
@@ -23,7 +23,7 @@
// Singleton
private static final HPSSVTDataBuffer instance = new HPSSVTDataBuffer();
- int[] header = new int[6];
+ int[] header = new int[7];
int temp = 23; // C
int nErrors = 0;
@@ -90,27 +90,28 @@
// If the FPGA data block is empty, add the header information
if(instance.fpgaToData.get(fpga).isEmpty()){
+ header[0] = 0; //TODO: figure out what this is actually supposed to be - probably event number
// Insert the temperature information. All temperatures are currently
// set to 23 C
- header[0] = (header[0] &= ~TEMP_MASK) | (temp & TEMP_MASK);
- header[0] = (header[0] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
-
header[1] = (header[1] &= ~TEMP_MASK) | (temp & TEMP_MASK);
header[1] = (header[1] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
header[2] = (header[2] &= ~TEMP_MASK) | (temp & TEMP_MASK);
header[2] = (header[2] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
-
+
header[3] = (header[3] &= ~TEMP_MASK) | (temp & TEMP_MASK);
header[3] = (header[3] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
-
+
header[4] = (header[4] &= ~TEMP_MASK) | (temp & TEMP_MASK);
header[4] = (header[4] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
-
+
header[5] = (header[5] &= ~TEMP_MASK) | (temp & TEMP_MASK);
header[5] = (header[5] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
+ header[6] = (header[6] &= ~TEMP_MASK) | (temp & TEMP_MASK);
+ header[6] = (header[6] &= ~(TEMP_MASK << 16)) | ((temp & TEMP_MASK) << 16);
+
for(int index = 0; index < header.length; index++) fpgaToData.get(fpga).add(header[index]);
}
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.4 -r1.5
--- EcalMonitoringPlots.java 13 Apr 2012 00:08:22 -0000 1.4
+++ EcalMonitoringPlots.java 27 Apr 2012 22:13:53 -0000 1.5
@@ -9,88 +9,96 @@
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 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 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 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();
- }
-
+ 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) {
- 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;
- }
-
- public void endOfData() {
- if (plotter != null) {
- plotter.hide();
- plotter.destroyRegions();
- }
- if (hitCountPlot != null)
- hitCountPlot.reset();
- }
-
- public void reset() {
- plotter.hide();
- hitCountPlot.reset();
- detectorChanged(detector);
- }
+ 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
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.12 -r1.13
--- SensorOccupancyPlotsDriver.java 13 Apr 2012 00:06:55 -0000 1.12
+++ SensorOccupancyPlotsDriver.java 27 Apr 2012 22:13:53 -0000 1.13
@@ -21,156 +21,158 @@
import org.lcsim.util.aida.AIDA;
/**
- * This Driver makes plots of sensor occupancies across a run. It is intended to be
- * used with the monitoring system. It will currently only run on a test run detector,
- * as the number of sensors, and hence plotter regions, is hardcoded to 20.
- *
+ * This Driver makes plots of sensor occupancies across a run. It is intended to
+ * be used with the monitoring system. It will currently only run on a test run
+ * detector, as the number of sensors, and hence plotter regions, is hardcoded
+ * to 20.
+ *
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: SensorOccupancyPlotsDriver.java,v 1.12 2012/04/13 00:06:55 jeremy Exp $
+ * @version $Id: SensorOccupancyPlotsDriver.java,v 1.12 2012/04/13 00:06:55
+ * jeremy Exp $
*
*/
public class SensorOccupancyPlotsDriver extends Driver implements Resettable {
- private String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits";
- private String trackerName = "Tracker";
-
- private AIDA aida = AIDA.defaultInstance();
- private IPlotter plotter;
-
- private Detector detector;
- private List<SiSensor> sensors;
- private Map<SiSensor,int[]> occupancyMap;
- private Map<SiSensor,Integer> sensorRegionMap;
-
- private int eventCount = 0;
- private int eventRefreshRate = 1000;
-
- public SensorOccupancyPlotsDriver()
- {}
-
- public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) {
- this.rawTrackerHitCollectionName = rawTrackerHitCollectionName;
- }
-
- public void setEventRefreshRate(int eventRefreshRate) {
- this.eventRefreshRate = eventRefreshRate;
- }
-
- private int computePlotterRegion(SiSensor sensor) {
-
- IIdentifierHelper helper = sensor.getIdentifierHelper();
- IIdentifier id = sensor.getIdentifier();
-
- int layer = helper.getValue(id, "layer"); // 1-10; axial layers are odd layers; stereo layers are even
- int module = helper.getValue(id, "module"); // 0-1; module number is top or bottom
-
- // Compute the sensor's x and y grid coordinates and then translate to region number.
- int ix = (layer - 1) / 2;
- int iy = 0;
- if (module > 0) {
- iy += 2;
- }
- if (layer % 2 == 0) {
- iy += 1;
- }
- int region = ix * 4 + iy;
- //System.out.println(sensor.getName() + "; lyr=" + layer + "; mod=" + module + " -> xy[" + ix + "][" + iy + "] -> reg="+region);
- return region;
- }
-
- protected void detectorChanged(Detector detector) {
-
- // Setup the plotter.
- IAnalysisFactory fac = aida.analysisFactory();
- plotter = fac.createPlotterFactory().create(detector.getDetectorName() + " : HPS SVT Sensor Occupancy Plots");
- IPlotterStyle pstyle = plotter.style();
- pstyle.dataStyle().fillStyle().setColor("green");
- pstyle.dataStyle().markerStyle().setColor("green");
- pstyle.dataStyle().errorBarStyle().setVisible(false);
- pstyle.statisticsBoxStyle().setVisible(false);
-
- // Create regions.
- plotter.createRegions(5, 4);
-
- // Cache Detector object.
- this.detector = detector;
-
- // Make a list of SiSensors in the SVT.
- sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
-
- // Reset the data structure that keeps track of strip occupancies.
- resetOccupancyMap();
-
- // For now throw an error if there are "too many" sensors.
- if (sensors.size() > 20) {
- throw new RuntimeException("Can't handle > 20 sensors at a time.");
- }
-
- // Map a map of sensors to their region numbers in the plotter.
- sensorRegionMap = new HashMap<SiSensor,Integer>();
- for (SiSensor sensor : sensors) {
- int region = computePlotterRegion(sensor);
- sensorRegionMap.put(sensor,region);
- }
-
- // Setup the occupancy plots.
- aida.tree().cd("/");
- for (SiSensor sensor : sensors) {
- IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName(), 640, 0, 639);
- occupancyPlot.reset();
- int region = sensorRegionMap.get(sensor);
- plotter.region(region).plot(occupancyPlot);
- JASHist hist = ((PlotterRegion)plotter.region(region)).getPlot();
- hist.setAllowUserInteraction(false);
- hist.setAllowPopupMenus(false);
- }
- plotter.show();
- }
-
- public void process(EventHeader event) {
-
- // Get RawTrackerHit collection from event.
- List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName);
-
- // Increment strip hit count.
- for (RawTrackerHit hit : rawTrackerHits) {
- int[] strips = occupancyMap.get((SiSensor) hit.getDetectorElement());
- strips[hit.getIdentifierFieldValue("strip")] += 1;
- }
-
- // Plot strip occupancies.
- if (eventCount % eventRefreshRate == 0) {
- for (SiSensor sensor : sensors) {
- IHistogram1D sensorHist = aida.histogram1D(sensor.getName());
- sensorHist.reset();
- int[] strips = occupancyMap.get(sensor);
- for (int i = 0; i < strips.length; i++) {
- double stripOccupancy = (double) strips[i] / (double) (eventCount);
- if (stripOccupancy != 0) {
- sensorHist.fill(i, stripOccupancy);
- }
- }
- }
- }
-
- // Increment event counter.
- ++eventCount;
- }
-
- private void resetOccupancyMap() {
- occupancyMap = new HashMap<SiSensor,int[]>();
- for (SiSensor sensor : sensors) {
- occupancyMap.put(sensor, new int[640]);
- }
- }
-
- public void endOfData() {
- if (plotter != null)
- plotter.hide();
- }
-
- public void reset() {
- eventCount = 0;
- resetOccupancyMap();
- }
+ private String rawTrackerHitCollectionName = "RawTrackerHitMaker_RawTrackerHits";
+ private String trackerName = "Tracker";
+ private AIDA aida = AIDA.defaultInstance();
+ private IPlotter plotter;
+ private Detector detector;
+ private List<SiSensor> sensors;
+ private Map<SiSensor, int[]> occupancyMap;
+ private Map<SiSensor, Integer> sensorRegionMap;
+ private int eventCount = 0;
+ private int eventRefreshRate = 1000;
+
+ public SensorOccupancyPlotsDriver() {
+ }
+
+ public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) {
+ this.rawTrackerHitCollectionName = rawTrackerHitCollectionName;
+ }
+
+ public void setEventRefreshRate(int eventRefreshRate) {
+ this.eventRefreshRate = eventRefreshRate;
+ }
+
+ private int computePlotterRegion(SiSensor sensor) {
+
+ IIdentifierHelper helper = sensor.getIdentifierHelper();
+ IIdentifier id = sensor.getIdentifier();
+
+ int layer = helper.getValue(id, "layer"); // 1-10; axial layers are odd layers; stereo layers are even
+ int module = helper.getValue(id, "module"); // 0-1; module number is top or bottom
+
+ // Compute the sensor's x and y grid coordinates and then translate to region number.
+ int ix = (layer - 1) / 2;
+ int iy = 0;
+ if (module > 0) {
+ iy += 2;
+ }
+ if (layer % 2 == 0) {
+ iy += 1;
+ }
+ int region = ix * 4 + iy;
+ //System.out.println(sensor.getName() + "; lyr=" + layer + "; mod=" + module + " -> xy[" + ix + "][" + iy + "] -> reg="+region);
+ return region;
+ }
+
+ protected void detectorChanged(Detector detector) {
+
+ // Setup the plotter.
+ IAnalysisFactory fac = aida.analysisFactory();
+ plotter = fac.createPlotterFactory().create(detector.getDetectorName() + " : HPS SVT Sensor Occupancy Plots");
+ IPlotterStyle pstyle = plotter.style();
+ pstyle.dataStyle().fillStyle().setColor("green");
+ pstyle.dataStyle().markerStyle().setColor("green");
+ pstyle.dataStyle().errorBarStyle().setVisible(false);
+ pstyle.statisticsBoxStyle().setVisible(false);
+
+ // Create regions.
+ plotter.createRegions(5, 4);
+
+ // Cache Detector object.
+ this.detector = detector;
+
+ // Make a list of SiSensors in the SVT.
+ sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
+
+ // Reset the data structure that keeps track of strip occupancies.
+ resetOccupancyMap();
+
+ // For now throw an error if there are "too many" sensors.
+ if (sensors.size() > 20) {
+ throw new RuntimeException("Can't handle > 20 sensors at a time.");
+ }
+
+ // Map a map of sensors to their region numbers in the plotter.
+ sensorRegionMap = new HashMap<SiSensor, Integer>();
+ for (SiSensor sensor : sensors) {
+ int region = computePlotterRegion(sensor);
+ sensorRegionMap.put(sensor, region);
+ }
+
+ // Setup the occupancy plots.
+ aida.tree().cd("/");
+ for (SiSensor sensor : sensors) {
+ IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName(), 640, 0, 639);
+ occupancyPlot.reset();
+ int region = sensorRegionMap.get(sensor);
+ plotter.region(region).plot(occupancyPlot);
+ JASHist hist = ((PlotterRegion) plotter.region(region)).getPlot();
+ hist.setAllowUserInteraction(false);
+ hist.setAllowPopupMenus(false);
+ }
+ plotter.show();
+ }
+
+ public void process(EventHeader event) {
+ if (event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) {
+
+ // Get RawTrackerHit collection from event.
+ List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName);
+
+ // Increment strip hit count.
+ for (RawTrackerHit hit : rawTrackerHits) {
+ int[] strips = occupancyMap.get((SiSensor) hit.getDetectorElement());
+ strips[hit.getIdentifierFieldValue("strip")] += 1;
+ }
+
+ // Plot strip occupancies.
+ if (eventCount % eventRefreshRate == 0) {
+ for (SiSensor sensor : sensors) {
+ IHistogram1D sensorHist = aida.histogram1D(sensor.getName());
+ sensorHist.reset();
+ int[] strips = occupancyMap.get(sensor);
+ for (int i = 0; i < strips.length; i++) {
+ double stripOccupancy = (double) strips[i] / (double) (eventCount);
+ if (stripOccupancy != 0) {
+ sensorHist.fill(i, stripOccupancy);
+ }
+ }
+ }
+ }
+
+ // Increment event counter.
+ ++eventCount;
+ }
+ }
+
+ private void resetOccupancyMap() {
+ occupancyMap = new HashMap<SiSensor, int[]>();
+ for (SiSensor sensor : sensors) {
+ occupancyMap.put(sensor, new int[640]);
+ }
+ }
+
+ public void endOfData() {
+ if (plotter != null) {
+ plotter.hide();
+ }
+ }
+
+ public void reset() {
+ eventCount = 0;
+ resetOccupancyMap();
+ }
}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.2 -r1.3
--- EcalWindowPlots.java 26 Apr 2012 18:15:26 -0000 1.2
+++ EcalWindowPlots.java 27 Apr 2012 22:13:53 -0000 1.3
@@ -140,16 +140,14 @@
}
public void process(EventHeader event) {
- List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, inputCollection);
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!rawTrackerHits.isEmpty() && RawTrackerHit.class.isInstance(rawTrackerHits.get(0))) {
+ 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);
+// 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);
}
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.1 -r1.2
--- EcalWindowPlotsXY.java 26 Apr 2012 18:15:26 -0000 1.1
+++ EcalWindowPlotsXY.java 27 Apr 2012 22:13:53 -0000 1.2
@@ -132,15 +132,13 @@
}
public void process(EventHeader event) {
- List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, inputCollection);
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!rawTrackerHits.isEmpty() && RawTrackerHit.class.isInstance(rawTrackerHits.get(0))) {
+ 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);
+// 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);
}
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.1 -r1.2
--- EcalPedestalPlots.java 26 Apr 2012 18:15:26 -0000 1.1
+++ EcalPedestalPlots.java 27 Apr 2012 22:13:53 -0000 1.2
@@ -10,8 +10,7 @@
import java.util.ArrayList;
import java.util.List;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
+import javax.swing.*;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawCalorimeterHit;
@@ -35,6 +34,7 @@
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;
@@ -98,6 +98,7 @@
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
@@ -109,7 +110,7 @@
}
// Create the plotter regions.
- plotter.createRegions(1, 2);
+ plotter.createRegions(1, 3);
xCombo = new JComboBox(xList);
xCombo.addActionListener(this);
@@ -124,16 +125,31 @@
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(plots[18][2]);
+ 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() {
@@ -154,9 +170,7 @@
}
public void process(EventHeader event) {
- List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, inputCollection);
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!rawTrackerHits.isEmpty() && RawTrackerHit.class.isInstance(rawTrackerHits.get(0))) {
+ if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
for (RawTrackerHit hit : hits) {
dec.setID(hit.getCellID());
@@ -168,9 +182,7 @@
}
}
- List<RawCalorimeterHit> rawCalHits = event.get(RawCalorimeterHit.class, inputCollection);
- //FIXME: this check is necessary because hasCollection(type, name) doesn't seem to actually check type!
- if (!rawCalHits.isEmpty() && RawCalorimeterHit.class.isInstance(rawCalHits.get(0))) {
+ if (event.hasCollection(RawCalorimeterHit.class, inputCollection)) {
List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollection);
for (RawCalorimeterHit hit : hits) {
dec.setID(hit.getCellID());
@@ -181,9 +193,11 @@
}
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);
}
@@ -195,9 +209,9 @@
Integer x, y;
x = (Integer) xCombo.getSelectedItem();
y = (Integer) yCombo.getSelectedItem();
- plotter.region(1).clear();
- plotter.region(1).plot(plots[x + 23][y + 5]);
- ((PlotterRegion) plotter.region(1)).getPlot().setAllowUserInteraction(false);
- ((PlotterRegion) plotter.region(1)).getPlot().setAllowPopupMenus(false);
+ 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);
}
}
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.3 -r1.4
--- EcalDaqPlots.java 19 Apr 2012 01:33:29 -0000 1.3
+++ EcalDaqPlots.java 27 Apr 2012 22:13:53 -0000 1.4
@@ -11,6 +11,7 @@
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.recon.ecal.HPSEcalDaqIDConverter;
@@ -18,96 +19,112 @@
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) {
- 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);
- }
- }
+
+ 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);
+ }
+ }
+ }
}
CVSspam 0.2.12