Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/users/omoreno on MAIN
SvtTrackRecoEfficiency.java+52-621.2 -> 1.3
Improved HelicalTrackStrip/SimTrackerHit matching

hps-java/src/main/java/org/lcsim/hps/users/omoreno
SvtTrackRecoEfficiency.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SvtTrackRecoEfficiency.java	25 Sep 2012 01:57:48 -0000	1.2
+++ SvtTrackRecoEfficiency.java	25 Sep 2012 15:40:40 -0000	1.3
@@ -1,21 +1,22 @@
 package org.lcsim.hps.users.omoreno;
 
 //--- java ---//
-import hep.aida.ICloud2D;
-import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-import hep.aida.IPlotter;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.TreeMap;
 import java.util.ArrayList;
 
+//--- aida ---//
+import hep.aida.IHistogram1D;
+import hep.aida.IPlotter;
+
+//--- hep ---//
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+
 //--- lcsim ---//
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
@@ -32,9 +33,8 @@
 import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
 import org.lcsim.geometry.Detector;
 
-import org.lcsim.hps.monitoring.AIDAFrame;
-import org.lcsim.hps.recon.tracking.SvtUtils;
 //--- hps-java ---//
+import org.lcsim.hps.recon.tracking.SvtUtils;
 import org.lcsim.hps.recon.tracking.TrackAnalysis;
 import org.lcsim.hps.recon.tracking.TrackUtils;
 import org.lcsim.hps.recon.tracking.FindableTrack;
@@ -42,7 +42,7 @@
 /**
  * 
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtTrackRecoEfficiency.java,v 1.2 2012/09/25 01:57:48 omoreno Exp $ 
+ * @version $Id: SvtTrackRecoEfficiency.java,v 1.3 2012/09/25 15:40:40 omoreno Exp $ 
  */
 public class SvtTrackRecoEfficiency extends Driver {
 
@@ -50,7 +50,7 @@
     private List<IPlotter>     plotters = new ArrayList<IPlotter>();
     private List<IHistogram1D> histo1D = new ArrayList<IHistogram1D>();
     private List<SimTrackerHit> simTrackerHits = new ArrayList<SimTrackerHit>();
-    private Map<Track, TrackAnalysis> trkToTrkAnalysis = new HashMap<Track, TrackAnalysis>();
+    //private Map<Track, TrackAnalysis> trkToTrkAnalysis = new HashMap<Track, TrackAnalysis>();
 
     TrackUtils trkUtils = new TrackUtils();
     FindableTrack findable = null;
@@ -80,7 +80,8 @@
     /**
      *  Enable/Disable debug
      */
-    public void setDebug(boolean debug){
+    public void setDebug(boolean debug)
+    {
         this.debug = debug;
     }
     
@@ -116,8 +117,7 @@
     /**
      * Dflt Ctor
      */
-    public SvtTrackRecoEfficiency(){
-    }
+    public SvtTrackRecoEfficiency(){}
 
     @Override
     protected void process(EventHeader event)
@@ -194,7 +194,7 @@
         }
         
         // Relate a stereo hits to a SimTrackerHit; This is a required argument by TrackAnalysis
-        RelationalTable<HelicalTrackHit, SimTrackerHit> hitToMC = 
+        RelationalTable<HelicalTrackHit, MCParticle> hitToMC = 
                 stereoHitToMC(event.get(HelicalTrackHit.class, stereoHitCollectionName), simTrackerHits);
         
         // Check if an MC particle is related to a found track
@@ -221,7 +221,8 @@
         }
     }
     
