Print

Print


Commit in lcsim/src/org/lcsim/contrib/seedtracker on MAIN
ConfirmSeeds.java+96-151.1 -> 1.2
DefaultStrategy.java+16-81.5 -> 1.6
FindSeeds.java+5-31.1 -> 1.2
HelixFitter.java+12-101.1 -> 1.2
MultipleScattering.java+17-101.3 -> 1.4
SeedStrategy.java+14-21.2 -> 1.3
+160-48
6 modified files


lcsim/src/org/lcsim/contrib/seedtracker
ConfirmSeeds.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ConfirmSeeds.java	4 Feb 2008 20:51:32 -0000	1.1
+++ ConfirmSeeds.java	6 Feb 2008 02:33:25 -0000	1.2
@@ -7,20 +7,101 @@
 
 package org.lcsim.contrib.seedtracker;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
+
 /**
  *
  * @author Richard Partridge
  * @version 1.0
  */
 public class ConfirmSeeds {
+    private HitManager _hitmanager;
+    private HelixFitter _helixfitter;
+    private List<SeedCandidate> _confirmedseeds;
     
     /** Creates a new instance of ConfirmSeeds */
-    public ConfirmSeeds() {
+    public ConfirmSeeds(HitManager hitmanager, HelixFitter helixfitter) {
+        _hitmanager = hitmanager;
+        _helixfitter = helixfitter;
+    }
+    
+    public boolean Confirm(SeedCandidate seed, SeedStrategy strategy) {
+        
+        //  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) {
+            
+            //  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>();
+            System.out.print("Started a new list");
+            //  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);
+                        System.out.println(" Added a seed to the new list");
+                        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()) {
+                    System.out.println(" Added the old seed to the new list");
+                    newlist.add(seedin);
+                }
+            }
+            //  Use the new list of seeds as input to the next layer search
+            seedlist = newlist;
+        }
+        
+        //  Check for seeds with sufficient numbers of confirmed hits
+        for (SeedCandidate candidate : seedlist) {
+            int hits = candidate.getHits().size();
+            System.out.println(" seed with nhits: "+hits);
+            if (hits >= inhits + strategy.getMinConfirm()) {
+                _confirmedseeds.add(candidate);
+            }
+        }
+        return _confirmedseeds.size()>0;
     }
-   
+    
+    public List<SeedCandidate> getConfirmedSeeds() {
+        return _confirmedseeds;
+    }
+    
 //    private List<SeedCandidate> FindConfirmedSeeds(SeedStrategy strategy, SeedCandidate seed) {
 //        List<SeedCandidate> confirmedseeds = new ArrayList<SeedCandidate>();
-        //  For now, confirm our original seed
+    //  For now, confirm our original seed
 //        confirmedseeds.add(seed);
 //        private List<List<TrackerHit>> FindConfirms(SeedStrategy strategy, List<BarrelEndcapFlag> beflaglist, SeedCandidate seed) {
 //            // Create a list of possible confirmation hits for each confirmation layer
@@ -33,21 +114,21 @@
 //                // If we have some confirmation hits in this layer, add the list of hits for this layer
 //                if (confirmhits.size()>0) confirmbylayer.add(confirmhits);
 //            }
-        // Initialize a list of track candidates that include confirmation hits
+    // Initialize a list of track candidates that include confirmation hits
 //            List<List<TrackerHit>> candlist = new ArrayList();
-        // check that there are sufficient layers with confirmation hits
+    // check that there are sufficient layers with confirmation hits
 //            if (confirmbylayer.size() >= strategy.getMinConfirm()) {
-        // Start with our seed hits as a candidate
+    // Start with our seed hits as a candidate
 //                candlist.add(seed.getTrackerHits());
-        // Loop over all the confirming layers
+    // Loop over all the confirming layers
 //                for (List<TrackerHit> confirmhits : confirmbylayer) {
-        // Create a list of new candidates that have hits added from this layer
+    // Create a list of new candidates that have hits added from this layer
 //                    List<List<TrackerHit>> newcandlist = new ArrayList();
