Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/users/omoreno on MAIN
SvtQA.java+724-4761.4 -> 1.5
Added some more plots

hps-java/src/main/java/org/lcsim/hps/users/omoreno
SvtQA.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- SvtQA.java	30 Jul 2012 04:20:31 -0000	1.4
+++ SvtQA.java	8 Jan 2013 08:11:32 -0000	1.5
@@ -5,6 +5,8 @@
 import hep.aida.IHistogram2D;
 import hep.aida.IPlotter;
 
+import java.io.BufferedWriter;
+import java.io.FileWriter;
 //--- Java ---//
 import java.io.IOException;
 import java.util.ArrayList;
@@ -17,19 +19,28 @@
 import org.lcsim.detector.tracker.silicon.SiSensor;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackCross;
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
 import org.lcsim.geometry.Detector;
+import org.lcsim.recon.tracking.seedtracker.SeedTrack;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 
 //--- hps-java ---//
 import org.lcsim.hps.monitoring.AIDAFrame;
+import org.lcsim.hps.recon.tracking.HPSFittedRawTrackerHit;
 import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants;
 import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants.ChannelConstants;
 import org.lcsim.hps.recon.tracking.HPSShapeFitParameters;
 import org.lcsim.hps.recon.tracking.HPSShaperAnalyticFitAlgorithm;
 import org.lcsim.hps.recon.tracking.SvtUtils;
+import org.lcsim.hps.recon.tracking.TrackUtils;
 import org.lcsim.hps.util.Pair;
+import org.lcsim.hps.recon.tracking.apv25.SvtReadout;
+
 
 //--- Constants ---//
 import static org.lcsim.hps.recon.tracking.HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR;
