lcsim/src/org/lcsim/util/swim
diff -u -r1.4 -r1.5
--- Helix.java 20 Aug 2005 23:25:07 -0000 1.4
+++ Helix.java 22 Aug 2005 03:31:16 -0000 1.5
@@ -19,7 +19,7 @@
* All quantities in this class are dimensionless. It has no dependencies
* except for Hep3Vector (which could easily be removed).
* @author tonyj
- * @version $Id: Helix.java,v 1.4 2005/08/20 23:25:07 tonyj Exp $
+ * @version $Id: Helix.java,v 1.5 2005/08/22 03:31:16 tonyj Exp $
*/
public class Helix implements Trajectory
{
@@ -64,7 +64,8 @@
{
double darg = r*r/(2.*radius*radiusOfCenter) - radiusOfCenter/(2.*radius) - radius/(2.*radiusOfCenter);
double diff = asin(darg) + phi - phiToCenter;
- return (radius/cosLambda)*diff;
+ if (diff < 0) diff += 2*Math.PI;
+ return (Math.abs(radius)/cosLambda)*diff;
}
/**
lcsim/src/org/lcsim/util/swim
diff -u -r1.4 -r1.5
--- HelixSwimmer.java 20 Aug 2005 23:25:07 -0000 1.4
+++ HelixSwimmer.java 22 Aug 2005 03:31:16 -0000 1.5
@@ -12,7 +12,7 @@
* A simple helix smimmer for use in org.lcsim. Uses standard lcsim units
* Tesla, mm, GeV. This swimmer works for charged and neutral tracks.
* @author tonyj
- * @version $Id: HelixSwimmer.java,v 1.4 2005/08/20 23:25:07 tonyj Exp $
+ * @version $Id: HelixSwimmer.java,v 1.5 2005/08/22 03:31:16 tonyj Exp $
*/
public class HelixSwimmer
{
@@ -67,13 +67,25 @@
}
public Hep3Vector getPointAtDistance(double alpha)
{
+ if (trajectory == null) throw new RuntimeException("Trajectory not set");
return trajectory.getPointAtDistance(alpha);
}
+ public double getDistanceToRadius(double r)
+ {
+ if (trajectory == null) throw new RuntimeException("Trajectory not set");
+ return trajectory.getDistanceToInfiniteCylinder(r);
+ }
+ public double getDistanceToZ(double z)
+ {
+ if (trajectory == null) throw new RuntimeException("Trajectory not set");
+ double result = trajectory.getDistanceToZPlane(z);
+ if (result<0) result = trajectory.getDistanceToZPlane(-z);
+ return result;
+ }
public double getDistanceToCylinder(double r,double z)
{
- double x1 = trajectory.getDistanceToInfiniteCylinder(r);
- double x2 = trajectory.getDistanceToZPlane(z);
- if (x2<0) x2 = trajectory.getDistanceToZPlane(-z);
+ double x1 = getDistanceToRadius(r);
+ double x2 = getDistanceToZ(z);
return Double.isNaN(x1) ? x2 : Math.min(x1,x2);
}
}
\ No newline at end of file