Author: [log in to unmask]
Date: Fri Jan 9 16:16:37 2015
New Revision: 1911
Log:
Move monitoring specific utility methods to monitoring-drivers module from ecal-recon.
Added:
java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java
Modified:
java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java
java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalEventDisplay.java
java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java
java/trunk/users/pom.xml
java/trunk/users/src/main/java/org/hps/users/celentan/EcalChannelsAmplitude.java
java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java
Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java
=============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java (original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java Fri Jan 9 16:16:37 2015
@@ -75,66 +75,41 @@
}
}
}
-
- /*These methods have been added by A. Celentano: they're mostly used in the monitoring drivers related to Ecal:
- * however, instead of keeping them in a class "EcalMonitoringUtils", it seems better to have them here.
+
+ /**
+ * This is a very basic method that, given an array with the raw-waveform (in FADC units), returns the amplitude (in mV)
+ * @param data Array with data from FADC, in fadc units
+ * @param lenght The array lenght
+ * @param pedestalSamples How many samples at the beginning of the array to use for the pedestal. Must be < lenght
+ * @return double[], 0 is the amplitude in mV, 1 is the offest in ADC counts, 2 is the RMS in adc counts
*/
- public static int getRowFromHistoID(int id){
- return (5-(id%11));
+ public static double[] computeAmplitude(short [] data, int lenght, int pedestalSamples){
+ double amplitude,pedestal,noise;
+ pedestal=0;
+ noise=0;
+ amplitude=data[0];
+ double[] ret={0.,0.,0.};
+ if (pedestalSamples>lenght){
+ return ret;
+ }
+ for (int jj = 0; jj < lenght; jj++){
+ if (jj<pedestalSamples){
+ pedestal+=data[jj];
+ noise+=data[jj]*data[jj];
+ }
+ if (data[jj]>amplitude) amplitude=data[jj];
+ }
+ pedestal/=pedestalSamples;
+ noise/=pedestalSamples;
+ noise=Math.sqrt(noise-pedestal*pedestal);
+ amplitude-=pedestal;
+
+ amplitude*=adcResolution*1000;
+ ret[0]=amplitude;
+ ret[1]=pedestal;
+ ret[2]=noise;
+ return ret;
+
}
- public static int getColumnFromHistoID(int id){
- return ((id/11)-23);
- }
-
- public static int getHistoIDFromRowColumn(int row,int column){
- return (-row+5)+11*(column+23);
- }
-
- public static Boolean isInHole(int row,int column){
- Boolean ret;
- ret=false;
- if ((row==1)||(row==-1)){
- if ((column<=-2)&&(column>=-10)) ret=true;
- }
- return ret;
- }
-
-
- /**
- * This is a very basic method that, given an array with the raw-waveform (in FADC units), returns the amplitude (in mV)
- * @param data Array with data from FADC, in fadc units
- * @param lenght The array lenght
- * @param pedestalSamples How many samples at the beginning of the array to use for the pedestal. Must be < lenght
- * @return double[], 0 is the amplitude in mV, 1 is the offest in ADC counts, 2 is the RMS in adc counts
- */
- public static double[] computeAmplitude(short [] data, int lenght, int pedestalSamples){
- double amplitude,pedestal,noise;
- pedestal=0;
- noise=0;
- amplitude=data[0];
- double[] ret={0.,0.,0.};
- if (pedestalSamples>lenght){
- return ret;
- }
- for (int jj = 0; jj < lenght; jj++){
- if (jj<pedestalSamples){
- pedestal+=data[jj];
- noise+=data[jj]*data[jj];
- }
- if (data[jj]>amplitude) amplitude=data[jj];
- }
- pedestal/=pedestalSamples;
- noise/=pedestalSamples;
- noise=Math.sqrt(noise-pedestal*pedestal);
- amplitude-=pedestal;
-
- amplitude*=adcResolution*1000;
- ret[0]=amplitude;
- ret[1]=pedestal;
- ret[2]=noise;
- return ret;
-
- }
-
}
Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalEventDisplay.java
=============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalEventDisplay.java (original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalEventDisplay.java Fri Jan 9 16:16:37 2015
@@ -169,8 +169,8 @@
// for possibly different raw waveform dimensions!
//Get the x and y indices for the current channel.
- int row = ECalUtils.getRowFromHistoID(ii);
- int column = ECalUtils.getColumnFromHistoID(ii);
+ int row = EcalMonitoringUtilities.getRowFromHistoID(ii);
+ int column = EcalMonitoringUtilities.getColumnFromHistoID(ii);
// Initialize the histograms for the current crystal channel.
channelEnergyPlot.add(aida.histogram1D(detector.getDetectorName() + " : "
@@ -311,7 +311,7 @@
if (iy != 0 && ix != 0) {
// Get the histogram index for the hit.
- int id = ECalUtils.getHistoIDFromRowColumn(iy, ix);
+ int id = EcalMonitoringUtilities.getHistoIDFromRowColumn(iy, ix);
// If the hit has energy, populate the plots.
if(hit.getCorrectedEnergy() > 0) {
@@ -340,7 +340,7 @@
int iy = cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
// Get the histogram index for the hit.
- int id = ECalUtils.getHistoIDFromRowColumn(iy, ix);
+ int id = EcalMonitoringUtilities.getHistoIDFromRowColumn(iy, ix);
// Add the cluster energy to the plot.
if(cluster.getEnergy() > 0.0) {
@@ -429,9 +429,9 @@
// Make sure that the clicked crystal is valid. Necessary??
if((ecalPoint.x != 0) && (ecalPoint.y != 0))
- if (!ECalUtils.isInHole(ecalPoint.y, ecalPoint.x)) {
+ if (!EcalMonitoringUtilities.isInHole(ecalPoint.y, ecalPoint.x)) {
// Get the crystal ID.
- int id = ECalUtils.getHistoIDFromRowColumn(ecalPoint.y, ecalPoint.x);
+ int id = EcalMonitoringUtilities.getHistoIDFromRowColumn(ecalPoint.y, ecalPoint.x);
// Clear and replot region 0 for the new crystal.
plotter.region(0).clear();
Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java
=============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java (original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java Fri Jan 9 16:16:37 2015
@@ -92,8 +92,8 @@
NoccupancyFill=1; //to avoid a "NaN" at beginning
for (int ii = 0; ii < (11 * 47); ii++) {
- int row = ECalUtils.getRowFromHistoID(ii);
- int column = ECalUtils.getColumnFromHistoID(ii);
+ int row = EcalMonitoringUtilities.getRowFromHistoID(ii);
+ int column = EcalMonitoringUtilities.getColumnFromHistoID(ii);
occupancyFill[ii]=0;
}
@@ -145,7 +145,7 @@
for (CalorimeterHit hit : hits) {
int column = hit.getIdentifierFieldValue("ix");
int row = hit.getIdentifierFieldValue("iy");
- int id = ECalUtils.getHistoIDFromRowColumn(row, column);
+ int id = EcalMonitoringUtilities.getHistoIDFromRowColumn(row, column);
hitCountFillPlot.fill(column, row);
{
chits[id]++;
@@ -202,12 +202,12 @@
occupancyDrawPlot.reset();
for (int id = 0; id < (47 * 11); id++) {
- int row = ECalUtils.getRowFromHistoID(id);
- int column = ECalUtils.getColumnFromHistoID(id);
+ int row = EcalMonitoringUtilities.getRowFromHistoID(id);
+ int column = EcalMonitoringUtilities.getColumnFromHistoID(id);
double mean = occupancyFill[id]/NoccupancyFill;
occupancyFill[id]=0;
- if ((row != 0) && (column != 0) && (!ECalUtils.isInHole(row, column)))
+ if ((row != 0) && (column != 0) && (!EcalMonitoringUtilities.isInHole(row, column)))
occupancyDrawPlot.fill(column, row, mean);
}
plotter.region(2).clear();
Added: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java
=============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java (added)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java Fri Jan 9 16:16:37 2015
@@ -0,0 +1,35 @@
+package org.hps.monitoring.ecal.plots;
+
+/**
+ * Some simple utility methods for organizing ECAL monitoring plots.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @author Andrea Celentano <[log in to unmask]>
+ */
+public final class EcalMonitoringUtilities {
+
+ private EcalMonitoringUtilities() {
+ }
+
+ public static int getRowFromHistoID(int id) {
+ return (5 - (id % 11));
+ }
+
+ public static int getColumnFromHistoID(int id) {
+ return ((id / 11) - 23);
+ }
+
+ public static int getHistoIDFromRowColumn(int row, int column) {
+ return (-row + 5) + 11 * (column + 23);
+ }
+
+ public static Boolean isInHole(int row, int column) {
+ Boolean ret;
+ ret = false;
+ if ((row == 1) || (row == -1)) {
+ if ((column <= -2) && (column >= -10))
+ ret = true;
+ }
+ return ret;
+ }
+}
Modified: java/trunk/users/pom.xml
=============================================================================
--- java/trunk/users/pom.xml (original)
+++ java/trunk/users/pom.xml Fri Jan 9 16:16:37 2015
@@ -23,6 +23,10 @@
<groupId>org.hps</groupId>
<artifactId>hps-record-util</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hps</groupId>
+ <artifactId>hps-monitoring-drivers</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: java/trunk/users/src/main/java/org/hps/users/celentan/EcalChannelsAmplitude.java
=============================================================================
--- java/trunk/users/src/main/java/org/hps/users/celentan/EcalChannelsAmplitude.java (original)
+++ java/trunk/users/src/main/java/org/hps/users/celentan/EcalChannelsAmplitude.java Fri Jan 9 16:16:37 2015
@@ -1,28 +1,12 @@
package org.hps.users.celentan;
import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-import hep.aida.ICloud1D;
-import hep.aida.ICloud2D;
-import hep.aida.IPlotter;
-import hep.aida.IPlotterFactory;
-import hep.aida.IPlotterStyle;
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
-import java.lang.System;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
+import org.hps.monitoring.ecal.plots.EcalMonitoringUtilities;
import org.hps.recon.ecal.ECalUtils;
-import org.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.geometry.Detector;
@@ -30,158 +14,122 @@
import org.lcsim.util.aida.AIDA;
/**
- * The driver <code>EcalChannelAmplitude</code> implements the histogram shown to the user
- * in the fifth tab of the Monitoring Application, when using the Ecal monitoring lcsim file.
- * The implementation is as follows:
- * - The event display is opened in a separate window
- * - It is updated regularly, according to the event refresh rate
- * - If the user clicks on a crystal, the corresponding energy and time distributions (both Histogram1D) are shown in the last panel of the MonitoringApplication,
- * as well as a 2D histogram (hit time vs hit energy). Finally, if available, the raw waveshape (in mV) is displayed.
+ * The driver <code>EcalChannelAmplitude</code> implements the histogram shown to the user in the
+ * fifth tab of the Monitoring Application, when using the Ecal monitoring lcsim file. The implementation
+ * is as follows: - The event display is opened in a separate window - It is updated regularly, according
+ * to the event refresh rate - If the user clicks on a crystal, the corresponding energy and time
+ * distributions (both Histogram1D) are shown in the last panel of the MonitoringApplication, as well
+ * as a 2D histogram (hit time vs hit energy). Finally, if available, the raw waveshape (in mV) is
+ * displayed.
*
- * @author Andrea Celentano
- * *
+ * @author Andrea Celentano
+ *
*/
+public class EcalChannelsAmplitude extends Driver {
-public class EcalChannelsAmplitude extends Driver{
-
-
String inputCollection = "EcalCalHits";
String inputCollectionRaw = "EcalReadoutHits";
String clusterCollection = "EcalClusters";
- private AIDA aida=AIDA.defaultInstance();
+ private AIDA aida = AIDA.defaultInstance();
private Detector detector;
-
-
+
int eventn = 0;
- int ix,iy,id;
- int pedSamples=10;
-
- double amp,ped,sigma;
- double hitE;
- int[] windowRaw=new int[47*11];//in case we have the raw waveform, this is the window lenght (in samples)
- boolean[] isFirstRaw=new boolean[47*11];
-
-
- boolean enableAllFadc=false;
-
+ int ix, iy, id;
+ int pedSamples = 10;
-
+ double amp, ped, sigma;
+ double hitE;
+ int[] windowRaw = new int[47 * 11];// in case we have the raw waveform, this is the window lenght (in samples)
+ boolean[] isFirstRaw = new boolean[47 * 11];
+
+ boolean enableAllFadc = false;
+
ArrayList<IHistogram1D> channelAmplitudePlot;
ArrayList<IHistogram1D> channelRawWaveform;
-
-
-
-
-
- int itmpx,itmpy;
-
- public EcalChannelsAmplitude() {
-
+
+ int itmpx, itmpy;
+
+ public EcalChannelsAmplitude() {
+
}
-
public void setPedSamples(int pedSamples) {
this.pedSamples = pedSamples;
}
-
+
public void setInputCollection(String inputCollection) {
this.inputCollection = inputCollection;
}
-
+
public void setInputCollectionRaw(String inputCollectionRaw) {
this.inputCollectionRaw = inputCollectionRaw;
}
-
+
public void setInputClusterCollection(String inputClusterCollection) {
this.clusterCollection = inputClusterCollection;
}
-
-
-
+
@Override
public void detectorChanged(Detector detector) {
- System.out.println("Ecal event display detector changed");
+ System.out.println("Ecal event display detector changed");
this.detector = detector;
-
- aida.tree().cd("/");
-
-
-
- channelAmplitudePlot=new ArrayList<IHistogram1D>();
- channelRawWaveform=new ArrayList<IHistogram1D>();
- //create the histograms for single channel energy and time distribution.
- for(int ii = 0; ii < (47*11); ii = ii +1){
- int row=ECalUtils.getRowFromHistoID(ii);
- int column=ECalUtils.getColumnFromHistoID(ii);
- channelAmplitudePlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Amplitude : " + (column) + " "+ (row)+ ": "+ii, 100, -.2, 2100.));
- channelRawWaveform.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Amplitude : " + (column) + " "+ (row)+ ": "+ii));
- //the above instruction is a terrible hack, just to fill the arrayList with all the elements. They'll be initialized properly during the event readout,
- //since we want to account for possibly different raw waveform dimensions!
-
-
- isFirstRaw[ii]=true;
- windowRaw[ii]=1;
- }
- id=0;
- iy=ECalUtils.getRowFromHistoID(id);
- ix=ECalUtils.getColumnFromHistoID(id);
+
+ aida.tree().cd("/");
+
+ channelAmplitudePlot = new ArrayList<IHistogram1D>();
+ channelRawWaveform = new ArrayList<IHistogram1D>();
+ // create the histograms for single channel energy and time distribution.
+ for (int ii = 0; ii < (47 * 11); ii = ii + 1) {
+ int row = EcalMonitoringUtilities.getRowFromHistoID(ii);
+ int column = EcalMonitoringUtilities.getColumnFromHistoID(ii);
+ channelAmplitudePlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Amplitude : " + (column) + " " + (row) + ": " + ii, 100, -.2, 2100.));
+ channelRawWaveform.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Amplitude : " + (column) + " " + (row) + ": " + ii));
+ // the above instruction is a terrible hack, just to fill the arrayList with all the elements. They'll be initialized properly during the event readout,
+ // since we want to account for possibly different raw waveform dimensions!
+
+ isFirstRaw[ii] = true;
+ windowRaw[ii] = 1;
+ }
+ id = 0;
+ iy = EcalMonitoringUtilities.getRowFromHistoID(id);
+ ix = EcalMonitoringUtilities.getColumnFromHistoID(id);
}
@Override
public void endOfData() {
- System.out.println("END OF DATA");
+ System.out.println("END OF DATA");
}
@Override
- public void process(EventHeader event){
-
- int ii;
- int row = 0;
- int column = 0;
- double[] result;
-
-
- if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)){
- List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw);
- for (RawTrackerHit hit : hits) {
- row=hit.getIdentifierFieldValue("iy");
- column=hit.getIdentifierFieldValue("ix");
- ii = ECalUtils.getHistoIDFromRowColumn(row,column);
- if ((row!=0)&&(column!=0)&&(!(ECalUtils.isInHole(row,column)))){
- if (isFirstRaw[ii]){ //at the very first hit we read for this channel, we need to read the window length and save it
- isFirstRaw[ii]=false;
- windowRaw[ii]=hit.getADCValues().length;
- channelRawWaveform.set(ii,aida.histogram1D(detector.getDetectorName() + " : " + inputCollectionRaw + " : Raw Waveform : " + (column) + " "+ (row)+ ": "+ii,windowRaw[ii],-0.5*ECalUtils.ecalReadoutPeriod,(-0.5+windowRaw[ii])*ECalUtils.ecalReadoutPeriod));
- }
- result=ECalUtils.computeAmplitude(hit.getADCValues(),windowRaw[ii],pedSamples);
- channelAmplitudePlot.get(ii).fill(result[0]);
- }
+ public void process(EventHeader event) {
+
+ int ii;
+ int row = 0;
+ int column = 0;
+ double[] result;
+
+ if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)) {
+ List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw);
+ for (RawTrackerHit hit : hits) {
+ row = hit.getIdentifierFieldValue("iy");
+ column = hit.getIdentifierFieldValue("ix");
+ ii = EcalMonitoringUtilities.getHistoIDFromRowColumn(row, column);
+ if ((row != 0) && (column != 0) && (!(EcalMonitoringUtilities.isInHole(row, column)))) {
+ if (isFirstRaw[ii]) { // at the very first hit we read for this channel, we need to read the window length and save it
+ isFirstRaw[ii] = false;
+ windowRaw[ii] = hit.getADCValues().length;
+ channelRawWaveform.set(ii, aida.histogram1D(detector.getDetectorName() + " : " + inputCollectionRaw + " : Raw Waveform : " + (column) + " " + (row) + ": " + ii, windowRaw[ii], -0.5 * ECalUtils.ecalReadoutPeriod, (-0.5 + windowRaw[ii]) * ECalUtils.ecalReadoutPeriod));
+ }
+ result = ECalUtils.computeAmplitude(hit.getADCValues(), windowRaw[ii], pedSamples);
+ channelAmplitudePlot.get(ii).fill(result[0]);
+ }
}
- }
-
+ }
+
}
-
+
/*
- @Override
- public void reset(){
- for(int ii = 0; ii < (47*11); ii = ii +1){
- channelEnergyPlot.get(ii).reset();
- channelTimePlot.get(ii).reset();
- channelTimeVsEnergyPlot.get(ii).reset();
- }
- }
- */
-
-
-
-
-
-
+ * @Override public void reset(){ for(int ii = 0; ii < (47*11); ii = ii +1){ channelEnergyPlot.get(ii).reset(); channelTimePlot.get(ii).reset(); channelTimeVsEnergyPlot.get(ii).reset(); } }
+ */
}
-
-
-
-
-
-
Modified: java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java
=============================================================================
--- java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java (original)
+++ java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java Fri Jan 9 16:16:37 2015
@@ -15,6 +15,7 @@
import org.lcsim.event.RawTrackerHit;
import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
+import org.hps.monitoring.ecal.plots.EcalMonitoringUtilities;
public class RawPedestalComputator extends Driver {
@@ -59,9 +60,9 @@
for (RawTrackerHit hit : hits) {
row = hit.getIdentifierFieldValue("iy");
column = hit.getIdentifierFieldValue("ix");
- ii = ECalUtils.getHistoIDFromRowColumn(row, column);
+ ii = EcalMonitoringUtilities.getHistoIDFromRowColumn(row, column);
if ((row != 0) && (column != 0)) {
- if (!ECalUtils.isInHole(row, column)) {
+ if (!EcalMonitoringUtilities.isInHole(row, column)) {
if (isFirstRaw[ii]) { // at the very first hit we read for this channel, we need to read the window length and save it
isFirstRaw[ii] = false;
windowRaw[ii] = hit.getADCValues().length;
@@ -84,9 +85,9 @@
for (int ii = 0; ii < 11 * 47; ii++) {
int row, column;
- row = ECalUtils.getRowFromHistoID(ii);
- column = ECalUtils.getColumnFromHistoID(ii);
- if (ECalUtils.isInHole(row, column))
+ row = EcalMonitoringUtilities.getRowFromHistoID(ii);
+ column = EcalMonitoringUtilities.getColumnFromHistoID(ii);
+ if (EcalMonitoringUtilities.isInHole(row, column))
continue;
if ((row == 0) || (column == 0))
continue;
|