Print

Print


Commit in lcsim/src/org/lcsim/fit/helicaltrack on MAIN
HelixUtils.java+28-21.11 -> 1.12
Change path length calculation for a hit being added to a helix to better match what is done in HelicalTrackFitter (namely, order in z and require successive layers to not loop).  Old code used helix fit, which allowed very large path lengths under certain conditions (such as the helix slope was estimated to be near 0).

lcsim/src/org/lcsim/fit/helicaltrack
HelixUtils.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- HelixUtils.java	14 Nov 2010 00:33:25 -0000	1.11
+++ HelixUtils.java	1 Feb 2011 22:45:05 -0000	1.12
@@ -77,8 +77,34 @@
      * @return path length from the DCA to the hit
      */
     public static double PathLength(HelicalTrackFit helix, HelicalTrackHit hit) {
-        //  Return the path length from the DCA
-        return PathCalc(helix.xc(), helix.yc(), helix.R(), helix.x0(), helix.y0(), hit.x(), hit.y());
+
+        //  Calculate the shortest path length from the DCA to the hit x-y coordinates
+        double path0 = PathCalc(helix.xc(), helix.yc(), helix.R(), helix.x0(), helix.y0(), hit.x(), hit.y());
+        if (hit instanceof HelicalTrack2DHit) return path0;
+
+        //  Find the closest 3D hit in the z coordinate (if there is one)
+        HelicalTrackHit close = null;
+        double zhit = hit.z();
+        for (HelicalTrackHit fithit : helix.PathMap().keySet()) {
+            if (!(fithit instanceof HelicalTrack2DHit)) {
+
+                 if (close == null) {
+                    //  If this is the first 3D hit, mark it as being closest
+                    close = fithit;
+                } else {
+                    //  Check if the fithit is closer in z
+                    if (Math.abs(zhit - fithit.z()) < Math.abs(zhit - close.z())) close = fithit;
+                }
+            }
+        }
+
+        //  If we didn't find another 3D hit, return the path from the DCA
+        if (close == null) return path0;
+
+        //  Find the path length for the closest hit assuming it hasn't looped
+        double path = helix.PathMap().get(close) +
+                PathCalc(helix.xc(), helix.yc(), helix.R(), close.x(), close.y(), hit.x(), hit.y());
+        return path;
     }
     
     /**
CVSspam 0.2.8