-        // Loop over all existing candidates
+    // Loop over all existing candidates
 //                    for (List<TrackerHit> oldcand : candlist) {
-        // Loop over all the hits in this confirming layer
+    // Loop over all the hits in this confirming layer
 //                        for (TrackerHit hit : confirmhits) {
-        // Create a new track candidate that adds this hit
+    // Create a new track candidate that adds this hit
 //                            List<TrackerHit> newcand = new ArrayList();
 //                            boolean status = newcand.addAll(oldcand);
 //                            newcand.add(hit);
@@ -57,7 +138,7 @@
 //                    boolean status = candlist.addAll(newcandlist);
 //                }
 //            }
-        // Remove candidates that have too few confirmation hits
+    // Remove candidates that have too few confirmation hits
 //        ListIterator<List<BaseTrackerHitMC>> itr = candlist.listIterator();
 //        while (itr.hasNext()) {
 //            List<BaseTrackerHitMC> hitlist = itr.next();
@@ -68,8 +149,8 @@
 //        }
 //                    int maxhits = 3 + strategy.getLayers(SeedType.Confirm).size();
 //                    int minhits = 3 + strategy.getMinConfirm();
-        // First try to find one or more tracks using all the confirm hits
-        // If this fails, work our way down to the minimum number
+    // First try to find one or more tracks using all the confirm hits
+    // If this fails, work our way down to the minimum number
 //                    for (int nhit = maxhits; nhit >= minhits; nhit--) {
 //                        boolean foundtrack = false;
 //                        for (List<TrackerHit> candidate : confirmlist) {
@@ -78,6 +159,6 @@
 //                                    boolean status2 = FindHelix(strategy, candidate);
 //        return confirmedseeds;
 //    }
-
+    
     
 }
\ No newline at end of file

