lcsim/src/org/lcsim/util/swim
diff -N HelixSwimmer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HelixSwimmer.java 20 Aug 2005 01:37:17 -0000 1.1
@@ -0,0 +1,52 @@
+package org.lcsim.util.swim;
+
+import hep.physics.vec.Hep3Vector;
+
+// 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.
+ * @author tonyj
+ * @version $Id: HelixSwimmer.java,v 1.1 2005/08/20 01:37:17 tonyj Exp $
+ */
+public class HelixSwimmer
+{
+ private static final double fieldConversion = 0.299792458 / 1000; // mm
+ private double field;
+ private Helix helix;
+
+ /** 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;
+ }
+ /**
+ * 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 = iq * pt/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