lcsim/src/org/lcsim/fit/helicaltrack
diff -u -r1.27 -r1.28
--- HelicalTrackFitter.java 13 Oct 2008 01:05:58 -0000 1.27
+++ HelicalTrackFitter.java 24 Oct 2008 21:29:20 -0000 1.28
@@ -4,7 +4,7 @@
*
* Created on March 25, 2006, 6:11 PM
*
- * $Id: HelicalTrackFitter.java,v 1.27 2008/10/13 01:05:58 partridge Exp $
+ * $Id: HelicalTrackFitter.java,v 1.28 2008/10/24 21:29:20 partridge Exp $
*/
import hep.physics.matrix.SymmetricMatrix;
@@ -235,8 +235,11 @@
cov.setElement(HelicalTrackFit.phi0Index, HelicalTrackFit.dcaIndex, -1. * _cfit.cov()[4]); // fix d0 sign convention
cov.setElement(HelicalTrackFit.dcaIndex, HelicalTrackFit.dcaIndex, _cfit.cov()[5]);
- // Calculate the arc lengths from the DCA to each hit
+ // Calculate the arc lengths from the DCA to each hit and check for backwards hits
Map<HelicalTrackHit, Double> smap = getPathLengths(hitcol);
+ for (HelicalTrackHit hit : smap.keySet()) {
+ if (smap.get(hit) < 0.) return FitStatus.CircleFitFailed;
+ }
// Check if we have enough pixel hits to do a straight-line fit of s vs z
int npix = pixel_hits.size();
@@ -462,8 +465,9 @@
private CircleFit CircleFix(CircleFit oldfit, List<HelicalTrackHit> hitlist) {
// Check if we are going around the circle in the right direction by getting
- // the path length to the first hit and checking that it is positive
- double s = HelixUtils.PathLength(oldfit, hitlist.get((0)));
+ // the path length to the last hit and checking that it is positive
+ int nhits = hitlist.size();
+ double s = HelixUtils.PathLength(oldfit, hitlist.get(nhits - 1));
if (s > 0.) return oldfit;
// Reverse the direction by changing the sign of dca, curv, and adding pi to phi0