@@ -38,204 +49,231 @@
  * SVT Quality Assurance Driver
  *  
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtQA.java,v 1.4 2012/07/30 04:20:31 omoreno Exp $
+ * @version $Id: SvtQA.java,v 1.5 2013/01/08 08:11:32 omoreno Exp $
  */
 public class SvtQA extends Driver {
-	
-	private AIDA aida;
-	private List<AIDAFrame>    frames   = new ArrayList<AIDAFrame>();
-	private List<IHistogram1D> histos1D = new ArrayList<IHistogram1D>();
-	private List<IHistogram2D> histos2D = new ArrayList<IHistogram2D>();
-	private List<IPlotter>     plotters = new ArrayList<IPlotter>();
-	HPSShaperAnalyticFitAlgorithm shaperFitter = new HPSShaperAnalyticFitAlgorithm();
-	int plotterIndex = 0;
-	String outputFile = "Test.pdf";
-	int channelNumber = 0;
-	int apvNumber = 0;
-	String sensorName = null;
-	Map<String, double[]> sensorToOccupancy = new HashMap<String, double[]>();
-	Map<String, double[]> sensorToStereoOccupancy = new HashMap<String, double[]>();
-	int totalNumberEvents = 0;
-	double maxOccupancy = 1.0;
-	double maxOccupancyVariation = 1000; // %
-	
-	// Plot flags
-	boolean enableADCvsChannel = false;
-	boolean enableOccupancy    = false;
-	boolean enableStereoHitOccupancy = false;
-	boolean enableChannelPlots = false;
-	boolean enableAPVPlots     = false;
-	boolean enableChiSquaredvsChannel = false;
-	boolean enableSamples = false;
-	
-	// Collection Names
+
+    private AIDA aida;
+    private HPSShaperAnalyticFitAlgorithm shaperFitter = new HPSShaperAnalyticFitAlgorithm();
+    TrackUtils trkUtils = new TrackUtils();
+    private List<AIDAFrame>    frames   = new ArrayList<AIDAFrame>();
+    private List<IHistogram1D> histos1D = new ArrayList<IHistogram1D>();
+    private List<IHistogram2D> histos2D = new ArrayList<IHistogram2D>();
+    private List<IPlotter>     plotters = new ArrayList<IPlotter>();
+    private Map<String, double[]> sensorToOccupancy = new HashMap<String, double[]>();
+    private Map<String, double[]> sensorToStereoOccupancy = new HashMap<String, double[]>();
+    BufferedWriter output = null;
+
+    String outputFile = null;
+    String sensorName = null;
+
+    int channelNumber = 0;
+    int plotterIndex = 0;
+    int apvNumber = 0;	
+    double totalNumberEvents = 0;
+    double totalNumberOfRawHitEvents = 0;
+    double[] totalTopSamples = new double[6];
+    double[] totalBottomSamples = new double[6];
+    double[] topSamples = new double[6];
+    double[] bottomSamples = new double[6];
+    double totalNumberOfHits = 0;
+    
+    double maxOccupancy = 1.0;
+    double maxOccupancyVariation = 1000; // %
+
+    boolean verbose = false;
+    boolean simulation = false;
+
+    // Plot flags
+    boolean enableADCvsChannel = false;
+    boolean enableOccupancy    = false;
+    boolean enableStereoHitOccupancy = false;
+    boolean enableChannelPlots = false;
+    boolean enableAPVPlots     = false;
+    boolean enableChiSquaredvsChannel = false;
+    boolean enableSamples = false;
+    boolean enableT0Plots = false;
+    boolean enableTotalNumberOfHitsPlots = false;
+
+    // Collection Names
     private String trackCollectionName = "MatchedTracks";
-    private String rawTrackerHitCollectionName = "SVTRawTrackerHits";
+    private String rawHitCollectionName = "SVTRawTrackerHits";
     private String stereoHitCollectionName = "RotatedHelicalTrackHits";
-	
-	public SvtQA(){}
+    private String fittedHitCollectionName = "SVTFittedRawTrackerHits";
+
+    /**
+     * Default Ctor
+     */
+    public SvtQA(){
+    }
+
+    //--- Setters ---//
+    //---------------//
+    /**
+     * Enable/disable occupancy plots
+     */
+    public void setEnableOccupancyPlots(boolean enableOccupancy){
+        this.enableOccupancy = enableOccupancy;
+    }
+
+    /**
+     * Enable/disable stereo hit occupancy plots
+     */
+    public void setEnableStereoHitOccupancyPlots(boolean enableStereoHitOccupancy){
+        this.enableStereoHitOccupancy = enableStereoHitOccupancy;
+    }
+
+    /**
+     * Enable/disable ADC counts vs Channel plots 
+     */
+    public void setEnableADCvsChannelPlots(boolean enableADCvsChannel){
+        this.enableADCvsChannel = enableADCvsChannel;
+    }
+
+    /**
+     * Enable/disable Channel Plots
+     */
+    public void setEnableChannelPlots(boolean enableChannelPlots){
+        this.enableChannelPlots = enableChannelPlots;
+    }
+
+    /**
+     * Enable/disable plots associated with individual APVs 
+     */
+    public void setEnableAPVPlots(boolean enableAPVPlots){
+        this.enableAPVPlots = enableAPVPlots;
+    }
+
+    /**
+     * Enable/disable Chi Squared of fit to samples vs Channel plots 
+     */
+    public void setEnableChiSquaredvsChannelPlots(boolean enableChiSquaredvsChannel){
+        this.enableChiSquaredvsChannel = enableChiSquaredvsChannel;
+    }
+
+    /**
+     * Enable/disable plots of the APV samples
+     */
+    public void setEnableSamplesPlots(boolean enableSamples){
+        this.enableSamples = enableSamples;
+    }
+
+    /**
+     * Enable/disable t0 plots 
+     */
+    public void setEnableT0Plots(boolean enableT0Plots){
+        this.enableT0Plots = enableT0Plots;
+    }
+
+    /**
+     * Set the channel number of interest 
+     */
+    public void setChannelNumber(int channelNumber){
+        this.channelNumber = channelNumber;
+    }
+
+    /**
+     * Set the sensor of interest 
+     */
+    public void setSensorName(String sensorName){
+        this.sensorName = sensorName;
+    }
 
-	
-	//--- Setters ---//
-	//---------------//
-	
-	/**
-	 * Enable/disable occupancy plots
-	 */
-	public void setEnableOccupancyPlots(boolean enableOccupancy){
-	    this.enableOccupancy = enableOccupancy;
-	}
-	
-	/**
-	 * Enable/disable stereo hit occupancy plots
-	 */
-	public void setEnableStereoHitOccupancyPlots(boolean enableStereoHitOccupancy){
-	    this.enableStereoHitOccupancy = enableStereoHitOccupancy;
-	}
-	
-	/**
-	 * Enable/disable ADC counts vs Channel plots 
-	 */
-	public void setEnableADCvsChannelPlots(boolean enableADCvsChannel){
-		this.enableADCvsChannel = enableADCvsChannel;
-	}
-	
-	/**
-	 * Enable/disable Channel Plots
-	 */
-	public void setEnableChannelPlots(boolean enableChannelPlots){
-		this.enableChannelPlots = enableChannelPlots;
-	}
-	
-	/**
-	 * Enable/disable plots associated with individual APVs 
-	 */
-	public void setEnableAPVPlots(boolean enableAPVPlots){
-	    this.enableAPVPlots = enableAPVPlots;
-	}
-	
-	/**
-	 * Enable/disable Chi Squared of fit to samples vs Channel plots 
-	 */
-	public void setEnableChiSquaredvsChannelPlots(boolean enableChiSquaredvsChannel){
-	    this.enableChiSquaredvsChannel = enableChiSquaredvsChannel;
-	}
-	
-	/**
-	 * Enable/disable plots of the APV samples
-	 */
-	public void setEnableSamplesPlots(boolean enableSamples){
-	    this.enableSamples = enableSamples;
-	}
-	
-	/**
-	 * Set the channel number of interest 
-	 */
-	public void setChannelNumber(int channelNumber){
-	    this.channelNumber = channelNumber;
-	}
-	
-	/**
-	 * Set the sensor of interest 
-	 */
-	public void setSensorName(String sensorName){
-	    this.sensorName = sensorName;
-	}
-	
-	/**
-	 * Set the APV number of interest
-	 */
-	public void setApvNumber(int apvNumber){
-	    this.apvNumber = apvNumber;
-	}
-	
-	/**
-	 * Set the maximum occupancy a channel may have    
-	 */
-	public void setMaxOccupancy(double maxOccupancy){
-	    this.maxOccupancy = maxOccupancy;
-	}
-	
-	/**
-	 * Set the maximum channel to channel occupancy variation
-	 */
-	public void setMaxOccupancyVariation(double maxOccupancyVariation){
-	    this.maxOccupancyVariation = maxOccupancyVariation;
-	}
-	
-	/**
-	 * 
-	 */
-	public void setOutputFileName(String outputFile){
-	    this.outputFile = outputFile;
-	}
-	
-	/**
-	 * 
-	 */
-	private int getAPVNumber(int physicalChannel){
-	    int apv = (int) Math.floor((physicalChannel - TOTAL_STRIPS_PER_SENSOR)/-128);
-	    if(apv > 4 || apv < 0) throw new RuntimeException("Invalid APV Number: " + apv );
-	    return apv;
-	}  
-	
-	   /**
+    /**
+     * Set the APV number of interest
+     */
+    public void setApvNumber(int apvNumber){
+        this.apvNumber = apvNumber;
+    }
+
+    /**
+     * Set the maximum occupancy a channel may have    
+     */
+    public void setMaxOccupancy(double maxOccupancy){
+        this.maxOccupancy = maxOccupancy;
+    }
+
+    /**
+     * Set the maximum channel to channel occupancy variation
+     */
+    public void setMaxOccupancyVariation(double maxOccupancyVariation){
+        this.maxOccupancyVariation = maxOccupancyVariation;
+    }
+
+    /**
      * 
      */
-    private int getPlotterRegion(SiSensor sensor) {
+    public void setOutputFileName(String outputFile){
+        this.outputFile = outputFile;
+    }
 
-        int layer = SvtUtils.getInstance().getLayerNumber(sensor);
+    /**
+     *
+     */
+    public void setVerbose(boolean verbose){
+        this.verbose = verbose;
+    }
 
-        // Compute the sensor's x and y grid coordinates and then translate to region number.
-        int ix = (layer - 1) / 2;
-        int iy = 0;
-        if (!SvtUtils.getInstance().isTopLayer(sensor)) {
-            iy += 2;
-        }
-        if (layer % 2 == 0) {
-            iy += 1;
-        }
-        int region = ix * 4 + iy;
-        return region;
-    } 
-	
-	protected void detectorChanged(Detector detector){
-		
-		// setup AIDA
-		aida = AIDA.defaultInstance();
-		aida.tree().cd("/");
-	
-		// Create AIDA Frames
-		for(int index = 0; index < 2; index++) frames.add(new AIDAFrame());
-	
-		// Set frame titles
-		frames.get(0).setTitle("Occupancy");
-		frames.get(1).setTitle("ADC Counts");
-		
-		//
-		Set<SiSensor> sensors = SvtUtils.getInstance().getSensors();
-		int plotterIndex = 0;
-		IHistogram1D histo1D = null;
-		IHistogram2D histo2D = null;
-		String title;
-		
-
-		//--- Occupancy ---//
-		//-----------------//
-		if(enableOccupancy){
-			plotters.add(PlotUtils.setupPlotter("Occupancy", 5, 4));
-		    for(SiSensor sensor : sensors){
-		    	sensorToOccupancy.put(SvtUtils.getInstance().getDescription(sensor), new double[640]);
-		        title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
-		        histo1D = aida.histogram1D(title, 640, 0, 639);
-		        histos1D.add(histo1D);
-		        PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, this.getPlotterRegion(sensor), "Channel #", histo1D);
-		    }
-		    frames.get(0).addPlotter(plotters.get(plotterIndex));
-		    plotterIndex++;
-		}
-		
-	    //--- Stereo Hit Occupancy ---//
+    /**
+     *
+     */
+    public void setSimulation(boolean simulation){
+        this.simulation = simulation;
+    }
+    
+    /**
+     * 
+     */
+    public void setEnableTotalNumberOfHitsPlots(boolean enableTotalNumberOfHitsPlots){
+    	this.enableTotalNumberOfHitsPlots = enableTotalNumberOfHitsPlots;
+    }
+
+    /**
+     * 
+     */
+    private int getAPVNumber(int physicalChannel){
+        int apv = (int) Math.floor((physicalChannel - TOTAL_STRIPS_PER_SENSOR)/-128);
+        if(apv > 4 || apv < 0) throw new RuntimeException("Invalid APV Number: " + apv );
+        return apv;
+    }  
+
+    protected void detectorChanged(Detector detector){
+        super.detectorChanged(detector);
+
+        // setup AIDA
+        aida = AIDA.defaultInstance();
+        aida.tree().cd("/");
+
+        // Create AIDA Frames
+        for(int index = 0; index < 2; index++) frames.add(new AIDAFrame());
+
+        // Set frame titles
+        frames.get(0).setTitle("Occupancy");
+        frames.get(1).setTitle("ADC Counts");
+
+        //
+        Set<SiSensor> sensors = SvtUtils.getInstance().getSensors();
+        int plotterIndex = 0;
+        IHistogram1D histo1D = null;
+        IHistogram2D histo2D = null;
+        String title = null;
+
+        //--- Occupancy ---//
+        //-----------------//
+        if(enableOccupancy){
+            plotters.add(PlotUtils.setupPlotter("Occupancy", 5, 4));
+            for(SiSensor sensor : sensors){
+                sensorToOccupancy.put(SvtUtils.getInstance().getDescription(sensor), new double[640]);
+                title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+                histo1D = aida.histogram1D(title, 640, 0, 639);
+                histos1D.add(histo1D);
+                PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", histo1D);
+            }
+            frames.get(0).addPlotter(plotters.get(plotterIndex));
+            plotterIndex++;
+        }
+
+        //--- Stereo Hit Occupancy ---//
         //----------------------------//
         if(enableStereoHitOccupancy){
             plotters.add(PlotUtils.setupPlotter("Stereo Hit Occupancy", 5, 4));
@@ -244,100 +282,100 @@
                 title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
                 histo1D = aida.histogram1D(title, 640, 0, 639);
                 histos1D.add(histo1D);
-                PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, this.getPlotterRegion(sensor), "Channel #", histo1D);
+                PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", histo1D);
             }
             frames.get(0).addPlotter(plotters.get(plotterIndex));
             plotterIndex++;
         }
