Commit in lcsim/src/org/lcsim/recon/tracking/seedtracker on MAIN
ConfirmerExtender.java+35-81.13 -> 1.14
FastCheck.java+59-221.8 -> 1.9
SeedCandidate.java+9-81.6 -> 1.7
SeedTrackFinder.java+24-51.13 -> 1.14
SeedTracker.java+131.10 -> 1.11
+140-43
5 modified files
Fix bug - Unchecked layer list in Seed Candidate passed instead of duplicated during seed cloning

lcsim/src/org/lcsim/recon/tracking/seedtracker
ConfirmerExtender.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- ConfirmerExtender.java	1 Sep 2009 22:54:58 -0000	1.13
+++ ConfirmerExtender.java	3 Sep 2009 17:52:29 -0000	1.14
@@ -9,6 +9,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.lcsim.event.MCParticle;
 import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.recon.tracking.seedtracker.diagnostic.ISeedTrackerDiagnostics;
@@ -70,7 +71,7 @@
 
         //  Process the seed
         doTask(seed, Task.CONFIRM, strategy, bfield);
-        
+
         //  Return true if we found at least one confirming seed candidate
         return _result.size() > 0;
     }
@@ -132,7 +133,7 @@
                 continue;
             }
 
-            //  Pull the next layer off the queue
+           //  Pull the next layer off the queue
             SeedLayer lyr = seed.getNextLayer();
 
             //  Get the list of sectors associated with this layer
