lcsim/src/org/lcsim/util/swim
diff -u -r1.16 -r1.17
--- Helix.java 28 Oct 2005 07:57:27 -0000 1.16
+++ Helix.java 28 Oct 2005 19:56:22 -0000 1.17
@@ -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.16 2005/10/28 07:57:27 jstrube Exp $
+ * @version $Id: Helix.java,v 1.17 2005/10/28 19:56:22 jstrube Exp $
*/
public class Helix implements Trajectory
{
@@ -96,7 +96,7 @@
* <a href=doc-files/fitting/transport.pdf>
* Paul Avery's excellent text</a>
* @param point Point in Space to swim to.
- * @return the length Parameter s
+ * @return the length Parameter alpha
*/
public double getDistanceToPoint(Hep3Vector point) {
double tanLambda = sinLambda/cosLambda;
@@ -111,29 +111,26 @@
// first, the point needs to be translated into the first period
Hep3Vector xDiff = VecOp.sub(origin, point);
- double zPos = abs(xDiff.z());
+ double zPos = xDiff.z();
int addedQuarterPeriods = 0;
// these are two mutually exclusive cases and two while loops
// may not be the best way to express this
- while (zPos > abs(radius*tanLambda*Math.PI/2)) {
- zPos -= abs(radius*tanLambda*Math.PI/2);
- ++addedQuarterPeriods;
- }
- while (zPos < -abs(radius*tanLambda*Math.PI/2)) {
- zPos += abs(radius*tanLambda*Math.PI/2);
+
+ while (abs(zPos) > abs(radius*tanLambda*Math.PI/2)) {
+ zPos -= signum(zPos)*abs(radius*tanLambda*Math.PI/2);
++addedQuarterPeriods;
}
// Make sure the helix is in the right quadrant for the atan
- if (addedQuarterPeriods % 2 != 0)
- ++addedQuarterPeriods;
- if (point.z()<origin.z())
+ if (zPos > 0 && addedQuarterPeriods > 0)
addedQuarterPeriods *= -1;
+ if (addedQuarterPeriods % 2 != 0)
+ addedQuarterPeriods += signum(addedQuarterPeriods);
xDiff = new BasicHep3Vector(xDiff.x(), xDiff.y(), zPos);
double factorA1 = pMag - pz*pz/pMag - (VecOp.dot(xDiff, pCrossB))*rho;
double factorA2 = (VecOp.dot(xDiff, p0) - xDiff.z()*pz)*rho;
// System.err.print("addedQuarterPeriods: " + addedQuarterPeriods);
// System.err.printf("result:%.3f + %.3f\n", addedQuarterPeriods*(radius/cosLambda*Math.PI/2), Math.atan(factorA2/factorA1) / -rho);
- return addedQuarterPeriods*abs(radius/cosLambda*Math.PI/2) + signum(radius)*Math.atan(factorA2/factorA1) / -rho;
+ return addedQuarterPeriods*abs(radius/cosLambda*Math.PI/2) + Math.atan(factorA2/factorA1) / -rho;
}
@@ -173,16 +170,16 @@
// Returns the "momentum" at the length s from the starting point.
// This uses the definition in http://www.phys.ufl.edu/~avery/fitting/transport.pdf
- public Hep3Vector getTangentAtDistance(double s) {
+ public Hep3Vector getTangentAtDistance(double alpha) {
double r = abs(radius);
double p0x = r*cosPhi;
double p0y = r*sinPhi;
double p0z = r*sinLambda/cosLambda;
double rho = -cosLambda/radius;
- double px = p0x*cos(rho*s) - p0y*sin(rho*s);
- double py = p0y*cos(rho*s) + p0x*sin(rho*s);
- double pz = p0z*cos(rho*s) + p0z*(1-cos(rho*s));
+ double px = p0x*cos(rho*alpha) - p0y*sin(rho*alpha);
+ double py = p0y*cos(rho*alpha) + p0x*sin(rho*alpha);
+ double pz = p0z*cos(rho*alpha) + p0z*(1-cos(rho*alpha));
return new BasicHep3Vector(px, py, pz);
}
lcsim/src/org/lcsim/util/swim
diff -u -r1.8 -r1.9
--- HelixSwimmer.java 19 Oct 2005 10:32:54 -0000 1.8
+++ HelixSwimmer.java 28 Oct 2005 19:56:22 -0000 1.9
@@ -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.8 2005/10/19 10:32:54 jstrube Exp $
+ * @version $Id: HelixSwimmer.java,v 1.9 2005/10/28 19:56:22 jstrube Exp $
*/
public class HelixSwimmer
{
@@ -33,7 +33,7 @@
* @param r0 initial position(x0,y0,z0)
* @param iq charge iq = q/|e| = +1/0/-1
*/
- public void setTrack(Hep3Vector p, Hep3Vector r0, int iq)
+ public void setTrack(Hep3Vector p, Hep3Vector r0, double iq)
{
double temp = p.x()*p.x()+p.y()*p.y();
double pmom = Math.sqrt(temp + p.z()*p.z());