-		
-		//--- ADC Counts vs Channel ---//
-		//-----------------------------//
-		if(enableADCvsChannel){
-			if(sensorName.equals("all")){
-				plotters.add(PlotUtils.setupPlotter("ADC Counts vs Channel #", 5, 4));
-				for(SiSensor sensor : sensors){
-				    title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
-				    histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
-				    histos2D.add(histo2D);
-				    PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, this.getPlotterRegion(sensor), "Channel #", "ADC Counts", histo2D);
-				}
-				frames.get(1).addPlotter(plotters.get(plotterIndex));
-				plotterIndex++;
-			} else if(sensorName != null){
-			    title = sensorName + " - ADC Counts vs Channel #";
-				plotters.add(PlotUtils.setupPlotter(title, 0, 0));
-			    histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
-			    histos2D.add(histo2D);
-			    PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 0, "Channel #", "ADC Counts", histo2D);
-			    frames.get(1).addPlotter(plotters.get(plotterIndex));
-				plotterIndex++;
-			} else {
-				throw new RuntimeException("Sensor of interest is not set!");
-			}
-		}
-		
-		//--- Chi Squared vs Channel ---//
-		//------------------------------//
-		if(enableChiSquaredvsChannel){
-		    title = sensorName + " - Chi Squared vs Channel #";
-		    plotters.add(PlotUtils.setupPlotter(title, 0, 0));
+
+        //--- ADC Counts vs Channel ---//
+        //-----------------------------//
+        if(enableADCvsChannel){
+            if(sensorName.equals("all")){
+                plotters.add(PlotUtils.setupPlotter("ADC Counts vs Channel #", 5, 4));
+                for(SiSensor sensor : sensors){
+                    title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
+                    histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
+                    histos2D.add(histo2D);
+                    PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", "ADC Counts", histo2D);
+                }
+                frames.get(1).addPlotter(plotters.get(plotterIndex));
+                plotterIndex++;
+            } else if(sensorName != null){
+                title = sensorName + " - ADC Counts vs Channel #";
+                plotters.add(PlotUtils.setupPlotter(title, 0, 0));
+                histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
+                histos2D.add(histo2D);
+                PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 0, "Channel #", "ADC Counts", histo2D);
+                frames.get(1).addPlotter(plotters.get(plotterIndex));
+                plotterIndex++;
+            } else {
+                throw new RuntimeException("Sensor of interest is not set!");
+            }
+        }
+
+        //--- Chi Squared vs Channel ---//
+        //------------------------------//
+        if(enableChiSquaredvsChannel){
+            title = sensorName + " - Chi Squared vs Channel #";
+            plotters.add(PlotUtils.setupPlotter(title, 0, 0));
             histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 100);
             histos2D.add(histo2D);
             PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 0, "Channel #", "Chi Squared", histo2D);
             frames.get(1).addPlotter(plotters.get(plotterIndex));
             plotterIndex++;
