Print

Print


Commit in lcsim/src/org/lcsim/contrib/seedtracker on MAIN
SeedValidator.java+31-41.1 -> 1.2
MergeSeedLists.java+37-231.3 -> 1.4
+68-27
2 modified files
CD - better metrics for seed validation

lcsim/src/org/lcsim/contrib/seedtracker
SeedValidator.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SeedValidator.java	1 Apr 2008 22:45:05 -0000	1.1
+++ SeedValidator.java	8 Apr 2008 08:44:00 -0000	1.2
@@ -22,6 +22,7 @@
     private MCParticle likelyMC; 
     private Map<MCParticle,Integer> occurs;
     private SeedVerdict verdict; 
+    private double purity=0; 
     
     public enum SeedVerdict{
         SEED_VALID_BUT_MULTIPLE_MCS_IN_HITS,
@@ -54,6 +55,7 @@
         if(occurs.size()==1) {
             likelyMC = (MCParticle) occurs.keySet().toArray()[0];
             verdict = SeedVerdict.SEED_VALID;
+            purity = 1; 
             return;
         }
         
@@ -62,12 +64,18 @@
         List<MCParticle> mcs_in_all_hits = new ArrayList<MCParticle>(); 
         int size = candidate.getHits().size(); 
         
+        int max_hits = 0;
         for (MCParticle p : occurs.keySet()){
-            if(occurs.get(p).intValue()==size){
-                mcs_in_all_hits.add(p);
+            int num_hits = occurs.get(p).intValue();
+            if(num_hits==size) mcs_in_all_hits.add(p);
+            if(num_hits>=max_hits){
+                max_hits=num_hits; 
+                likelyMC = p; 
             }
         }
         
+        purity = ((double)max_hits)/((double)size); 
+        
         //if no MCParticles meet this criteria, we have a baad seed. 
         if (mcs_in_all_hits.size()==0){
             verdict = SeedVerdict.SEED_INVALID; 
@@ -81,15 +89,34 @@
         }
         
         verdict = SeedVerdict.SEED_VALID; 
-        likelyMC = mcs_in_all_hits.get(0);
         
     }
     
     
+    /**
+     * Returns an enum of type SeedVerdict encoding the status of the MC...
+     * @return
+     */
     public SeedVerdict getVerdict(){
         return verdict; 
     }
     
+    /**
+     * Returns the purity of the candidate. The purity is defined as the number
+     * of hits containing the likelyMC (see the {@link #getLikelyMC() getLikelyMC}
+     * method divided by the total number of hits.
+     * @return
+     */
+    public double getPurity(){
+        return purity; 
+    }
+    /**
+     * Returns the most likely MC belonging to the seed. If there is an MC that 
+     * all the hits contain, that MC is returned. Otherwise, the MC with the 
+     * most hits containing it is returned. If more than one MC has the most hits,
+     * only one will be returned, though it's not easy to predict whigh. 
+     * @return the most likely MC
+     */
     public MCParticle getLikelyMC(){
         return likelyMC; 
     }
@@ -158,7 +185,7 @@
             
             for (MCParticle p : mcs) {    
                if(!occurrences.containsKey(p)){
-                    occurrences.put(p, 1); 
+                    occurrences.put(p, 1);
                }
                else {
                    int currVal = occurrences.get(p);

lcsim/src/org/lcsim/contrib/seedtracker
MergeSeedLists.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MergeSeedLists.java	1 Apr 2008 22:45:05 -0000	1.3
+++ MergeSeedLists.java	8 Apr 2008 08:44:00 -0000	1.4
@@ -45,7 +45,7 @@
                             SeedValidator oldV = new SeedValidator(seed);
                             SeedValidator newV = new SeedValidator(newseed);
 
-                            if (oldV.getVerdict().isGoodValue() && !newV.getVerdict().isGoodValue()){
+                            if (oldV.getPurity() > newV.getPurity()){
                                 makeBadDecisionPlots(newseed,seed, oldV,newV);
                             }
                         }
@@ -60,21 +60,7 @@
         System.out.println(" After merging: "+seedlist.size());
         
         if(VALIDATE) {
-            for (SeedCandidate s : seedlist){
-            
-                SeedValidator v = new SeedValidator(s);
-                if (v.getVerdict().isGoodValue()) {
-                    aida.cloud1D("Good seeds chisq").fill(s.getHelix().chisqtot());
-                    aida.cloud1D("Good seeds numhits").fill(s.getHits().size());
-                    aida.cloud1D("Good seeds pt").fill(s.getHelix().pT(5.0));
-                }
-                
-                else {
-                    aida.cloud1D("Bad seeds chisq").fill(s.getHelix().chisqtot());
-                    aida.cloud1D("Bad seeds numhits").fill(s.getHits().size());
-                    aida.cloud1D("Bad seeds pt").fill(s.getHelix().pT(5.0));
-                }
-            }
+            makeCandidatePlots(seedlist);
         }
         return;
     }
@@ -107,15 +93,43 @@
         aida.cloud1D("Bad Decision newseed chisq").fill(newseed.getHelix().chisqtot());
         aida.cloud1D("Bad Decision oldseed chisq").fill(seed.getHelix().chisqtot());
         aida.cloud2D("Bad Decision newseed vs. oldseed chisq").fill(newseed.getHelix().chisqtot(), seed.getHelix().chisqtot());
-
-        Hep3Vector p = oldV.getLikelyMC().getMomentum();
-        double pt = Math.sqrt(p.x() * p.x() + p.y() * p.y());
-        aida.cloud1D("Bad Decision real particle transverse momentum").fill(pt);
+        aida.cloud1D("Bad Decision old seedpurity").fill(oldV.getPurity());
+        aida.cloud1D("Bad Decision new seedpurity").fill(newV.getPurity());
         
-        Hep3Vector r = oldV.getLikelyMC().getOrigin();
-        double rc = Math.sqrt(r.x()*r.x()+r.y()*r.y()); 
-        aida.cloud1D("Bad Decision real particle start radius (cylindrical)").fill(rc);
         
+        if(oldV.getVerdict().isGoodValue()){
+            Hep3Vector p = oldV.getLikelyMC().getMomentum();
+            double pt = Math.sqrt(p.x() * p.x() + p.y() * p.y());
+            aida.cloud1D("Bad Decision real particle transverse momentum").fill(pt);
+        
+            Hep3Vector r = oldV.getLikelyMC().getOrigin();
+            double rc = Math.sqrt(r.x()*r.x()+r.y()*r.y()); 
+            aida.cloud1D("Bad Decision real particle start radius (cylindrical)").fill(rc);
+        }
+        
+    }
+
+    private void makeCandidatePlots(List<SeedCandidate> seedlist) {
+        for (SeedCandidate s : seedlist) {
+
+            SeedValidator v = new SeedValidator(s);
+            if (v.getVerdict().isGoodValue()) {
+                aida.cloud1D("Good seeds chisq").fill(s.getHelix().chisqtot());
+                aida.cloud1D("Good seeds numhits").fill(s.getHits().size());
+                aida.cloud1D("Good seeds pt").fill(s.getHelix().pT(5.0));
+            } else {
+                aida.cloud1D("Bad seeds chisq").fill(s.getHelix().chisqtot());
+                aida.cloud1D("Bad seeds numhits").fill(s.getHits().size());
+                aida.cloud1D("Bad seeds pt").fill(s.getHelix().pT(5.0));
+            }
+
+            aida.cloud1D("purity").fill(v.getPurity());
+            aida.cloud2D("purity vs. numHits").fill(v.getPurity(), s.getHits().size());
+            aida.cloud2D("purity vs. pt").fill(v.getPurity(), s.getHelix().pT(5.0));
+            aida.cloud2D("purity vs. cth").fill(v.getPurity(), s.getHelix().cth());
+            aida.cloud2D("purity vs. chisq").fill(v.getPurity(), s.getHelix().chisqtot());
+            aida.cloud2D("purity cs. dca").fill(v.getPurity(), s.getHelix().dca());
+        }
     }
 }
  
\ No newline at end of file
CVSspam 0.2.8