Commit in hps-java/src/main/java/org/lcsim/hps/users/omoreno on MAIN
SvtPerformance.java+66-361.8 -> 1.9
Add more output variables; add variable names such that they are recognized by the converter

hps-java/src/main/java/org/lcsim/hps/users/omoreno
SvtPerformance.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- SvtPerformance.java	31 Oct 2013 21:54:04 -0000	1.8
+++ SvtPerformance.java	12 Nov 2013 08:07:19 -0000	1.9
@@ -2,6 +2,7 @@
 
 import hep.aida.IHistogram1D;
 import hep.aida.IPlotter;
+import hep.physics.vec.BasicHep3Vector;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -31,7 +32,7 @@
  * Driver that looks at the performance of the SVT.
  * 
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtPerformance.java,v 1.8 2013/10/31 21:54:04 omoreno Exp $
+ * @version $Id: SvtPerformance.java,v 1.9 2013/11/12 08:07:19 omoreno Exp $
  */
 public class SvtPerformance extends Driver {
 
@@ -46,7 +47,7 @@
 
     int plotterIndex = 0;
 
-    double totalNumberOfEvents = 0;
+    int eventNumber = 0; 
     double totalTracks = 0;
     double totalTwoTrackEvents = 0;
     double idealNoise = 886; // e-
@@ -62,8 +63,9 @@
     // Plot Flags
     boolean plotClustersPerLayer = false;
     boolean plotMIP = false;
-
-    public SvtPerformance() {
+    boolean batchMode = true; 
+    
+    public SvtPerformance(){
     }
 
     // --- Setters ---//
@@ -72,24 +74,17 @@
     /**
      * Enable/disble debug mode
      */
-    public void setEnableDebug(boolean debug) {
+    public void setEnableDebug(boolean debug){
         this.debug = debug;
     }
 
     /**
-     * 
-     */
-    public void setSensorName(String sensorName) {
-        this.sensorName = sensorName;
-    }
-
-    /**
      * Enable/disable plotting the number of clusters per layer. Only clusters
      * from stereo hits associated with a track are used.
      * 
      * @param true or false
      */
-    public void setPlotClustersPerLayer(boolean plotClustersPerLayer) {
+    public void setPlotClustersPerLayer(boolean plotClustersPerLayer){
         this.plotClustersPerLayer = plotClustersPerLayer;
     }
 
@@ -99,17 +94,26 @@
      * 
      * @param true or false
      */
-    public void setPlotClusterCharge(boolean plotMIP) {
+    public void setPlotClusterCharge(boolean plotMIP){
         this.plotMIP = plotMIP;
     }
 
     /**
+     *	Enable/disable batch mode.  If set to true, plots are not shown.
+     *
+     * @param true or false
+     */
+    public void setBatchMode(boolean batchMode){
+    	this.batchMode = batchMode; 
+    }
+    
+    /**
      * Set the name of the file to which data will be written.
      * 
      * @param outputFileName
      *            : Name of the output file
      */
-    public void setOutputFileName(String outputFileName) {
+    public void setOutputFileName(String outputFileName){
         this.outputFileName = outputFileName;
     }
 
@@ -160,10 +164,22 @@
 
                 writer = new BufferedWriter(new FileWriter(outputFile.getAbsoluteFile()));
 
+                writer.write("! event\n");
+                writer.write("! volume\n");
+                writer.write("! layer\n");
+                writer.write("! channel\n");
+                writer.write("! noise\n");
+                writer.write("! cluster_hits\n");
+                writer.write("! bad_channel\n");
+                writer.write("! chi_squared\n");
+                writer.write("! hit_x\n");
+                writer.write("! hit_y\n");
+                
             } catch (IOException exception) {
                 exception.printStackTrace();
             }
 
+            
             plotters.add(PlotUtils.setupPlotter("Cluster Charge", 5, 4));
             for (HpsSiSensor sensor : sensors) {
                 if (sensor.isTopLayer()) {
@@ -178,39 +194,49 @@
             plotterIndex++;
         }
 
-        // Show the plotters
-        for (IPlotter plotter : plotters)
-            plotter.show();
+        if(batchMode) return;
+        
+        // Show the plotters        
+        for (IPlotter plotter : plotters) plotter.show();
 
     }
 
     public void process(EventHeader event) {
-        totalNumberOfEvents++;
-
+    	eventNumber++; 
+    	
         if (!event.hasCollection(Track.class, trackCollectionName))
             return;
         List<Track> tracks = event.get(Track.class, trackCollectionName);
 
         HpsSiSensor sensor = null;
         String plotTitle = null;
-        int channel;
+        int channel, bad_channel;
         int maxClusterChannel = 0; 
         int hitsPerCluster = 0;  
         ChannelConstants constants = null;
         HPSShapeFitParameters fit = null;
         double clusterAmplitude, maxClusterAmplitude;
         double noise = 0;
+        double chi_squared = -1;
+        double hitX, hitY; 
 
         // Loop over all tracks in an event
         for (Track track : tracks) {
-            double[] topClusters = new double[10];
+        
+        	if((new BasicHep3Vector(track.getTrackStates().get(0).getMomentum())).magnitude() <= .500) continue;
+            
+        	double[] topClusters = new double[10];
             double[] bottomClusters = new double[10];
             // Loop over all stereo hits associated with a track
+            hitX = 0; hitY = 0; 
             for (TrackerHit trackerHit : track.getTrackerHits()) {
-
+          	
+            	hitX = trackerHit.getPosition()[1];
+            	hitY = trackerHit.getPosition()[2];
+            	
                 // Loop over the strip hits used to crate the stereo hit
                 for (HelicalTrackStrip stripHit : ((HelicalTrackCross) trackerHit).getStrips()) {
-
+                	
                     sensor = (HpsSiSensor) ((RawTrackerHit) stripHit.rawhits().get(0)).getDetectorElement();
                     if (sensor.isTopLayer())
                         topClusters[sensor.getLayerNumber() - 1] += 1;
@@ -220,17 +246,27 @@
                     maxClusterAmplitude = 0;
                     clusterAmplitude = 0;
                     hitsPerCluster = stripHit.rawhits().size();
-                    noise = 0; 
+                    noise = 0;
+                    bad_channel = 0;
+                    chi_squared = -1;
                     for (Object rh : stripHit.rawhits()) {
 
                         RawTrackerHit rawHit = (RawTrackerHit) rh;
                         channel = rawHit.getIdentifierFieldValue("strip");
+                        // Check if the channel neighbors a channel that has been tagged as bad
+                        if(HPSSVTCalibrationConstants.isBadChannel(sensor, channel+1) 
+                        		|| HPSSVTCalibrationConstants.isBadChannel(sensor, channel-1)){
+                        	bad_channel = 1; 
+                        }
                         constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
                         fit = shaperFitter.fitShape(rawHit, constants);
                         if (fit.getAmp() > maxClusterAmplitude) {
                             maxClusterChannel = channel;
                             maxClusterAmplitude = fit.getAmp();
                         }
+                        if(stripHit.rawhits().size() == 1){
+                        	chi_squared = fit.getChiSq();
+                        }
                         noise += Math.pow(constants.getNoise(), 2);
                         clusterAmplitude += fit.getAmp();
                     }
@@ -241,15 +277,15 @@
                         try {
                             if (sensor.isTopLayer()) {
                                 plotTitle = "Top - Layer " + sensor.getLayerNumber() + " - Cluster Charge";
-                                writer.write("0 " + sensor.getLayerNumber() + " " + maxClusterChannel + " " +  clusterAmplitude + " ");
-                                writer.write(noise + " " + hitsPerCluster + "\n");
+                                writer.write(eventNumber + " 0 " + sensor.getLayerNumber() + " " + maxClusterChannel + " ");
                             } else {
                                 plotTitle = "Bottom - Layer " + sensor.getLayerNumber() + " - Cluster Charge";
-                                writer.write("1 " + sensor.getLayerNumber() + " " + maxClusterChannel + " " +  clusterAmplitude + " ");
-                                writer.write(noise + " " + hitsPerCluster + "\n");
+                                writer.write(eventNumber + " 1 " + sensor.getLayerNumber() + " " + maxClusterChannel + " ");
                             }
+                                writer.write(clusterAmplitude + " " + noise + " " + hitsPerCluster + " " + bad_channel + " " 
+                                			+ chi_squared + " " + hitX + " " + hitY + "\n");
                         } catch (IOException exception) {
-
+                        	exception.printStackTrace(); 
                         }
                         aida.histogram1D(plotTitle).fill(clusterAmplitude);
                     }
@@ -289,11 +325,5 @@
         } catch (IOException exception) {
             exception.printStackTrace();
         }
-
-        System.out.println("%===================================================================% \n");
-        System.out.println("Number of tracks per event: " + (totalTracks / totalNumberOfEvents));
-        System.out.println("Number of events with two tracks per event: " + (totalTwoTrackEvents / totalNumberOfEvents));
-        System.out.println("\n%===================================================================% \n");
-
     }
 }
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