-		}
-		
-		
-		//--- Single Channel Plots ---//
-		//----------------------------//
-		if(enableChannelPlots){
-			if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
-			title = sensorName + " - Channel: " + channelNumber;
-			plotters.add(PlotUtils.setupPlotter(title, 2, 2));
-			title = "ADC Counts";
-			histo1D = aida.histogram1D(title, 300, 4000, 7000);
-			histos1D.add(histo1D);
-			PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
-			title = "Shaper Signal Amplitude";
-			histo1D = aida.histogram1D(title, 300, 0, 3000);
-			histos1D.add(histo1D);
-			PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 1, "Amplitude [ADC Counts]", histo1D);
-	        title = "t0";
-	        histo1D = aida.histogram1D(title, 100, -150, 100);
-	        histos1D.add(histo1D);
-	        PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 2, "t0 [ns]", histo1D);
-			frames.get(1).addPlotter(plotters.get(plotterIndex));
-	        plotterIndex++;
-		}
-
-		//--- APV Plots ---//
-		//-----------------//
-		if(enableAPVPlots){
-		    if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
-		    title = sensorName + " - APV " + apvNumber;
-		    plotters.add(PlotUtils.setupPlotter(title, 2, 2));
-		    title = "APV " + apvNumber + " - ADC Counts";
-		    histo1D = aida.histogram1D(title, 400, 0, 10000);
-		    histos1D.add(histo1D);
-		    PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
-		    title = "APV " + apvNumber + " - Shaper Signal Amplitude";
-		    histo1D = aida.histogram1D(title, 300, 0, 6000);
-		    histos1D.add(histo1D);
-		    PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 1, "Amplitude [ADC Counts]", histo1D);
-		    title = "APV " + apvNumber + " - t0";
-		    histo1D = aida.histogram1D(title, 100, -100, 100);
-		    histos1D.add(histo1D);
-		    PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 2, "t0 [ns]", histo1D);
-		    title = "APV " + apvNumber + " - Amplitude vs t0";
-		    histo2D = aida.histogram2D(title, 300, 0, 6000, 100, -100, 100);
-		    histos2D.add(histo2D);
-		    PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 3, "Amplitude [ADC Counts]", "t0 [ns]", histo2D);
-	        frames.get(1).addPlotter(plotters.get(plotterIndex));
-	        plotterIndex++;   
-		}
-		
-	    //--- Samples Amplitude vs Sample Number ---//
+        }
+
+
+        //--- Single Channel Plots ---//
+        //----------------------------//
+        if(enableChannelPlots){
+            if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
+            title = sensorName + " - Channel: " + channelNumber;
+            plotters.add(PlotUtils.setupPlotter(title, 2, 2));
+            title = "ADC Counts";
+            histo1D = aida.histogram1D(title, 300, 4000, 7000);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
+            title = "Shaper Signal Amplitude";
+            histo1D = aida.histogram1D(title, 300, 0, 3000);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 1, "Amplitude [ADC Counts]", histo1D);
+            title = "t0";
+            histo1D = aida.histogram1D(title, 100, -150, 100);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 2, "t0 [ns]", histo1D);
+            frames.get(1).addPlotter(plotters.get(plotterIndex));
+            plotterIndex++;
+        }
+
+        //--- APV Plots ---//
+        //-----------------//
+        if(enableAPVPlots){
+            if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
+            title = sensorName + " - APV " + apvNumber;
+            plotters.add(PlotUtils.setupPlotter(title, 2, 2));
+            title = "APV " + apvNumber + " - ADC Counts";
+            histo1D = aida.histogram1D(title, 400, 0, 10000);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
+            title = "APV " + apvNumber + " - Shaper Signal Amplitude";
+            histo1D = aida.histogram1D(title, 300, 0, 6000);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 1, "Amplitude [ADC Counts]", histo1D);
+            title = "APV " + apvNumber + " - t0";
+            histo1D = aida.histogram1D(title, 100, -100, 100);
+            histos1D.add(histo1D);
+            PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 2, "t0 [ns]", histo1D);
+            title = "APV " + apvNumber + " - Amplitude vs t0";
+            histo2D = aida.histogram2D(title, 300, 0, 6000, 100, -100, 100);
+            histos2D.add(histo2D);
+            PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 3, "Amplitude [ADC Counts]", "t0 [ns]", histo2D);
+            frames.get(1).addPlotter(plotters.get(plotterIndex));
+            plotterIndex++;   
+        }
+
+        //--- Samples Amplitude vs Sample Number ---//
         //------------------------------------------//
         if(enableSamples){
             title = "APV Sample Number vs Sample Amplitude";
@@ -354,250 +392,460 @@
             frames.get(1).addPlotter(plotters.get(plotterIndex));
             plotterIndex++;
         }