lcsim/src/org/lcsim/contrib/seedtracker
DefaultStrategy.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- DefaultStrategy.java	5 Feb 2008 17:08:47 -0000	1.5
+++ DefaultStrategy.java	6 Feb 2008 02:33:25 -0000	1.6
@@ -26,11 +26,19 @@
     public DefaultStrategy() {
         _strategylist = new ArrayList();
         // Barrel only strategies
-        List<SeedLayer> tb012layers = new ArrayList();
-        tb012layers.add(new SeedLayer("VertexBarrel", 0, BarrelEndcapFlag.BARREL, SeedType.Seed));
-        tb012layers.add(new SeedLayer("VertexBarrel", 1, BarrelEndcapFlag.BARREL, SeedType.Seed));
-        tb012layers.add(new SeedLayer("VertexBarrel", 2, BarrelEndcapFlag.BARREL, SeedType.Seed));
-        _strategylist.add(new SeedStrategy("TB012",tb012layers));
+        List<SeedLayer> tv012layers = new ArrayList();
+        tv012layers.add(new SeedLayer("VertexBarrel", 0, BarrelEndcapFlag.BARREL, SeedType.Seed));
+        tv012layers.add(new SeedLayer("VertexBarrel", 1, BarrelEndcapFlag.BARREL, SeedType.Seed));
+        tv012layers.add(new SeedLayer("VertexBarrel", 2, BarrelEndcapFlag.BARREL, SeedType.Seed));
+        tv012layers.add(new SeedLayer("VertexBarrel", 3, BarrelEndcapFlag.BARREL, SeedType.Confirm));
+        tv012layers.add(new SeedLayer("VertexBarrel", 4, BarrelEndcapFlag.BARREL, SeedType.Confirm));
+        tv012layers.add(new SeedLayer("TrackerBarrel", 0, BarrelEndcapFlag.BARREL, SeedType.Extend));
+        tv012layers.add(new SeedLayer("TrackerBarrel", 1, BarrelEndcapFlag.BARREL, SeedType.Extend));
+        tv012layers.add(new SeedLayer("TrackerBarrel", 2, BarrelEndcapFlag.BARREL, SeedType.Extend));
+        tv012layers.add(new SeedLayer("TrackerBarrel", 3, BarrelEndcapFlag.BARREL, SeedType.Extend));
+        tv012layers.add(new SeedLayer("TrackerBarrel", 4, BarrelEndcapFlag.BARREL, SeedType.Extend));
+        
+        _strategylist.add(new SeedStrategy("TV012",tv012layers));
         
         List<BarrelEndcapFlag> belist = new ArrayList();
         belist.add(BarrelEndcapFlag.ENDCAP_NORTH);
@@ -41,19 +49,19 @@
             td012layers.add(new SeedLayer("TrackerEndcap", 0, beflag, SeedType.Seed));
             td012layers.add(new SeedLayer("TrackerEndcap", 2, beflag, SeedType.Seed));
             td012layers.add(new SeedLayer("TrackerEndcap", 4, beflag, SeedType.Seed));
-            _strategylist.add(new SeedStrategy("TD012"+beflag.toString(),td012layers));
+//            _strategylist.add(new SeedStrategy("TD012"+beflag.toString(),td012layers));
             
             List<SeedLayer> tca = new ArrayList();
             tca.add(new SeedLayer("TrackerBarrel", 0, BarrelEndcapFlag.BARREL, SeedType.Seed));
             tca.add(new SeedLayer("TrackerBarrel", 1, BarrelEndcapFlag.BARREL, SeedType.Seed));
             tca.add(new SeedLayer("TrackerEndcap", 4, beflag, SeedType.Seed));
-            _strategylist.add(new SeedStrategy("TCA"+beflag.toString(),tca));
+//            _strategylist.add(new SeedStrategy("TCA"+beflag.toString(),tca));
             
             List<SeedLayer> tcb = new ArrayList();
             tcb.add(new SeedLayer("TrackerBarrel", 0, BarrelEndcapFlag.BARREL, SeedType.Seed));
             tcb.add(new SeedLayer("TrackerEndcap", 2, beflag, SeedType.Seed));
             tcb.add(new SeedLayer("TrackerEndcap", 4, beflag, SeedType.Seed));
-            _strategylist.add(new SeedStrategy("TCB"+beflag.toString(),tcb));
+//            _strategylist.add(new SeedStrategy("TCB"+beflag.toString(),tcb));
         }        
     }
     

lcsim/src/org/lcsim/contrib/seedtracker
FindSeeds.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FindSeeds.java	4 Feb 2008 20:51:32 -0000	1.1
+++ FindSeeds.java	6 Feb 2008 02:33:25 -0000	1.2
@@ -20,12 +20,14 @@
 public class FindSeeds {
     private HitManager _hitmanager;
     private HelixFitter _helixfitter;
+    private ConfirmSeeds _confirmseeds;
     private List<SeedCandidate> _confirmedseeds;
     
     /** Creates a new instance of FindSeeds */
     public FindSeeds(HitManager hitmanager, HelixFitter helixfitter) {
         _hitmanager = hitmanager;
         _helixfitter = helixfitter;
+        _confirmseeds = new ConfirmSeeds(hitmanager, helixfitter);
     }
     
     public boolean FindConfirmedSeeds(SeedStrategy strategy) {
@@ -69,10 +71,10 @@
                     if (!success) continue;
                     seed.setHelix(_helixfitter.getHelix());
                     
-//                    success = _confirmseed.confirm(seed, strategy);
-//                    if (!success) continue;
+                    success = _confirmseeds.Confirm(seed, strategy);
+                    if (!success) continue;
                     
-                    _confirmedseeds.add(seed);
+                    _confirmedseeds.addAll(_confirmseeds.getConfirmedSeeds());
                 }
             }
         }

lcsim/src/org/lcsim/contrib/seedtracker
HelixFitter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HelixFitter.java	4 Feb 2008 20:51:32 -0000	1.1
+++ HelixFitter.java	6 Feb 2008 02:33:25 -0000	1.2
@@ -62,7 +62,7 @@
         }
         
         //  Calculate the MS errors
