lcsim/src/org/lcsim/util/swim
diff -N Line.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Line.java 20 Aug 2005 19:16:20 -0000 1.1
@@ -0,0 +1,36 @@
+package org.lcsim.util.swim;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+/**
+ * A straight line
+ * @author tonyj
+ * @version $Id: Line.java,v 1.1 2005/08/20 19:16:20 tonyj Exp $
+ */
+public class Line implements Trajectory
+{
+ private double sinPhi;
+ private double cosPhi;
+ private double sinLambda;
+ private double cosLambda;
+ private Hep3Vector origin;
+
+ public Line(Hep3Vector origin, double phi, double lambda)
+ {
+ this.origin = origin;
+ sinPhi = Math.sin(phi);
+ cosPhi = Math.cos(phi);
+ sinLambda = Math.sin(lambda);
+ cosLambda = Math.cos(lambda);
+ }
+
+ public Hep3Vector getPointAtDistance(double alpha)
+ {
+ double z = origin.z() + alpha*sinLambda;
+ double dr = alpha*cosLambda;
+ double x = origin.x() + dr*sinPhi;
+ double y = origin.y() + dr*cosPhi;
+ return new BasicHep3Vector(x,y,z);
+ }
+}
lcsim/src/org/lcsim/util/swim
diff -u -r1.2 -r1.3
--- HelixSwimmer.java 20 Aug 2005 17:42:39 -0000 1.2
+++ HelixSwimmer.java 20 Aug 2005 19:16:20 -0000 1.3
@@ -1,52 +1,73 @@
package org.lcsim.util.swim;
+import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
+import org.lcsim.constants.Constants;
+import org.lcsim.event.Track;
+
// For more info on swimming see: http://www.phys.ufl.edu/~avery/fitting/transport.pdf
/**
* A simple helix smimmer for use in org.lcsim. Uses standard lcsim units
- * Tesla, mm, GeV.
+ * Tesla, mm, GeV. This swimmer works for charged and neutral tracks.
* @author tonyj
- * @version $Id: HelixSwimmer.java,v 1.2 2005/08/20 17:42:39 jstrube Exp $
+ * @version $Id: HelixSwimmer.java,v 1.3 2005/08/20 19:16:20 tonyj Exp $
*/
public class HelixSwimmer
{
- private static final double fieldConversion = 0.299792458 / 1000; // mm
private double field;
- private Helix helix;
+ private Trajectory trajectory;
/** Creates a new instance of HelixSwimmer
* @param B field strength in Tesla; uniform, solenoidal, directed along z-axis
*/
public HelixSwimmer(double b)
{
- field = b*fieldConversion;
+ field = b*Constants.fieldConversion;
+ }
+ /**
+ * Sets parameters for helix swimmmer.
+ *
+ * @param p 3-momentum (px,py,pz)
+ * @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)
+ {
+ double temp = p.x()*p.x()+p.y()*p.y();
+ double pmom = Math.sqrt(temp + p.z()*p.z());
+ double sin_lambda = p.z()/pmom;
+ double phi = Math.atan2(p.y(),p.x());
+ double lambda = Math.asin(sin_lambda);
+
+ if (iq != 0 && field != 0)
+ {
+ double pt = Math.sqrt(temp);
+ double radius = pt/(iq*field);
+ trajectory = new Helix(r0,radius,phi,lambda);
+ }
+ else
+ {
+ trajectory = new Line(r0, phi, lambda);
+ }
+
+ }
+ public void setTrack(Track t)
+ {
+ double omega = t.getTrackParameter(2);
+ double z0 = t.getTrackParameter(3);
+ double phi = t.getTrackParameter(1);
+ double lambda = Math.atan(t.getTrackParameter(4));
+ double d0 = t.getTrackParameter(0);
+ int iCharge = (int) Math.signum(omega);
+ double halfpi = Math.PI/2;
+ double[] ref = t.getReferencePoint();
+ Hep3Vector origin = new BasicHep3Vector( ref[0] + d0 * Math.cos(phi + iCharge * halfpi), ref[1] + d0 * Math.sin(phi + iCharge * halfpi), ref[2] + z0);
+ trajectory = new Helix(origin,1/omega,phi,lambda);
+ }
+ public Hep3Vector getPointAtDistance(double alpha)
+ {
+ return trajectory.getPointAtDistance(alpha);
}
- /**
- * Sets parameters for helix swimmmer.
- *
- * @param p 3-momentum (px,py,pz)
- * @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)
- {
- if (iq != 0 && field != 0)
- {
- double temp = p.x()*p.x()+p.y()*p.y();
- double pmom = Math.sqrt(temp + p.z()*p.z());
- double sin_lambda = p.z()/pmom;
- double pt = Math.sqrt(temp);
- double radius = pt / (iq*field);
- double phi = Math.atan2(p.y(),p.x());
- double lambda = Math.asin(sin_lambda);
- helix = new Helix(r0,radius,phi,lambda);
- }
-
- }
- public Hep3Vector getPointAtDistance(double alpha)
- {
- return helix.getPointAtDistance(alpha);
- }
}
\ No newline at end of file
lcsim/src/org/lcsim/util/swim
diff -u -r1.1 -r1.2
--- Helix.java 18 Aug 2005 15:24:04 -0000 1.1
+++ Helix.java 20 Aug 2005 19:16:20 -0000 1.2
@@ -8,9 +8,9 @@
* 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.1 2005/08/18 15:24:04 tonyj Exp $
+ * @version $Id: Helix.java,v 1.2 2005/08/20 19:16:20 tonyj Exp $
*/
-public class Helix
+public class Helix implements Trajectory
{
/** Creates a new instance of Helix.
* @param origin A point on the helix
@@ -34,9 +34,7 @@
phiToCenter = Math.atan2(yCenter,xCenter);
radiusOfCenter = Math.sqrt(xCenter*xCenter + yCenter*yCenter);
}
- /**
- * Gets a point after traveling distance alpha from the origin along the helix
- */
+
public Hep3Vector getPointAtDistance(double alpha)
{
double darg = alpha*cosLambda/radius - phi;