Print

Print


Commit in lcsim/src/org/lcsim/util/swim on MAIN
Helix.java+12-51.17 -> 1.18
added public accessors for radius and center of helix as per request by Nick Sinev.
Deferred costly evaluation of phiToCenter and radiusOfCenter to getDistanceToInfiniteCylinder, the only function that actually uses them.

lcsim/src/org/lcsim/util/swim
Helix.java 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- Helix.java	28 Oct 2005 19:56:22 -0000	1.17
+++ Helix.java	30 Oct 2005 06:10:04 -0000	1.18
@@ -20,7 +20,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.17 2005/10/28 19:56:22 jstrube Exp $
+ * @version $Id: Helix.java,v 1.18 2005/10/30 06:10:04 jstrube Exp $
  */
 public class Helix implements Trajectory
 {
@@ -50,8 +50,6 @@
       sinLambda = sin(lambda);
       xCenter = origin.x() + radius*sin(phi);
       yCenter = origin.y() - radius*cos(phi);
-      phiToCenter = atan2(yCenter,xCenter);
-      radiusOfCenter = sqrt(xCenter*xCenter + yCenter*yCenter);
    }
 
    /**
@@ -67,6 +65,15 @@
       return new BasicHep3Vector(x,y,z);
    }
 
+   public double getRadius() {
+       return radius;
+   }
+   
+   
+   public Hep3Vector getCenterXY() {
+       return new BasicHep3Vector(xCenter, yCenter, 0);
+   }
+   
    
    public double getDistanceToZPlane(double z)
    {
@@ -80,6 +87,8 @@
     */
    public double getDistanceToInfiniteCylinder(double r)
    {
+       double phiToCenter = atan2(yCenter,xCenter);
+       double radiusOfCenter = sqrt(xCenter*xCenter + yCenter*yCenter);
        // Negative radius doesn't make sense
       if (r<0) throw new IllegalArgumentException("radius "+r+"<0");
       double darg  = r*r/(2.*radius*radiusOfCenter) - radiusOfCenter/(2.*radius) - radius/(2.*radiusOfCenter);
@@ -192,6 +201,4 @@
    private double sinPhi;
    private double cosPhi;
    private double phi;
-   private double phiToCenter;
-   private double radiusOfCenter;
 }
CVSspam 0.2.8