-        Map<HelicalTrackHit, MultipleScatter> msmap = _scattering.HelixScatters(oldhelix);
+        Map<HelicalTrackHit, MultipleScatter> msmap = _scattering.HelixScatters(oldhelix, hitlist);
         
         //  Do a helix fit including MS errors
         status = _fitter.fit(hitlist, msmap);
@@ -92,16 +92,17 @@
         double[] params = helix.parameters();
         
         //  Sum the chisq for the circle (x-y) and line (s-z) fits
-        double chisq = helix.chisq()[0]+helix.chisq()[1];
+        double chisq = helix.chisqtot();
         
-        System.out.println(" chisq "+chisq);
-        System.out.println(" d0 "+params[0]);
-        System.out.println(" phi0 "+params[1]);
-        System.out.println(" curvatures "+params[2]);
-        System.out.println(" z0 "+params[3]);
-        System.out.println(" slope "+params[4]);
-        double pT = 0.0003 * _bfield / Math.abs(params[2]);
-        System.out.println(" pT "+pT);
+        System.out.println(" circle chisq "+helix.chisq()[0]);
+        System.out.println(" line fit chisq "+helix.chisq()[1]);
+        System.out.println(" total chisq "+chisq);
+        System.out.println(" dca "+helix.dca());
+        System.out.println(" phi0 "+helix.phi0());
+        System.out.println(" curvatures "+helix.curvature());
+        System.out.println(" z0 "+helix.z0());
+        System.out.println(" slope "+helix.slope());
+        System.out.println(" pT "+helix.pT(_bfield));
         
         //  Inflate chisq if |curvature| is too large
         double curvmax = 0.0003 * _bfield / strategy.getMinPT();
@@ -124,6 +125,7 @@
             chisq += Math.pow(z0 - z0max, 2) / helix.covariance().e(3, 3);
         }
         
+        System.out.println(" inflated chisq: "+chisq);
         //  Make the chi squared cut
         if (chisq > strategy.getMaxChisq()) return false;
         System.out.println(" Good track found");

lcsim/src/org/lcsim/contrib/seedtracker
MultipleScattering.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MultipleScattering.java	5 Feb 2008 17:08:47 -0000	1.3
+++ MultipleScattering.java	6 Feb 2008 02:33:25 -0000	1.4
@@ -48,22 +48,29 @@
      * @param helix HelicalTrackFit that we want the ms errors for
      * @return map containing the MultipleScatter objects for each hit
      */