-		
-		for(AIDAFrame frame : frames){
-			frame.pack();
-			frame.setVisible(true);
-		}
-	}
-    
+
+        //--- t0 Plots ---//
+        //----------------//
+        if(enableT0Plots){
+            if(sensorName.equals("all")){
+                plotters.add(PlotUtils.setupPlotter("t0 Resolution vs Channel #", 5, 4));
+                plotters.get(plotterIndex).style().zAxisStyle().setParameter("scale", "log");
+                for(SiSensor sensor : sensors){
+                    title = SvtUtils.getInstance().getDescription(sensor) + " - t0 Resolution vs Channel #";
+                    histo2D = aida.histogram2D(title, 640, 0, 639, 40, -20, 20);
+                    histos2D.add(histo2D);
+                    PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", "t0 Resolution [ns]", histo2D);
+                }
+                frames.get(1).addPlotter(plotters.get(plotterIndex));
+                plotterIndex++;
+            }
+            else if(sensorName != null){
+                title = sensorName + " - Hit Time Resolution";
+                plotters.add(PlotUtils.setupPlotter(title, 0, 0));
+                plotters.get(plotterIndex).style().statisticsBoxStyle().setVisible(true);
+                histo1D = aida.histogram1D(title, 40, -20, 20);
+                histos1D.add(histo1D);
+                PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "<Hit Time> - Hit Time [ns]", histo1D);
+                frames.get(1).addPlotter(plotters.get(plotterIndex));
+                plotterIndex++;
+            }
+            else throw new RuntimeException("Sensor of interest not set!");
+
+        }
+        
+        if(enableTotalNumberOfHitsPlots){
+        	title = "Total Number of RawTrackerHits";
+        	plotters.add(PlotUtils.setupPlotter(title, 0, 0));
+        	plotters.get(plotterIndex).style().statisticsBoxStyle().setVisible(true);
+        	histo1D = aida.histogram1D(title, 100, 0, 75);
+        	histos1D.add(histo1D);
+        	PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Number of RawTrackerHits", histo1D);
+        	frames.get(1).addPlotter(plotters.get(plotterIndex));
+        	plotterIndex++;
+        }
+
+        for(AIDAFrame frame : frames){
+            frame.pack();
+            frame.setVisible(true);
+        }
+    }
+
     /**
      * 
      */
     public int findPeakSamples(short[] samples){
-    	int maxSample = 0;
-    	int maxSampleIndex = 0;
-    	for(int index = 0; index < samples.length; index++){
-    		if(maxSample < samples[index]){
-    			maxSample = samples[index];
-    			maxSampleIndex = index;
-    		}
-    	}
-    	return maxSampleIndex;
+        int maxSample = 0;
+        int maxSampleIndex = 0;
+        for(int index = 0; index < samples.length; index++){
+            if(maxSample < samples[index]){
+                maxSample = samples[index];
+                maxSampleIndex = index;
+            }
+        }
+        return maxSampleIndex;
     }
