lcsim/src/org/lcsim/util/swim
diff -u -r1.28 -r1.29
--- Helix.java 10 Feb 2010 21:57:30 -0000 1.28
+++ Helix.java 8 Mar 2010 12:13:39 -0000 1.29
@@ -25,7 +25,7 @@
* by Paul Avery.
*
* @author tonyj
- * @version $Id: Helix.java,v 1.28 2010/02/10 21:57:30 partridge Exp $
+ * @version $Id: Helix.java,v 1.29 2010/03/08 12:13:39 cassell Exp $
*/
public class Helix implements Trajectory {
/**
@@ -138,9 +138,11 @@
// Calculate how far we are from the desired point
Hep3Vector delta = VecOp.sub(pos, point);
+ int count = 0;
+ int maxcount = 20;
// Iteratively close in on the point of closest approach
while (delta.magnitude() > eps) {
-
+ count++;
// Calculate the coefficients of the indicial equations a*s^2 + b*s + c = 0
double c = VecOp.dot(u, delta);
double b = 1. - rho * VecOp.dot(VecOp.cross(u, zhat), delta);
@@ -164,15 +166,16 @@
u = unew;
pos = pos1;
stot += s1;
- if (Math.abs(s1) < eps/100.) return stot;
+ if (Math.abs(s1) < eps) return stot;
} else {
unew = propagateDirection(u, s2);
u = unew;
pos = pos2;
stot += s2;
- if (Math.abs(s2) < eps/100.) return stot;
+ if (Math.abs(s2) < eps) return stot;
}
+ if(count > maxcount)return stot;
// Update how far we are from the specified point
delta = VecOp.sub(pos, point);
}
@@ -381,4 +384,5 @@
// Set the desired precision in finding the point closest to the track
private double eps = 1.e-6; // 1 nm ought to be good enough for government work!
+ public void setExtrapToPointPrecision(double prec){eps = prec;}
}