Print

Print


Commit in lcsim/src/org/lcsim/contrib/seedtracker on MAIN
ConfirmerExtender.java+181added 1.1
ConfirmSeeds.java+8-601.4 -> 1.5
ExtendSeeds.java+3-831.4 -> 1.5
+192-143
1 added + 2 modified, total 3 files
CD - common confirmer/extender code moved into a separate class.

lcsim/src/org/lcsim/contrib/seedtracker
ConfirmerExtender.java added at 1.1
diff -N ConfirmerExtender.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ConfirmerExtender.java	10 Apr 2008 00:12:05 -0000	1.1
@@ -0,0 +1,181 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.seedtracker;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
+/**
+ *
+ * @author cozzy
+ */
+public class ConfirmerExtender {
+
+    public enum Task{
+        CONFIRM,
+        EXTEND;
+    }
+    
+    private boolean optimize;
+    private Task task;
+    private List<SeedCandidate> l; 
+    private HitManager hmanager; 
+    private HelixFitter fitter; 
+    private SeedStrategy strategy; 
+    private List<SeedCandidate> result; 
+    private boolean taskDone; 
+    private boolean debugOut = false; 
+    private String sysOutAdjective = ""; //this is purely for sysouts
+    /**
+     * Constructs the Confirmer/Extender class.. 
+     * @param workinglist The list to work on, either confirmed (extending) or seed (confirming)
+     * @param task the task to do (either Task.CONFIRM or Task.EXTEND)
+     * @param optimize enables the sort / cutoff optimization
+     * @param helixfitter pass the fitter
+     * @param hitmanager pass the hit manager
+     * @param strategy pass the strategy
+     */
+    public ConfirmerExtender(List<SeedCandidate> workinglist, Task task, boolean optimize, HelixFitter helixfitter, HitManager hitmanager, SeedStrategy strategy){
+        this.task = task;
+        this.optimize = optimize; 
+        this.l = workinglist;
+        this.hmanager = hitmanager;
+        this.fitter = helixfitter;
+        this.strategy = strategy;
+        this.result = new ArrayList<SeedCandidate>();
+        this.taskDone = false; 
+    }
+    
+    /**
+     * Retrieves the result of the confirmation or extension. This step does the computation if it has not been done already. 
+     * @return result The list of confirmed/extended seeds.. 
+     */
+    public List<SeedCandidate> getResult(){
+        if(!taskDone) {
+            doTask();
+            taskDone = true; 
+        }
+        return result; 
+    }
+    
+    public void setDebugOut(boolean value){
+        debugOut = value; 
+        if (value==true){
+            if (task == Task.CONFIRM) sysOutAdjective="Confirmed";
+            else sysOutAdjective = "Extended";
+        }
+        
+    }
+    
+    private void doTask(){
+        
+        List<SeedLayer> lyrs; 
+        
+        if (task == Task.EXTEND)
+            lyrs= strategy.getLayers(SeedLayer.SeedType.Extend);
+        else if (task == Task.CONFIRM)
+            lyrs = strategy.getLayers(SeedLayer.SeedType.Confirm);
+        else throw new RuntimeException("Unrecognized Task"); 
+        
+        //  Loop over the confirmed seeds
+        for (SeedCandidate seed : l) {
+            int n = 0;
+            
+            //  Start a working seed list and add the input seed
+            List<SeedCandidate> seedlist = new ArrayList<SeedCandidate>();
+            seedlist.add(seed);
+            
+            //  Loop over the confirmation/extension layers
+            for (SeedLayer lyr : lyrs) {
+                
+                //  Get the hits on this confirmation/extension layer    
+                List<HelicalTrackHit> hitlist = hmanager.getTrackerHits(lyr);
+                
+                //  Create a list for seeds that are confirmed/extended using the current layer
+                List<SeedCandidate> newlist = new ArrayList<SeedCandidate>();
+                
+                //  Loop over the seeds in the working seed list
+                for (SeedCandidate seedin : seedlist) {
+                  
+                    SortHits comp; 
+                    
+                    if(optimize) {
+                        comp = new SortHits(seedin.getHelix());
+                        Collections.sort(hitlist, comp);
+                    }
+                  
+                    //  Retrieve the chisq for the last fit and initialize the best fit chisq for this layer
+                    double oldchisq = seedin.getHelix().chisqtot();
+                    double oldcirclechisq = seedin.getHelix().chisq()[0];
+                    double chisqbest = 1.e6;
+                    if (debugOut) {
+                        System.out.println("Oldcirclechisq: "+oldcirclechisq);
+                        System.out.println("Oldchisq: "+oldchisq);
+                        System.out.println("Oldhits: "+seedin.getHits().size());
+                        System.out.println("Old Helix: "+seedin.getHelix().toString());
+                    }
+                    
+                    //  For each hit in this confirmation/extension layer, make a test seed including the new hit
+                    for (HelicalTrackHit hit : hitlist) {
+                            
+                        SeedCandidate test = new SeedCandidate(seedin);
+                        test.addHit(hit);
+                        
+                        //  See if we have a successful fit
+                        boolean success = fitter.FitCandidate(test, strategy);
+                        
+                        if (!success && optimize) {
+                            if (fitter.getFitStatus() != FitStatus.CircleFitFailed) {
+                                double circlechisq = fitter.getCircleFit().chisq();
+                                if (debugOut) System.out.println("Circlechissq: "+circlechisq);
+                                if (circlechisq > oldcirclechisq + strategy.getMaxChisq()) break;
+                            }
+                            continue; 
+                        }
+                        if (success) { 
+                            
+                            //  Attach the fit to the test seed and add it to the list
+                            test.setHelix(fitter.getHelix());
+                            if (debugOut) {
+                                System.out.println("Good fit");
+                                System.out.println("Chisq: "+fitter.getHelix().chisqtot());
+                                System.out.println("Circle Chisq: "+fitter.getHelix().chisq()[0]);
+                                System.out.println("New Helix: "+fitter.getHelix().toString());
+                            }
+                            newlist.add(test);
+                            chisqbest = Math.min(chisqbest, fitter.getHelix().chisqtot());
+                        }
+                    }
+                    
+                    //  If all fit tries for this layer are potentially bad hits, include the starting seed in the list
+                    if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
+                        newlist.add(seedin);
+                    } else n++;
+                }
+                //  Use the new list of seeds as input to the next layer search
+                
+                seedlist = newlist;
+                if (debugOut){
+                    System.out.println(" "+sysOutAdjective+" seeds: "+n);
+                    System.out.println(" "+sysOutAdjective+" seed candidates: "+seedlist.size());
+                }
+            }
+            
+        //Check for seeds with sufficient numbers of confirmed/extended hits
+            for (SeedCandidate candidate : seedlist) {
+                int hits = candidate.getHits().size();
+                if ( (task == Task.EXTEND && hits >= strategy.getMinHits()) ||
+                     (task == Task.CONFIRM && hits >= strategy.getMinConfirm()) ) {
+                    
+                    result.add(candidate);
+                }
+            }
+        }
+    }
+}