-	
-	
-    
+
+
+
     public void process(EventHeader event){
-        
+
         totalNumberEvents++;
         String title;
-        
-	    // If the event doesn't contain RawTrackerHits then skip it
-	    if(!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName )) return;
-	
-	    // Get the RawTrackerHits from the event
-	    List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName);
-	    
-	    // If the event does not contain stereo hits, skip the event
-        if(event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)){
-           
-            // Get the list of HelicalTrackHits
-            List<HelicalTrackHit> stereoHits =event.get(HelicalTrackHit.class, stereoHitCollectionName); 
-        
-            for(HelicalTrackHit stereoHit : stereoHits){
-                
-                for(Object hit : stereoHit.getRawHits()){
-                    
-                    RawTrackerHit rawHit = (RawTrackerHit) hit;
-                    
-                    SiSensor sensor = (SiSensor) rawHit.getDetectorElement();
-                    
-                    // Get the channel number
-                    int channel = rawHit.getIdentifierFieldValue("strip");
-                    
-                    // Get the constants associated with this channel
-                    ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
-                    
-                    // Fit the samples associated with the RawTrackerHit
-                    HPSShapeFitParameters fit = shaperFitter.fitShape(rawHit, constants);
-                    
-                    // Get the shaper signal samples
-                    short[] samples = rawHit.getADCValues();
-                    
-                    if(enableStereoHitOccupancy){
-                        title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
-                        sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel] += 1;
-                    }
-                    
-                    // Fill Sample Plots
-                    if(enableSamples){
-                        if(fit.getAmp() > 2000 && fit.getAmp() < 6000){
-                            for(int sampleN = 1; sampleN <= samples.length; sampleN++){
-                                if((sampleN == 1 && totalNumberEvents%5 != 0) || (sampleN == 2 && totalNumberEvents%5 != 0) || (sampleN == 3 && totalNumberEvents%3 != 0)) continue;
-                                if(SvtUtils.getInstance().isTopLayer(sensor))
-                                    aida.histogram2D("APV Sample Number vs Sample Amplitude - Top").fill(sampleN, samples[sampleN-1] - constants.getPedestal());
-                                else
-                                    aida.histogram2D("APV Sample Number vs Sample Amplitude - Bottom").fill(sampleN, samples[sampleN-1] - constants.getPedestal());
 
-                            }
-                        }
-                    }
-                }
-            }
+        // If the event doesn't contain RawTrackerHits then skip it
+        if(!event.hasCollection(RawTrackerHit.class, rawHitCollectionName )){
+            if(verbose) System.out.println("Event doesn't contain RawTrackerHits! Skipping event ...");
+            return;
         }
