Commit in hps-java/src/main/java/org/lcsim/hps/users/omoreno on MAIN
SvtPerformance.java+218added 1.1
SVT Performance Plots

hps-java/src/main/java/org/lcsim/hps/users/omoreno
SvtPerformance.java added at 1.1
diff -N SvtPerformance.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SvtPerformance.java	24 Jul 2012 06:21:52 -0000	1.1
@@ -0,0 +1,218 @@
+package org.lcsim.hps.users.omoreno;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.monitoring.AIDAFrame;
+import org.lcsim.hps.recon.tracking.SvtUtils;
+import org.lcsim.hps.recon.tracking.TrackUtils;
+import org.lcsim.recon.tracking.seedtracker.SeedTrack;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * Svt Performance Plots
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: SvtPerformance.java,v 1.1 2012/07/24 06:21:52 omoreno Exp $
+ */
+public class SvtPerformance 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>();
+	TrackUtils trkUtil = new TrackUtils();
+	
+	double totalTracksFound  = 0;
+	double totalTopTracksFound = 0;
+	double totalBottomTracksFound = 0;
+	double totalNumberEvents = 0;
+	double possibleTracks = 0;
+	double possibleTopTracks = 0;
+	double possibleBottomTracks = 0;
+	
+	double[] topLayers;    
+	double[] bottomLayers;
+	
+	boolean debug = true;
+	boolean topHit = false;
+	
+	// Plot flags
+	
+	// Collection Names
+	private String stereoHitCollectionName = "RotatedHelicalTrackHits";
+	private String trackCollectionName     = "MatchedTracks";
+	
+	public SvtPerformance(){}
+
+	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
+		
+	
+		for(AIDAFrame frame : frames){
+			frame.pack();
+			frame.setVisible(true);
+		}
+	}
+	
+	public void process(EventHeader event){
+		
+		
+		
+		// Increment the event number
+		totalNumberEvents++;
+		topLayers = new double[5];
+		bottomLayers = new double[5];
+
+		// If the event does not contain stereo hits, skip the event
+		if(!event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)) return;
+	
+		// Get the list of HelicalTrackHits
+		List<HelicalTrackHit> stereoHits =event.get(HelicalTrackHit.class, stereoHitCollectionName);
+	
+		for(HelicalTrackHit stereoHit : stereoHits){
+			
+			if(debug)
+				System.out.println(this.getClass().getSimpleName() + " : Stereo Hit position = [" + stereoHit.x()
+						+ ", " + stereoHit.y() + ", " + stereoHit.z() + "]");
+			
+			// Get the layer associated with the stereoHit
+			int layer = stereoHit.Layer();
+			int arrayPosition = (layer - 1)/2;
+			if(debug){
+				System.out.println(this.getClass().getSimpleName() + " : Layer Number: " + layer);
+				System.out.println(this.getClass().getSimpleName() + " : Array Position: " + arrayPosition);
+			}
+			
+			if(layer == 5){
+				for(Object hit : stereoHit.getRawHits()){
+					RawTrackerHit rawHit = (RawTrackerHit) hit;
+					System.out.println("Sensor: " + SvtUtils.getInstance().getDescription((SiSensor) rawHit.getDetectorElement()) + " : Strip " + rawHit.getIdentifierFieldValue("strip")); 
+				}
+			}
+			
+			// Find the detector volume the hit corresponds to
+			if(stereoHit.z() > 0){
+				topLayers[arrayPosition]++;
+				System.out.println(this.getClass().getSimpleName() + " :  Found Top Hit!");
+			}
+			else if(stereoHit.z() < 0){
+				bottomLayers[arrayPosition]++;
+				System.out.println(this.getClass().getSimpleName() + " :  Found Bottom Hit!");
+			}
+			else throw new RuntimeException("Invalid hit position - y = " + stereoHit.y());
+		}
+	
+		/*
+		// Check if there are four consencutive hits on either volume
+		if(this.hasConsecutiveHits(topLayers)){
+			possibleTracks++;
+			possibleTopTracks++;
+		}
+		
+		if(this.hasConsecutiveHits(bottomLayers)){
+			possibleTracks++;
+			possibleBottomTracks++;
+			System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
+		}
+		*/
+		
+		// Check if tracks were actually found
+		if(!event.hasCollection(Track.class, trackCollectionName)){
+
+			System.out.println("No Tracks Were Found!");
+			
+			// Check if there are four consencutive hits on either volume
+			if(this.hasConsecutiveHits(topLayers)){
+				possibleTracks++;
+				possibleTopTracks++;
+				System.out.println(this.getClass().getSimpleName() + " : Found Possible Top Track!");
+			}
+			
+			if(this.hasConsecutiveHits(bottomLayers)){
+				possibleTracks++;
+				possibleBottomTracks++;
+				System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
+			}
+			return;
+		}
+		
+		// Get the list of tracks
+    	List<SeedTrack> tracks = event.get(SeedTrack.class, trackCollectionName);
+    	
+    	// Get the total number of tracks found in the event
+    	double tracksFound = tracks.size();
+    	
+    	// Only look at events with a single track
+    	if(tracksFound >= 2) return;
+    	
+    	totalTracksFound += tracks.size();
+    	
+    	for(SeedTrack track : tracks){
+    		trkUtil.setTrack(track);
+    		
+    		// Check which volume the track corresponds to
+    		if(trkUtil.getZ0() > 0){
+    			totalTopTracksFound++;
+    			System.out.println(this.getClass().getSimpleName() + " : Found Top Track!");
+    		}
+    		else if(trkUtil.getZ0() < 0){
+    			totalBottomTracksFound++;
+    			System.out.println(this.getClass().getSimpleName() + " : Found Bottom Track!");
+    		}
+    	}
+    	
+		// Check if there are four consencutive hits on either volume
+		if(this.hasConsecutiveHits(topLayers)){
+			possibleTracks++;
+			possibleTopTracks++;
+		}
+		
+		if(this.hasConsecutiveHits(bottomLayers)){
+			possibleTracks++;
+			possibleBottomTracks++;
+			System.out.println(this.getClass().getSimpleName() + " : Found Possible Bottom Track!");
+		}
+	}
+	
+	private boolean hasConsecutiveHits(double[] layers){
+		for(int index = 0; index < 2; index++){
+			if(layers[index] > 0 && layers[index + 1] > 0 && layers[index + 2] > 0 && layers[index + 3] > 0){
+				for(int layer = 0; layer < layers.length; layer++){
+					System.out.println("Layer " + layer+1 + " Hits: " + layers[layer]);
+				}
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	@Override
+	public void endOfData(){
+		System.out.println("Number of tracks per event: " + (totalTracksFound/totalNumberEvents) );
+		System.out.println("Total Track Reconstruction Efficiency: " + (totalTracksFound/possibleTracks));
+		System.out.println("Total Top Track Reconstruction Efficiency " + (totalTopTracksFound/possibleTopTracks));
+		System.out.println("Total Bottom Track Reconstruction Efficiency" + (totalBottomTracksFound/possibleBottomTracks));
+	}
+}
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