Commit in hps-java/src/main/java/org/lcsim/hps/monitoring/svt on MAIN | |||
SVTSimpleEventDisplay.java | +191 | -77 | 1.10 -> 1.11 |
refactored this class; added missing documentation; using as test driver for monitoring app
diff -u -r1.10 -r1.11 --- SVTSimpleEventDisplay.java 5 Jun 2013 19:03:21 -0000 1.10 +++ SVTSimpleEventDisplay.java 25 Oct 2013 20:14:49 -0000 1.11 @@ -1,8 +1,9 @@
package org.lcsim.hps.monitoring.svt;
-import hep.aida.IAnalysisFactory;
import hep.aida.IHistogram1D; import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory; +import hep.aida.jfree.plot.style.DefaultHistogram1DStyle;
import java.util.List;
@@ -10,7 +11,6 @@
import org.lcsim.event.RawTrackerHit; import org.lcsim.fit.helicaltrack.HelicalTrackHit; import org.lcsim.geometry.Detector;
-import org.lcsim.hps.monitoring.AIDAFrame;
import org.lcsim.hps.monitoring.Resettable; import org.lcsim.hps.recon.tracking.SvtUtils; import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
@@ -18,44 +18,86 @@
import org.lcsim.util.aida.AIDA; /**
- * Plots hit counts for all SVT channels at each stage of reconstruction; - * can be set to reset after each event for use as an event display
+ * Plots hit counts for all SVT channels at each stage of reconstruction. + * This class can be configured to reset after each event for use as an + * event display by calling {@link #setSingleEvent(boolean)}.
*
- * @version $Id: SVTSimpleEventDisplay.java,v 1.10 2013/06/05 19:03:21 jeremy Exp $
+ * @version $Id: SVTSimpleEventDisplay.java,v 1.11 2013/10/25 20:14:49 jeremy Exp $
*/ public class SVTSimpleEventDisplay extends Driver implements Resettable {
- //private AIDAFrame plotterFrame;
+ /* + * Names of collections. + */
private String inputCollection = "SVTRawTrackerHits"; private String trackerHitCollection = "StripClusterer_SiTrackerHitStrip1D"; private String helicalHitCollection = "HelicalTrackHits";
+ + /* + * Reference to AIDA utility. + */
private AIDA aida = AIDA.defaultInstance();
+ + /* + * AIDA objects that will be setup during initialization. + */
private IPlotter plotter, plotter2, plotter3, plotter4; private IHistogram1D[][] rth = new IHistogram1D[2][10]; private IHistogram1D[][] th = new IHistogram1D[2][10]; private IHistogram1D[][] hth = new IHistogram1D[2][10]; private IHistogram1D hitCount[] = new IHistogram1D[2];
+ private IPlotterFactory factory; + + /* + * Single event mode setting. + */
private boolean singleEvent = true;
+ /** + * Class constructor. + */
public SVTSimpleEventDisplay() { }
+ /** + * Set the name of the HelicalTrackHit collection. + * @param helicalHitCollection The name of the HelicalTrackHit collection. + */
public void setHelicalHitCollection(String helicalHitCollection) { this.helicalHitCollection = helicalHitCollection; }
+ /** + * Set this Driver to reset after each event. + * @param singleEvent Set to true if Driver should reset after each event. + */
public void setSingleEvent(boolean singleEvent) { this.singleEvent = singleEvent; }
+ /** + * Set the RawTrackerHit collection name. + * @param inputCollection The name of the RawTrackerHit collection. + * FIXME: This method should really be called setRawTrackerHitCollection instead. + */
public void setInputCollection(String inputCollection) { this.inputCollection = inputCollection; }
+ /** + * Set the name of the TrackerHit collection. + * @param trackerHitCollection The name of the TrackerHit collection. + */
public void setTrackerHitCollection(String trackerHitCollection) { this.trackerHitCollection = trackerHitCollection; }
+ /** + * Get the plotter region index from a layer and module number of a sensor. + * @param layer The sensor's layer number. + * @param module The sensor's module number. + * @return The index of the plotter region for the layer and module. + */
private int computePlotterRegion(int layer, int module) { // Compute the sensor's x and y grid coordinates and then translate to region number. int iy = (layer - 1) / 2;
@@ -71,43 +113,74 @@
return region; }
- @Override
+ /** + * Configure this Driver for a new Detector, e.g. setup the plots and show them. + */
protected void detectorChanged(Detector detector) {
- //plotterFrame = new AIDAFrame(); - //plotterFrame.setTitle("HPS SVT Hit Counts");
+ createPlotterFactory(); + setupRawTrackerHitPlots(); + setupTrackerHitPlots(); + setupHelicalTrackHitPlots(); + setupHitCountPlots(); + setupOccupancyPlots(); + showPlots(); + }
- // Setup the plotter. - IAnalysisFactory fac = aida.analysisFactory();
+ /** + * Create the PlotterFactory. + */ + private void createPlotterFactory() { + factory = aida.analysisFactory().createPlotterFactory("SVT Event Display"); + }
- plotter = fac.createPlotterFactory().create("RawTrackerHits"); - plotter.setTitle("RawTrackerHits"); - //plotterFrame.addPlotter(plotter); - plotter.style().dataStyle().errorBarStyle().setVisible(false); - plotter.style().statisticsBoxStyle().setVisible(false); - plotter.createRegions(4, 5);
+ private void setupHitCountPlots() { + plotter4 = factory.create("Hit Counts"); + plotter4.setTitle("Hit Counts"); + plotter4.setStyle(new DefaultHistogram1DStyle()); + plotter4.style().dataStyle().errorBarStyle().setVisible(false); + plotter4.createRegions(1, 2); + + hitCount[0] = aida.histogram1D("Hit layers in top", 6, -0.5, 5.5); + plotter4.region(0).plot(hitCount[0]); + hitCount[1] = aida.histogram1D("Hit layers in bottom", 6, -0.5, 5.5); + plotter4.region(1).plot(hitCount[1]); + } + + private void setupHelicalTrackHitPlots() { + plotter3 = factory.create("HelicalTrackHits"); + plotter3.setTitle("HelicalTrackHits"); + plotter3.setStyle(new DefaultHistogram1DStyle()); + plotter3.style().dataStyle().errorBarStyle().setVisible(false); + plotter3.style().statisticsBoxStyle().setVisible(false); + plotter3.createRegions(4, 5); + }
- plotter2 = fac.createPlotterFactory().create("TrackerHits");
+ private void setupTrackerHitPlots() { + plotter2 = factory.create("TrackerHits");
plotter2.setTitle("TrackerHits");
- //plotterFrame.addPlotter(plotter2);
+ plotter2.setStyle(new DefaultHistogram1DStyle());
plotter2.style().dataStyle().errorBarStyle().setVisible(false); plotter2.style().statisticsBoxStyle().setVisible(false); plotter2.createRegions(4, 5);
+ }
- plotter3 = fac.createPlotterFactory().create("HelicalTrackHits"); - plotter3.setTitle("HelicalTrackHits"); - //plotterFrame.addPlotter(plotter3); - plotter3.style().dataStyle().errorBarStyle().setVisible(false); - plotter3.style().statisticsBoxStyle().setVisible(false); - plotter3.createRegions(4, 5);
+ private void setupRawTrackerHitPlots() { + plotter = factory.create("RawTrackerHits"); + plotter.setTitle("RawTrackerHits"); + plotter.setStyle(new DefaultHistogram1DStyle()); + plotter.style().dataStyle().errorBarStyle().setVisible(false); + plotter.style().statisticsBoxStyle().setVisible(false); + plotter.createRegions(4, 5); + }
- plotter4 = fac.createPlotterFactory().create("Hit Counts"); - plotter4.setTitle("Hit Counts"); - //plotterFrame.addPlotter(plotter4); - plotter4.style().dataStyle().errorBarStyle().setVisible(false); -// plotter4.style().statisticsBoxStyle().setVisible(false); - plotter4.createRegions(1, 2);
+ private void showPlots() { + plotter.show(); + plotter2.show(); + plotter3.show(); + plotter4.show(); + }
- // Setup the occupancy plots.
+ private void setupOccupancyPlots() {
aida.tree().cd("/"); for (int module = 0; module < 2; module++) { for (int layer = 0; layer < 10; layer++) {
@@ -120,58 +193,37 @@
plotter3.region(region).plot(hth[module][layer]); } }
- - hitCount[0] = aida.histogram1D("Hit layers in top", 6, -0.5, 5.5); - plotter4.region(0).plot(hitCount[0]); - hitCount[1] = aida.histogram1D("Hit layers in bottom", 6, -0.5, 5.5); - plotter4.region(1).plot(hitCount[1]); - - //plotterFrame.pack(); - //plotterFrame.setVisible(true);
}
- @Override
+ /** + * Process a single event by filling histograms with event data. + * @param event The current event. + */
public void process(EventHeader event) {
- // Clear histograms. - if (singleEvent) { - for (int module = 0; module < 2; module++) { - for (int layer = 1; layer < 11; layer++) { - rth[module][layer - 1].reset(); - th[module][layer - 1].reset(); - hth[module][layer - 1].reset(); - } - } - } - - if (event.hasCollection(RawTrackerHit.class, inputCollection)) { - List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, inputCollection); - - // Increment strip hit count. - for (RawTrackerHit hit : rawTrackerHits) { - int layer = hit.getIdentifierFieldValue("layer"); // 1-10; axial layers are odd layers; stereo layers are even - int module = hit.getIdentifierFieldValue("module"); // 0-1; module number is top or bottom
- rth[module][layer - 1].fill(hit.getIdentifierFieldValue("strip")); - }
+ // Clear histograms if in single event mode. + if (singleEvent) { + resetPlots();
}
- if (event.hasCollection(SiTrackerHit.class, trackerHitCollection)) { - List<SiTrackerHit> trackerHits = event.get(SiTrackerHit.class, trackerHitCollection);
+ plotRawTrackerHits(event);
- // Increment strip hit count. - for (SiTrackerHit hit : trackerHits) { - for (RawTrackerHit rawHit : hit.getRawHits()) { - int layer = rawHit.getIdentifierFieldValue("layer"); // 1-10; axial layers are odd layers; stereo layers are even - int module = rawHit.getIdentifierFieldValue("module"); // 0-1; module number is top or bottom
+ plotTrackerHits(event);
- th[module][layer - 1].fill(rawHit.getIdentifierFieldValue("strip")); - } - } - }
+ plotHelicalTrackHits(event); + }
+ /** + * Fill HelicalTrackHit plots for one event. + * @param event The event. + */ + private void plotHelicalTrackHits(EventHeader event) {
if (event.hasCollection(HelicalTrackHit.class, helicalHitCollection)) {
+
List<HelicalTrackHit> helicalTrackerHits = event.get(HelicalTrackHit.class, helicalHitCollection);
+ System.out.println(helicalHitCollection + " has " + helicalTrackerHits.size() + " hits"); +
boolean[][] hasHit = new boolean[2][5]; // Increment strip hit count.
@@ -193,23 +245,85 @@
} hitCount[module].fill(count); }
+ } else { + throw new RuntimeException("Collection " + helicalHitCollection + " was not found.");
} }
- @Override - public void endOfData() { - //plotterFrame.dispose();
+ /** + * Fill TrackerHit plots for one event. + * @param event The event. + */ + private void plotTrackerHits(EventHeader event) { + if (event.hasCollection(SiTrackerHit.class, trackerHitCollection)) { + + List<SiTrackerHit> trackerHits = event.get(SiTrackerHit.class, trackerHitCollection); + + System.out.println(trackerHitCollection + " has " + trackerHits.size() + " hits"); + + // Increment strip hit count. + for (SiTrackerHit hit : trackerHits) { + for (RawTrackerHit rawHit : hit.getRawHits()) { + int layer = rawHit.getIdentifierFieldValue("layer"); // 1-10; axial layers are odd layers; stereo layers are even + int module = rawHit.getIdentifierFieldValue("module"); // 0-1; module number is top or bottom + + th[module][layer - 1].fill(rawHit.getIdentifierFieldValue("strip")); + } + } + } else { + throw new RuntimeException("Collection " + trackerHitCollection + " was not found."); + }
}
- @Override - public void reset() {
+ /** + * Fill RawTrackerHit plots for one event. + * @param event The event. + */ + private void plotRawTrackerHits(EventHeader event) { + if (event.hasCollection(RawTrackerHit.class, inputCollection)) { + List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, inputCollection); + + System.out.println(inputCollection + " has " + rawTrackerHits.size() + " hits"); + + // Increment strip hit count. + for (RawTrackerHit hit : rawTrackerHits) { + int layer = hit.getIdentifierFieldValue("layer"); // 1-10; axial layers are odd layers; stereo layers are even + int module = hit.getIdentifierFieldValue("module"); // 0-1; module number is top or bottom + + rth[module][layer - 1].fill(hit.getIdentifierFieldValue("strip")); + } + } else { + throw new RuntimeException("Collection " + inputCollection + " was not found."); + } + } + + /** + * Reset the plots for running in single event mode. + */ + private void resetPlots() {
for (int module = 0; module < 2; module++) { for (int layer = 1; layer < 11; layer++) { rth[module][layer - 1].reset(); th[module][layer - 1].reset(); hth[module][layer - 1].reset(); }
+ } + } + + /** + * Reset the hit count plot, which is not affected by single event setting. + */ + private void resetHitCountPlot() { + for (int module = 0; module < 2; module++) {
hitCount[module].reset(); } }
+ + /** + * Reset this Driver's plots. + */ + public void reset() { + resetPlots(); + resetHitCountPlot(); + }
}
\ No newline at end of file
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