-    
 
+        // Get the RawTrackerHits from the event
+        List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawHitCollectionName);
+        
+        // Get the total number of RawTrackerHits in the event
+        if(enableTotalNumberOfHitsPlots && rawHits.size() != 0){
+            aida.histogram1D("Total Number of RawTrackerHits").fill(rawHits.size());
+        }
+
+        SiSensor sensor = null;
+        ChannelConstants constants = null;
+        HPSShapeFitParameters fit = null;
+        for(RawTrackerHit rawHit : rawHits){
+
+            // Get the sensor on which this hit occurred
+            sensor = (SiSensor) rawHit.getDetectorElement();
+
+            // Get the shaper signal samples
+            short[] samples = rawHit.getADCValues();
+
+            // Get the channel number
+            int channel = rawHit.getIdentifierFieldValue("strip");
+
+            // Get the APV number
+            int apv = this.getAPVNumber(channel);
 
-	    for(RawTrackerHit rawHit : rawHits){
-	        
-	        // Get the sensor on which this hit occurred
-	        SiSensor sensor = (SiSensor) rawHit.getDetectorElement();
-	        
-	        // Get the shaper signal samples
-	        short[] samples = rawHit.getADCValues();
-	        
-	        // Get the channel number
-	        int channel = rawHit.getIdentifierFieldValue("strip");
-	        
-	        // Get the APV number
-	        int apv = this.getAPVNumber(channel);
-	        
             // Get the constants associated with this channel
-            ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
-	        
+            constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
+
             // Fit the samples associated with the RawTrackerHit
-            HPSShapeFitParameters fit = shaperFitter.fitShape(rawHit, constants);
-	        
-	        // Fill the occupancy plots
-	        if(enableOccupancy){
-	            title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
-	            sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel] += 1;
-	        }
-            
-	        // Fill ADC vs Channel # plots
-	        if(enableADCvsChannel && sensorName.equals("all")){
-			    title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
-			    for(short sample : samples){
-			    	aida.histogram2D(title).fill(channel, sample);
-			    }
-	        } else if(enableADCvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
-	        	title = sensorName + " - ADC Counts vs Channel #";
-			    for(short sample : samples){
-			    	aida.histogram2D(title).fill(channel, sample);
-			    }
-	        }
-	        
-	        // Fill Chi Squared vs Channel # plots
-	        if(enableChiSquaredvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
-	            title = sensorName + " - Chi Squared vs Channel #";
-	            aida.histogram2D(title).fill(channel, fit.getChiSq());
-	        }
-	        
-	        // 
-	        if(enableChannelPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && channel == channelNumber){
-	            title = "ADC Counts";
-	            for(short sample : samples){
-	                aida.histogram1D(title).fill(sample);
-	            }
-	            title = "Shaper Signal Amplitude";
-	            aida.histogram1D(title).fill(fit.getAmp());	    
-	            System.out.println("Amplitude: " + fit.getAmp());
-	            title="t0";
-	            aida.histogram1D(title).fill(fit.getT0());
-	            System.out.println("t0 " + fit.getT0());
-	        }
-	
-	        if(enableAPVPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && apv == apvNumber ){
-	            title = "APV " + apvNumber + " - ADC Counts";
-	            for(short sample : samples){
-	                aida.histogram1D(title).fill(sample);
-	            }
-	            title = "APV " + apvNumber + " - Shaper Signal Amplitude";
-	            aida.histogram1D(title).fill(fit.getAmp());     
-	            title = "APV " + apvNumber + " - t0";
-	            aida.histogram1D(title).fill(fit.getT0());
-	            title = "APV " + apvNumber + " - Amplitude vs t0";
-	            aida.histogram2D(title).fill(fit.getAmp(), fit.getT0());
-	        }
-	    }
-	    
-
-	    
-	    if(enableOccupancy){
-	        for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
-	            title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
-	            aida.histogram1D(title).reset();
-	            for(int index = 0; index < 640; index++){
-	                aida.histogram1D(title).fill(index, sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/event.getEventNumber());
-	            }
-	        }
-	    }
-	    
-	    if(enableStereoHitOccupancy){
-	        for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
-	            title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
-	            aida.histogram1D(title).reset();
-	               for(int index = 0; index < 640; index++){
-	                    aida.histogram1D(title).fill(index, sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/event.getEventNumber());
-	                }
-	        }
-	    }
-	    
-	    
-	    
-	}
-    
-    @Override
-    public void endOfData(){
-        
-        System.out.println("Total Bad Channels: " + HPSSVTCalibrationConstants.getTotalBadChannels() + "\n");
-        
+            fit = shaperFitter.fitShape(rawHit, constants);
+
+            // Fill the occupancy plots
+            if(enableOccupancy){
+                title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+                aida.histogram1D(title).fill(channel, 1);
+            }
+
+            // Fill ADC vs Channel # plots
+            if(enableADCvsChannel && sensorName.equals("all")){
+                title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
+                for(short sample : samples){
+                    aida.histogram2D(title).fill(channel, sample);
+                }
+            } else if(enableADCvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
+                title = sensorName + " - ADC Counts vs Channel #";
+                for(short sample : samples){
+                    aida.histogram2D(title).fill(channel, sample);
+                }
+            }
+
+            // 
+            if(enableChannelPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && channel == channelNumber){
+                title = "ADC Counts";
+                for(short sample : samples){
+                    aida.histogram1D(title).fill(sample);
+                }
+                title = "Shaper Signal Amplitude";
+                aida.histogram1D(title).fill(fit.getAmp());	    
+                System.out.println("Amplitude: " + fit.getAmp());
+                title="t0";
+                aida.histogram1D(title).fill(fit.getT0());
+                System.out.println("t0 " + fit.getT0());
+            }
+
+            if(enableAPVPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && apv == apvNumber ){
+                title = "APV " + apvNumber + " - ADC Counts";
+                for(short sample : samples){
+                    aida.histogram1D(title).fill(sample);
+                }
+                title = "APV " + apvNumber + " - Shaper Signal Amplitude";
+                aida.histogram1D(title).fill(fit.getAmp());     
+                title = "APV " + apvNumber + " - t0";
+                aida.histogram1D(title).fill(fit.getT0());
+                title = "APV " + apvNumber + " - Amplitude vs t0";
+                aida.histogram2D(title).fill(fit.getAmp(), fit.getT0());
+            }
+        }
+
+        /*
         if(enableOccupancy){
             for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
-                System.out.println("%===================================================================%");
-                System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
-                System.out.println("%===================================================================%");
+                title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+                aida.histogram1D(title).reset();
+                int nEvents = simulation ? SvtReadout.getNumberOfTriggers()  : totalNumberEvents; 
                 for(int index = 0; index < 640; index++){
-                    
-                    // Check is the channel can be considered bad    
-                    this.checkChannel(sensor, index);
-                    }
+                    aida.histogram1D(title).fill(index, sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/nEvents);
                 }
-            System.out.println("%===================================================================% \n");
+            }
+        }*/
+
[truncated at 1000 lines; 311 more skipped]
CVSspam 0.2.12


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