lcsim/src/org/lcsim/contrib/seedtracker
ConfirmSeeds.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ConfirmSeeds.java	12 Feb 2008 17:10:10 -0000	1.4
+++ ConfirmSeeds.java	10 Apr 2008 00:12:05 -0000	1.5
@@ -8,9 +8,12 @@
 package org.lcsim.contrib.seedtracker;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+import org.lcsim.util.aida.AIDA;
 
 /**
  *
@@ -29,67 +32,12 @@
     }
     
     public boolean Confirm(SeedCandidate seed, SeedStrategy strategy) {
+        List<SeedCandidate> seedl = new ArrayList<SeedCandidate>();
+        seedl.add(seed);
         
-        //  Retrieve the confirmation layers to be used and initialize the list of confirmed seeds
-        List<SeedLayer> confirmlyrs = strategy.getLayers(SeedLayer.SeedType.Confirm);
-        _confirmedseeds = new ArrayList<SeedCandidate>();
-        
-        //  Start a working seed list and add the input seed
-        List<SeedCandidate> seedlist = new ArrayList<SeedCandidate>();
-        seedlist.add(seed);
-        
-        //  Get the number of hits on the starting seed
-        int inhits = seed.getHits().size();
-        
-        //  Loop over the confirmation layers
-        for (SeedLayer lyr : confirmlyrs) {
-            int nconfirm = 0;
-            //  Get the hits on this confirmation layer
-            List<HelicalTrackHit> hitlist = _hitmanager.getTrackerHits(lyr);
-            
-            //  Create a list for seeds that are confirmed using the current layer
-            List<SeedCandidate> newlist = new ArrayList<SeedCandidate>();
-            //  Loop over the seeds in the working seed list
-            for (SeedCandidate seedin : seedlist) {
-
-                //  Retrieve the chisq for the last fit and initialize the best fit chisq for this layer
-                double oldchisq = seedin.getHelix().chisqtot();
-                double chisqbest = 1.e6;
-                
-                //  For each hit in this confirmation layer, make a test seed including the new hit
-                for (HelicalTrackHit hit : hitlist) {
-                    SeedCandidate test = new SeedCandidate(seedin);
-                    test.addHit(hit);
-                    
-                    //  See if we have a successful fit
-                    boolean success = _helixfitter.FitCandidate(test, strategy);
-                    if (success) {
-                        
-                        //  Attach the fit to the test seed and add it to the list
-                        test.setHelix(_helixfitter.getHelix());
-                        newlist.add(test);
-                        chisqbest = Math.min(chisqbest, _helixfitter.getHelix().chisqtot());
-                    }
-                }
-                
-                //  If all fit tries for this layer are potentially bad hits, include the starting seed in the list
-                if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
-                    newlist.add(seedin);
-                } else nconfirm++;
-            }
-            //  Use the new list of seeds as input to the next layer search
-            seedlist = newlist;
-//            System.out.println(" Number of confirmed seeds: "+nconfirm);
-//            System.out.println(" Number of seed candidates: "+seedlist.size());
-        }
-        
-        //  Check for seeds with sufficient numbers of confirmed hits
-        for (SeedCandidate candidate : seedlist) {
-            int hits = candidate.getHits().size();
-            if (hits >= inhits + strategy.getMinConfirm()) {
-                _confirmedseeds.add(candidate);
-            }
-        }
+        ConfirmerExtender ce = new ConfirmerExtender(seedl, ConfirmerExtender.Task.CONFIRM, true, 
+                                                    _helixfitter, _hitmanager, strategy);
+        _confirmedseeds = ce.getResult(); 
         return _confirmedseeds.size()>0;
     }
     

lcsim/src/org/lcsim/contrib/seedtracker
ExtendSeeds.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ExtendSeeds.java	4 Apr 2008 23:41:33 -0000	1.4
+++ ExtendSeeds.java	10 Apr 2008 00:12:05 -0000	1.5
@@ -35,89 +35,9 @@
     
     public boolean Extend(List<SeedCandidate> confirmed, SeedStrategy strategy) {
         
-        //  Retrieve the extension layers to be used and initialize the list of extended seeds
-        List<SeedLayer> extendlyrs = strategy.getLayers(SeedLayer.SeedType.Extend);
-        _extendedseeds = new ArrayList<SeedCandidate>();
-        
-        //  Loop over the confirmed seeds
-        for (SeedCandidate seed : confirmed) {
-            int nextend = 0;
-            
-            //  Start a working seed list and add the input seed
-            List<SeedCandidate> seedlist = new ArrayList<SeedCandidate>();
-            seedlist.add(seed);
-            
-            //  Loop over the extension layers
-            for (SeedLayer lyr : extendlyrs) {
-                
-                //  Get the hits on this extension layer
-                List<HelicalTrackHit> hitlist = _hitmanager.getTrackerHits(lyr);
-                
-                //  Create a list for seeds that are extended using the current layer
-                List<SeedCandidate> newlist = new ArrayList<SeedCandidate>();
-                
-                //  Loop over the seeds in the working seed list
-                for (SeedCandidate seedin : seedlist) {
-                  
-                    SortHits comp = new SortHits(seedin.getHelix());
-                    Collections.sort(hitlist, comp);
-                  
-                    //  Retrieve the chisq for the last fit and initialize the best fit chisq for this layer
-                    double oldchisq = seedin.getHelix().chisqtot();
-                    double oldcirclechisq = seedin.getHelix().chisq()[0];
-                    double chisqbest = 1.e6;
-//                    System.out.println("Oldcirclechisq: "+oldcirclechisq);
-//                    System.out.println("Oldchisq: "+oldchisq);
-//                    System.out.println("Oldhits: "+seedin.getHits().size());
-//                    System.out.println("Old Helix: "+seedin.getHelix().toString());
-                    //  For each hit in this confirmation layer, make a test seed including the new hit
-                    for (HelicalTrackHit hit : hitlist) {
-                            
-                        SeedCandidate test = new SeedCandidate(seedin);
-                        test.addHit(hit);
-                        
-                        //  See if we have a successful fit
-                        boolean success = _helixfitter.FitCandidate(test, strategy);
-                        if (!success) {
-                            if (_helixfitter.getFitStatus() != FitStatus.CircleFitFailed) {
-                                double circlechisq = _helixfitter.getCircleFit().chisq();
-//                                System.out.println("Circlechissq: "+circlechisq);
-                                if (circlechisq > oldcirclechisq + strategy.getMaxChisq()) break;
-                            }
-                            continue;
-                        }
-                        if (success) {
-                            
-                            //  Attach the fit to the test seed and add it to the list
-                            test.setHelix(_helixfitter.getHelix());
-//                            System.out.println("Good fit");
-//                            System.out.println("Chisq: "+_helixfitter.getHelix().chisqtot());
-//                            System.out.println("Circle Chisq: "+_helixfitter.getHelix().chisq()[0]);
-//                            System.out.println("New Helix: "+_helixfitter.getHelix().toString());
-                            newlist.add(test);
-                            chisqbest = Math.min(chisqbest, _helixfitter.getHelix().chisqtot());
-                        }
-                    }
-                    
-                    //  If all fit tries for this layer are potentially bad hits, include the starting seed in the list
-                    if (chisqbest - oldchisq > strategy.getBadHitChisq()) {
-                        newlist.add(seedin);
-                    } else nextend++;
-                }
-                //  Use the new list of seeds as input to the next layer search
-                seedlist = newlist;
-//                System.out.println(" Extended seeds: "+nextend);
-//                System.out.println(" Extended seed candidates: "+seedlist.size());
-            }
-            
-            //  Check for seeds with sufficient numbers of confirmed hits
-            for (SeedCandidate candidate : seedlist) {
-                int hits = candidate.getHits().size();
-                if (hits >= strategy.getMinHits()) {
-                    _extendedseeds.add(candidate);
-                }
-            }
-        }
+        ConfirmerExtender ce = new ConfirmerExtender(confirmed, ConfirmerExtender.Task.EXTEND, true, 
+                                                    _helixfitter, _hitmanager, strategy);
+        _extendedseeds = ce.getResult(); 
         return _extendedseeds.size()>0;
     }
     
CVSspam 0.2.8