-    private boolean isSameSvtVolume(Set<SimTrackerHit> simTrackerHits){
+    private boolean isSameSvtVolume(Set<SimTrackerHit> simTrackerHits)
+    {
         int volumeIndex = 0;
         for(SimTrackerHit simTrackerHit : simTrackerHits){
             if(SvtUtils.getInstance().isTopLayer((SiSensor) simTrackerHit.getDetectorElement())) volumeIndex++;
@@ -230,10 +231,11 @@
         return Math.abs(volumeIndex) == simTrackerHits.size();
     }
 
-    private RelationalTable<HelicalTrackHit, SimTrackerHit> stereoHitToMC(List<HelicalTrackHit> stereoHits, List<SimTrackerHit> simTrackerHits){
-        RelationalTable hitToMC = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
+    private RelationalTable<HelicalTrackHit, MCParticle> stereoHitToMC(List<HelicalTrackHit> stereoHits, List<SimTrackerHit> simTrackerHits)
+    {
+        RelationalTable<HelicalTrackHit, MCParticle> hitToMC 
+            = new BaseRelationalTable<HelicalTrackHit, MCParticle>(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
         Map<Integer, List<SimTrackerHit>> layerToSimTrackerHit = new HashMap<Integer, List<SimTrackerHit>>();
-        Map<Integer, List<HelicalTrackStrip>> layerToHelicalTrackStrip = new HashMap<Integer, List<HelicalTrackStrip>>();
         
         // Sort the SimTrackerHits by Layer
         for(SimTrackerHit simTrackerHit : simTrackerHits){
@@ -241,16 +243,38 @@
                 layerToSimTrackerHit.put(simTrackerHit.getLayer(), new ArrayList<SimTrackerHit>());
             layerToSimTrackerHit.get(simTrackerHit.getLayer()).add(simTrackerHit);
         }
-
+        
+        // 
         for(HelicalTrackHit stereoHit : stereoHits){
             HelicalTrackCross cross = (HelicalTrackCross) stereoHit;
                 for(HelicalTrackStrip strip : cross.getStrips()){
-                    if(layerToSimTrackerHit.get(strip.layer()).size() == 1){
-                        hitToMC.add(stereoHit, layerToSimTrackerHit.get(strip.layer()).get(0).getMCParticle());
-                        layerToSimTrackerHit.remove(strip.layer());
+                    // If there is only a single SimTrackerHit on a layer and it's in the same volume as the
+                    // stereo hit then they likely match to each other
+                    if(layerToSimTrackerHit.get(strip.layer()) != null && layerToSimTrackerHit.get(strip.layer()).size() == 1){
+                        Hep3Vector simTrackerHitPosition = layerToSimTrackerHit.get(strip.layer()).get(0).getPositionVec();
+                        if(Math.signum(simTrackerHitPosition.y()) == Math.signum(this.getClusterPosition(strip).z())){
+                            hitToMC.add(stereoHit, layerToSimTrackerHit.get(strip.layer()).get(0).getMCParticle()); 
+                            layerToSimTrackerHit.remove(strip.layer());
+                            System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitPosition.toString());
+                            System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
+                        } else {
+                            System.out.println(this.getClass().getSimpleName() + ": Cluster and SimTrackerHit are on different volumes");
+                        }
                     }
                     else if(layerToSimTrackerHit.get(strip.layer()).size() > 1){
                         System.out.println(this.getClass().getSimpleName() + ": Layer with multiple hits found.");
+                        double deltaZ = Double.MAX_VALUE;
+                        SimTrackerHit simTrackerHitMatch = null;
+                        for(SimTrackerHit simTrackerHit : layerToSimTrackerHit.get(strip.layer())){
+                            if(Math.abs(simTrackerHit.getPositionVec().y() - this.getClusterPosition(strip).z()) < deltaZ){
+                                deltaZ = Math.abs(simTrackerHit.getPositionVec().y() - this.getClusterPosition(strip).z());
+                                simTrackerHitMatch = simTrackerHit;
+                            }
+                        }
+                        hitToMC.add(stereoHit, simTrackerHitMatch.getMCParticle()); 
+                        layerToSimTrackerHit.remove(strip.layer()).remove(simTrackerHitMatch);
+                        System.out.println(this.getClass().getSimpleName() + ": SimTrackerHit position: " + simTrackerHitMatch.getPositionVec().toString());
+                        System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + this.getClusterPosition(strip));
                     }
                 }
             }
@@ -258,41 +282,8 @@
         return hitToMC;
     }
     
-    public boolean isTrackFindable(MCParticle mcParticle, int nLayers){
-        
-        if(nLayers%2 == 1) throw new RuntimeException(this.getClass().getSimpleName() + ": The required number of layers hit must be even");
-        
-        System.out.println(this.getClass().getSimpleName() + ": The number of relations in the table are: " + simHitToMcParticle.size());
-        
-        System.out.println(this.getClass().getSimpleName() + ": Number of SimTrackerHits associated with the MC Particle: " + simHitToMcParticle.allTo(mcParticle).size());
-        
-        // Get the list of SimTrackerHits associated with the MC particle
-        Set<SimTrackerHit> simHits = simHitToMcParticle.allTo(mcParticle);
-        
-        System.out.println("Number of simtracker hits " + simHits.size());
-        
-        // Find the layers hit
-        boolean[] layerHit = new boolean[totalLayersHit];
-        for(SimTrackerHit simHit : simHits){
-            layerHit[simHit.getLayer()-1] = true;
-        }
-        
-        int nLayersHit = 0;
-        // Check how many pairs of layers were hit
-        for(int index = 0; index < totalLayersHit; index += 2){
-            System.out.println(this.getClass().getSimpleName() + ": " + layerHit[index] + " " + layerHit[index+1]);
-            if(layerHit[index] && layerHit[index+1]){
-                System.out.println(this.getClass().getSimpleName() + ": Layer was hit!");
-                nLayersHit += 2;
-            }
-        }
-        
-        System.out.println(this.getClass().getSimpleName() + ": Number of layers hit: " + nLayersHit);
-        
-        return nLayers == nLayersHit;
-    }
-    
-    private Hep3Vector getClusterPosition(HelicalTrackStrip strip){
+    private Hep3Vector getClusterPosition(HelicalTrackStrip strip)
+    {
         Hep3Vector origin = strip.origin();
         Hep3Vector u = strip.u();
         double umeas = strip.umeas();
@@ -301,9 +292,8 @@
     }
 
    @Override
-    public void endOfData(){
-	   	
-	   	
+   public void endOfData()
+   { 	
        if(trackingEfficiencyPlots){
            double[] efficiency = new double[60];
 	   	    for(int index = 0; index < 60; index++){
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