@@ -150,7 +151,21 @@
             for (Sector sector : sectorlist) {
 
                 //  Check that this candidate is compatible with the sector
-                if (!checker.CheckSector(seed, sector)) continue;
+                if (!checker.CheckSector(seed, sector)) {
+//                    if (seed.isTrueSeed()) {
+//                        for (HelicalTrackHit hit : sector.Hits()) {
+//                            for (MCParticle mcp : hit.getMCParticles()) {
+//                                if (seed.getMCParticles().contains(mcp)) {
+//                                    System.out.println("Found a true hit in an incompatible sector!!");
+//                                    System.out.println("Sector phi lo: "+sector.philo()+" hi: "+sector.phihi());
+//                                    System.out.println("Sector z lo: "+sector.zlo()+" hi: "+sector.zhi());
+//                                    System.out.println("Hit: "+hit.toString());
+//                                }
+//                            }
+//                        }
+//                    }
+                    continue;
+                }
 
                 //  Add the hits for this confirmation/extension sector to the hitlist
                 hitlist.addAll(sector.Hits());
@@ -160,6 +175,7 @@
             Collections.sort(hitlist, comp);
 
             //  Loop over the sorted hits in this layer
+            boolean foundtrueseed = false;
             for (HelicalTrackHit hit : hitlist) {
 
                 //  Make a test seed including the new hit
@@ -167,18 +183,19 @@
                 test.addHit(hit);
 
                 //  Check that this hit is potentially viable
-//                if (!checker.CheckHitSeed(hit, seed)) {
-//                    if (_diag != null) _diag.fireCheckHitFailed(hit, test);
-//                    continue;
-//                }
+                if (!checker.CheckHitSeed(hit, seed)) {
+                    if (_diag != null) _diag.fireCheckHitFailed(hit, test);
+                    continue;
+                }
 
+                if (test.isTrueSeed()) foundtrueseed = true;
 
                 //  See if we have a successful fit
                 boolean success = _fitter.FitCandidate(test, strategy);
 
                 if (success) {
 
-                    //  Attach the fit to the test seed
+                     //  Attach the fit to the test seed
                     test.setHelix(_fitter.getHelix());
 
                     //  Add the seed to the LIFO queue of seed candidates
@@ -191,6 +208,16 @@
                     if (_fitter.getFitStatus() != FitStatus.CircleFitFailed) {
                         double circlechisq = _fitter.getCircleFit().chisq();
                         if (circlechisq > oldcirclechisq + strategy.getMaxChisq()) {
+                            if (_diag != null && seed.isTrueSeed() && !foundtrueseed) {
+                                for (HelicalTrackHit hitchk : hitlist) {
+                                    for (MCParticle mcp : hitchk.getMCParticles()) {
+                                        if (seed.getMCParticles().contains(mcp)) {
+                                            System.out.println("Stopped checking hits when a true hit was available");
+                                            System.out.println("p: "+mcp.getMomentum().toString());
+                                        }
+                                    }
+                                }
+                            }
                             break;
                         }
                     }

lcsim/src/org/lcsim/recon/tracking/seedtracker
FastCheck.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- FastCheck.java	1 Sep 2009 22:54:58 -0000	1.8
+++ FastCheck.java	3 Sep 2009 17:52:29 -0000	1.9
@@ -45,6 +45,16 @@
         CorrectHitPosition(hit1, seed);
         CorrectHitPosition(hit2, seed);
 
+        boolean match = false;
+        if (_diag != null && seed.isTrueSeed()) {
+             for (MCParticle mcp : seed.getMCParticles()) {
+                if (hit1.getMCParticles().contains(mcp) && hit2.getMCParticles().contains(mcp)) {
+                    match = true;
+                    break;
+                }
+            }
+        }
+
         //  Get the polar coordinates for the hits
         double r1 = hit1.r();
         double r2 = hit2.r();
@@ -61,10 +71,10 @@
         boolean phiOK = dphi <= dphimx;
 
         if (!phiOK) {
-            if (_diag != null && seed.isTrueSeed()) {
+            if (match) {
                 System.out.println("Bad Phi check");
-                System.out.println("dphi: " + dphi + " dphimx: " + dphimx);
-                System.out.println("r1: " + r1 + " r2: " + r2 + " phi1: " + phi1 + " phi2: " + phi2);
+//                System.out.println("dphi: " + dphi + " dphimx: " + dphimx);
+//                System.out.println("r1: " + r1 + " r2: " + r2 + " phi1: " + phi1 + " phi2: " + phi2);
             }
             return false;
         }
@@ -87,7 +97,7 @@
         boolean zOK = checkz0(smin(r1), smax(r1), zmin1, zmax1, smin(r2), smax(r2), zmin2, zmax2);
 
         if (!zOK) {
-            if (_diag != null && seed.isTrueSeed()) {
+            if (match) {
                 for (MCParticle mcp : seed.getMCParticles()) {
                     HelixParamCalculator helmc = new HelixParamCalculator(mcp, seed.getBField());
                     double z1 = 0.5 * (zmin1 + zmax1);
@@ -100,27 +110,27 @@
                     double arg2 = s2true * helmc.getMCOmega() / 2.;
                     double x2true = helmc.getX0() + s2true * Math.sin(arg2) * Math.cos(helmc.getPhi0()-arg2) / arg2;
                     double y2true = helmc.getY0() + s2true * Math.sin(arg2) * Math.sin(helmc.getPhi0()-arg2) / arg2;
-                    System.out.println("True s1: "+s1true+" x1: "+x1true+" y1: "+y1true);
-                    System.out.println("True s2: "+s2true+" x2: "+x2true+" y2: "+y2true);
+ //                   System.out.println("True s1: "+s1true+" x1: "+x1true+" y1: "+y1true);
+ //                   System.out.println("True s2: "+s2true+" x2: "+x2true+" y2: "+y2true);
                 }
                 System.out.println("******* Bad Z Check *******");
-                System.out.println(" x1: "+hit1.getCorrectedPosition().x()+
-                                   " y1: "+hit1.getCorrectedPosition().y()+
-                                   " x2: "+hit2.getCorrectedPosition().x()+
-                                   " y2: "+hit2.getCorrectedPosition().y());
-                System.out.println("s1min: " + smin(r1) + " s1max: " + smax(r1) + " zmin1: " + zmin1 +
-                        " zmax1: " + zmax1);
-                System.out.println("s2min: " + smin(r2) + " s2max: " + smax(r2) + " zmin2: " + zmin2 +
-                        " zmax2: " + zmax2);
-                System.out.println("Hit1: "+hit1.toString());
-                System.out.println("Hit 2: "+hit2.toString());
+//                System.out.println(" x1: "+hit1.getCorrectedPosition().x()+
+//                                   " y1: "+hit1.getCorrectedPosition().y()+
+//                                   " x2: "+hit2.getCorrectedPosition().x()+
+//                                   " y2: "+hit2.getCorrectedPosition().y());
+//                System.out.println("s1min: " + smin(r1) + " s1max: " + smax(r1) + " zmin1: " + zmin1 +
+//                        " zmax1: " + zmax1);
+//                System.out.println("s2min: " + smin(r2) + " s2max: " + smax(r2) + " zmin2: " + zmin2 +
+//                        " zmax2: " + zmax2);
+//                System.out.println("Hit1: "+hit1.toString());
+//                System.out.println("Hit 2: "+hit2.toString());
                 if (hit2 instanceof HelicalTrackCross) {
                     HelicalTrackCross c2 = (HelicalTrackCross) hit2;
                     for (HelicalTrackStrip strip : c2.getStrips()) {
-                        System.out.println("u: "+strip.u().toString());
-                        System.out.println("v: "+strip.v().toString());
-                        System.out.println("origin: "+strip.origin().toString());
-                        System.out.println("umeas: "+strip.umeas()+" vmin: "+strip.vmin()+" vmax: "+strip.vmax());
+//                        System.out.println("u: "+strip.u().toString());
+//                        System.out.println("v: "+strip.v().toString());
+//                        System.out.println("origin: "+strip.origin().toString());
+//                        System.out.println("umeas: "+strip.umeas()+" vmin: "+strip.vmin()+" vmax: "+strip.vmax());
                     }
 
                 }
@@ -140,6 +150,16 @@
 
     public boolean CheckSector(SeedCandidate seed, Sector sector) {
 
+
+        boolean match = false;
+        if (_diag != null && seed.isTrueSeed()) {
+            for (HelicalTrackHit hit : sector.Hits()) {
+                for (MCParticle mcp : hit.getMCParticles()) {
+                    if (seed.getMCParticles().contains(mcp)) match = true;
+                }
+            }
+        }
+
         //  Get limits on r, phi, and z for hits in this sector
         double rmin = sector.rmin();
         double rmax = sector.rmax();
@@ -155,6 +175,9 @@
         //  Check each hit for compatibility with this sector
         for (HelicalTrackHit hit : seed.getHits()) {
 
+            //  Adjust the hit position for stereo hits
+            CorrectHitPosition(hit, seed);
+
             //  Calculate the max track angle change between the hit and sector layer
             double dphitrk1 = dphimax(hit.r(), rmin);
             double dphitrk2 = dphimax(hit.r(), rmax);
@@ -165,7 +188,14 @@
 
             //  The maximum dphi is the sum of the track bend and half the sector span
             double dphimx = dphitrk + dphisec;
-            if (dphi > dphimx) return false;
+            if (dphi > dphimx) {
+                if (match) {
+                    for (MCParticle mcp : seed.getMCParticles()) {
+                        System.out.println("phi sector error - p: "+mcp.getMomentum().toString());
+                    }
+                }
+                return false;
+            }
 
             double smin1 = smin(rmin);
             double smax1 = smax(rmax);
@@ -183,7 +213,14 @@
 
             //  Check the z0 limits
             boolean zOK = checkz0(smin1, smax1, zmin, zmax, smin2, smax2, zmin2, zmax2);
-            if (!zOK) return false;
+            if (!zOK) {
+                if (match) {
+                    for (MCParticle mcp : seed.getMCParticles()) {
+                        System.out.println("z sector error - p: "+mcp.getMomentum().toString());
+                    }
+                }
+                return false;
+            }
         }
         return true;
     }

lcsim/src/org/lcsim/recon/tracking/seedtracker
SeedCandidate.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- SeedCandidate.java	1 Sep 2009 22:54:58 -0000	1.6
+++ SeedCandidate.java	3 Sep 2009 17:52:29 -0000	1.7
@@ -87,7 +87,7 @@
         _helix = seed.getHelix();
         _msmap.putAll(seed.getMSMap());
         _scatters = seed.getScatterAngles();
-        _unchecked = seed.getUncheckedLayers();
+        setUncheckedLayers(seed.getUncheckedLayers());
         _mcpset.addAll(seed.getMCParticles());
     }
     
@@ -193,7 +193,8 @@
     }
 
     public void setUncheckedLayers(List<SeedLayer> unchecked) {
-        _unchecked = new LinkedList<SeedLayer>(unchecked);
+        _unchecked = new LinkedList<SeedLayer>();
+        if (unchecked != null) _unchecked.addAll(unchecked);
         return;
     }
 
@@ -210,12 +211,12 @@
     }
 
     public boolean isTrueSeed() {
-//        boolean hasmuon = false;
-//        for (MCParticle mcp : _mcpset) {
-//            if (Math.abs(mcp.getPDGID()) == 13) hasmuon = true;
-//        }
-//        return _mcpset.size() > 0 && hasmuon;
-        return _mcpset.size() > 0;
+        boolean hasmuon = false;
+        for (MCParticle mcp : _mcpset) {
+            if (Math.abs(mcp.getPDGID()) == 13) hasmuon = true;
+        }
+        return _mcpset.size() > 0 && hasmuon;
+//        return _mcpset.size() > 0;
     }
 
     public double getBField() {

lcsim/src/org/lcsim/recon/tracking/seedtracker
SeedTrackFinder.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- SeedTrackFinder.java	1 Sep 2009 22:54:58 -0000	1.13
+++ SeedTrackFinder.java	3 Sep 2009 17:52:29 -0000	1.14
@@ -27,6 +27,8 @@
     private ConfirmerExtender _confirmer;
     private List<SeedCandidate> _trackseeds;
     private ISeedTrackerDiagnostics _diag = null;
+    private Set<MCParticle> _seededmcp;
+    private Set<MCParticle> _confirmedmcp;
 
     TrackCheck _trackCheck; // set by SeedTracker
 
@@ -45,6 +47,10 @@
         //  Create a list of track seeds that have been found
         _trackseeds = new ArrayList<SeedCandidate>();
 
+        //  Create a set of MC Particles that have been seeded, confirmed
+        _seededmcp = new HashSet<MCParticle>();
+        _confirmedmcp = new HashSet<MCParticle>();
+
     }
 
     public void setDiagnostic(ISeedTrackerDiagnostics d) {
@@ -59,9 +65,6 @@
         //  Instantiate the fast hit checker
         FastCheck checker = new FastCheck(strategy, bfield, _diag);
 
-        //  Create a set of MCParticles that have been found as seeds
-        Set<MCParticle> mcp_seeds = new HashSet<MCParticle>();
-
         //  Get the SeedLayers for this strategy
         List<SeedLayer> seedlayerlist = strategy.getLayers(SeedLayer.SeedType.Seed);
         if (seedlayerlist.size() != 3) 
@@ -108,8 +111,9 @@
                             continue;
                         }
 
+                        //  Found a seed - if it's a true seed, add the MC Particle to those that were seeded
                         if (_diag != null) {
-                            if (seed.isTrueSeed()) mcp_seeds.addAll(seed.getMCParticles());
+                            if (seed.isTrueSeed()) _seededmcp.addAll(seed.getMCParticles());
                         }
 
                         //  See if we can fit a helix to this seed candidate
@@ -126,6 +130,11 @@
                         success = _confirmer.Confirm(seed, strategy, bfield);
                         if (!success) continue;
 
+                        //  Confirmed a seed - if it's a true seed, add the MC Particle to those that were confirmed
+                        if (_diag != null) {
+                            if (seed.isTrueSeed()) _confirmedmcp.addAll(seed.getMCParticles());
+                        }
+
                         //  Try to extend each confirmed seed candidates to make a track candidate
                         List<SeedCandidate> confirmedlist = _confirmer.getResult();
                         for (SeedCandidate confirmedseed : confirmedlist) {
@@ -140,7 +149,7 @@
 
         //  Done with track finding for this strategy
         if (_diag != null)
-            _diag.fireFinderDone(_trackseeds, mcp_seeds);
+            _diag.fireFinderDone(_trackseeds, _seededmcp);
         return _trackseeds.size() > 0;
     }
 
@@ -150,5 +159,15 @@
 
     public void clearTrackSeedList() {
         _trackseeds.clear();
+        _seededmcp.clear();
+        _confirmedmcp.clear();
+    }
+
+    public Set<MCParticle> getSeededMCParticles() {
+        return _seededmcp;
+    }
+
+    public Set<MCParticle> getConfirmedMCParticles() {
+        return _confirmedmcp;
     }
 }
\ No newline at end of file

lcsim/src/org/lcsim/recon/tracking/seedtracker
SeedTracker.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- SeedTracker.java	19 Aug 2009 22:12:27 -0000	1.10
+++ SeedTracker.java	3 Sep 2009 17:52:29 -0000	1.11
@@ -9,9 +9,12 @@
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import java.util.Set;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
 import org.lcsim.geometry.Detector;
 import org.lcsim.recon.tracking.seedtracker.diagnostic.ISeedTrackerDiagnostics;
 import org.lcsim.util.Driver;
@@ -99,6 +102,16 @@
         //  Make tracks from the final list of track seeds
         _maketracks.Process(event, trackseeds, _bfield);
 
+        //  Save the MC Particles that have been seeded
+        Set<MCParticle> seededmcpset = _finder.getSeededMCParticles();
+        List<MCParticle> seededmcp = new ArrayList<MCParticle>(seededmcpset);
+        event.put("SeededMCParticles", seededmcp, MCParticle.class, 0);
+
+        //  Save the MC Particles that have been confirmed
+        Set<MCParticle> confirmedmcpset = _finder.getConfirmedMCParticles();
+        List<MCParticle> confirmedmcp = new ArrayList<MCParticle>(confirmedmcpset);
+        event.put("ConfirmedMCParticles", confirmedmcp, MCParticle.class, 0);
+
         //  Clear the list of track seeds accumulated in the track finder
         _finder.clearTrackSeedList();
 
CVSspam 0.2.8