-    public Map<HelicalTrackHit, MultipleScatter> HelixScatters(HelicalTrackFit helix) {
+    public Map<HelicalTrackHit, MultipleScatter> HelixScatters(HelicalTrackFit helix, List<HelicalTrackHit> hitlist) {
         
         //  Create an empty map to hold the multiple scattering errors
         Map<HelicalTrackHit, MultipleScatter> msmap = new HashMap<HelicalTrackHit, MultipleScatter>();
         
-        //  Construct a list of material scatterings for this helix
-        List<ScatterAngle> scatters = FindScatters(helix);
-        
         //  Retreive the x-y path lengths and calculate sin^2(theta) for this helix
         Map<HelicalTrackHit, Double> pathmap = helix.pathmap();
         double sth2 = Math.pow(helix.sth(), 2);
         
+        //  Make sure all hits have x-y path lengths.  Hits added since the last fit
+        //  won't have path lengths, so estimate the path length measured from the DCA
+        for (HelicalTrackHit hit : hitlist) {
+            if (!pathmap.containsKey(hit)) {
+                pathmap.put(hit, (Double) _hutil.PathLength(helix, hit));
+            }
+        }
+        
+        //  Construct a list of material scatterings for this helix
+        List<ScatterAngle> scatters = FindScatters(helix);
+        
         //  Loop over the hits on the helix and calculate the multiple scattering errors
-        for (Map.Entry<HelicalTrackHit, Double> hitentry : pathmap.entrySet()) {
-            double hitpath = hitentry.getValue();
-            HelicalTrackHit hit = hitentry.getKey();
+        for (HelicalTrackHit hit : hitlist) {
+            double hitpath = pathmap.get(hit);
             
             //  Loop over scattering points and sum in quadrature ms errors for this hit.
             //  It is assumed that we can ignore ms correlations during the track-finding stage.
@@ -79,7 +86,7 @@
                     
                     //  Get the multiple scattering plane angle for this scatter
                     double angle = scat.Angle();
-                    System.out.println(" s: "+scatpath+" angle "+angle);
+//                    System.out.println(" s: "+scatpath+" angle "+angle);
                     
                     //  Sum in quadrature the r-phi ms errors.  It is assumed that we
                     //  can ignore track curvature in calculating these errors during
@@ -98,7 +105,7 @@
             //  Create a new MultipleScatter object and store it in the map of ms errors
             MultipleScatter ms = new MultipleScatter(Math.sqrt(rphi_ms2), Math.sqrt(z_ms2));
             System.out.println(" r: "+hit.r()+" z "+hit.z()+" r-phi ms: "+ms.drphi()+" s-z ms: "+ms.dz());
-            msmap.put(hitentry.getKey(), ms);
+            msmap.put(hit, ms);
         }
         
         return msmap;
@@ -132,7 +139,7 @@
             smax = Math.min(smax, s);
         }
         
-        System.out.println(" smax: "+smax);
+//        System.out.println(" smax: "+smax);
         
         for (MaterialDisk disk : matdsk) {
             double s = _hutil.PathToZPlane(helix, disk.z());

lcsim/src/org/lcsim/contrib/seedtracker
SeedStrategy.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SeedStrategy.java	10 Aug 2007 15:50:26 -0000	1.2
+++ SeedStrategy.java	6 Feb 2008 02:33:25 -0000	1.3
@@ -24,8 +24,9 @@
     private double _MaxDCA = 10.0;
     private double _MaxZ0 = 10.0;
     private double _MaxChisq = 100.;
+    private double _BadHitChisq = 15.;
     private int _MinConfirm = 1;
-    private int _MinHits = 4;
+    private int _MinHits = 5;
     
     /**
      * Fully qualified constructor
@@ -35,17 +36,19 @@
      * @param MaxDCA Maximum DCA for this strategy
      * @param MaxZ0 Maximum z0 for this strategy
      * @param MaxChisq Maximum chi^2 for this strategy
+     * @param BadHitChisq chi^2 that invokes bad hit treatment
      * @param MinConfirm Minimum confirmation hits for this strategy
      * @param MinHits Minimum total number of hits for this strategy
      */
     public SeedStrategy(String Name, List<SeedLayer> LayerList, double MinPT,
-            double MaxDCA, double MaxZ0, double MaxChisq, int MinConfirm, int MinHits) {
+            double MaxDCA, double MaxZ0, double MaxChisq, double BadHitChisq, int MinConfirm, int MinHits) {
         this(Name, LayerList);
         _Name = Name;
         _MinPT = MinPT;
         _MaxDCA = MaxDCA;
         _MaxZ0 = MaxZ0;
         _MaxChisq = MaxChisq;
+        _BadHitChisq = BadHitChisq;
         _MinConfirm = MinConfirm;
         _MinHits = MinHits;
     }
@@ -116,6 +119,10 @@
         return _MaxChisq;
     }
     
+    public double getBadHitChisq() {
+        return _BadHitChisq;
+    }
+    
     /**
      * Return minimum number of confirmation hits for this strategy
      * @return Minimum number of confirmation hits for this strategy
@@ -177,6 +184,11 @@
         return;
     }
     
+    public void putBadHitChisq(double BadHitChisq) {
+        _BadHitChisq = BadHitChisq;
+        return;
+    }
+    
     /**
      * Set the minimum number of confirmation hits for this strategy
      * @param MinConfirm Minimum number of confirmation hits for this strategy
CVSspam 0.2.8