lcsim/src/org/lcsim/util/swim
diff -u -r1.19 -r1.20
--- Helix.java 8 Nov 2005 20:58:53 -0000 1.19
+++ Helix.java 30 May 2006 06:17:50 -0000 1.20
@@ -13,8 +13,6 @@
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.VecOp;
-
-
/**
* This class represents a helix with its axis aligned along Z.
* All quantities in this class are dimensionless. It has no dependencies
@@ -23,11 +21,11 @@
* For more info on swimming see <a href="doc-files/transport.pdf">this paper</a>
* by Paul Avery.
* @author tonyj
- * @version $Id: Helix.java,v 1.19 2005/11/08 20:58:53 tonyj Exp $
+ * @version $Id: Helix.java,v 1.20 2006/05/30 06:17:50 jstrube Exp $
*/
public class Helix implements Trajectory
{
- /** Creates a new instance of Helix.
+ /** Creates a new instance of Helix.
* Parameters according to <a href="doc-files/L3_helix.pdf">the L3 conventions</a><br />
* Please also have a look at <img src="doc-files/Helix-1.png" alt="Helix-1.png">
* <img src="doc-files/Helix-2.png" alt="Helix-2.png">
@@ -53,6 +51,7 @@
sinLambda = sin(lambda);
xCenter = origin.x() + radius*sin(phi);
yCenter = origin.y() - radius*cos(phi);
+ setSpacialParameters();
}
/**
@@ -112,13 +111,8 @@
*/
public double getDistanceToPoint(Hep3Vector point) {
double tanLambda = sinLambda/cosLambda;
- double r = abs(radius);
- double px = r*cosPhi;
- double py = r*sinPhi;
- double pz = r*tanLambda;
- double rho = -cosLambda/radius;
double pMag = sqrt(px*px + py*py + pz*pz);
- Hep3Vector p0 = new BasicHep3Vector(px, py, pz);
+ Hep3Vector p0 = new BasicHep3Vector(px, py, pz);
Hep3Vector pCrossB = new BasicHep3Vector(py, -px, 0);
// first, the point needs to be translated into the first period
@@ -153,11 +147,6 @@
*/
public double getSignedClosestDifferenceToPoint(Hep3Vector point) {
double tanLambda = sinLambda/cosLambda;
- double r = abs(radius);
- double px = r*cosPhi;
- double py = r*sinPhi;
- double pz = r*tanLambda;
- double rho = -cosLambda/radius;
Hep3Vector pCrossB = new BasicHep3Vector(py, -px, 0);
Hep3Vector xDiff = VecOp.sub(origin, point);
double pMag = sqrt(px*px + py*py + pz*pz);
@@ -183,16 +172,22 @@
// 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 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*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);
+ double p0x = px*cos(rho*alpha) - py*sin(rho*alpha);
+ double p0y = py*cos(rho*alpha) + px*sin(rho*alpha);
+ double p0z = pz*cos(rho*alpha) + pz*(1-cos(rho*alpha));
+ return new BasicHep3Vector(p0x, p0y, p0z);
+ }
+
+ /**
+ * Sets the parametereization in terms of "momentum" and charge
+ *
+ */
+ private void setSpacialParameters() {
+ abs_r = abs(radius);
+ px = abs_r*cosPhi;
+ py = abs_r*sinPhi;
+ pz = abs_r*sinLambda/cosLambda;
+ rho = -cosLambda/radius;
}
private Hep3Vector origin;
@@ -204,4 +199,14 @@
private double sinPhi;
private double cosPhi;
private double phi;
+
+ // parameterization in terms of 'momentum'
+ // A helix is a mathematical object and doesn't have "momentum",
+ // but unfortunately some of the used algorithms are expressed in terms of it.
+ // That's OK, it's a private variable.
+ private double px;
+ private double py;
+ private double pz;
+ private double abs_r;
+ private double rho;
}
lcsim/src/org/lcsim/util/swim
diff -u -r1.12 -r1.13
--- HelixSwimmer.java 8 Nov 2005 20:58:53 -0000 1.12
+++ HelixSwimmer.java 30 May 2006 06:17:50 -0000 1.13
@@ -4,6 +4,8 @@
import hep.physics.vec.Hep3Vector;
import org.lcsim.constants.Constants;
import org.lcsim.event.Track;
+import static java.lang.Math.abs;
+import static java.lang.Math.signum;
/**
* A simple helix smimmer for use in org.lcsim. Uses standard lcsim units
@@ -12,19 +14,29 @@
* For more info on swimming see <a href="doc-files/transport.pdf">this paper</a>
* by Paul Avery.
* @author tonyj
- * @version $Id: HelixSwimmer.java,v 1.12 2005/11/08 20:58:53 tonyj Exp $
+ * @version $Id: HelixSwimmer.java,v 1.13 2006/05/30 06:17:50 jstrube Exp $
*/
public class HelixSwimmer
{
+ class SpatialParameters
+ {
+ double px;
+ double py;
+ double pz;
+ int charge;
+ boolean isInvalid = true;
+ }
private double field;
private Trajectory trajectory;
-
+ private SpatialParameters spatialParms;
+ private Track track;
/** Creates a new instance of HelixSwimmer
* @param B field strength in Tesla; uniform, solenoidal, directed along z-axis
*/
public HelixSwimmer(double B)
{
field = B*Constants.fieldConversion;
+ spatialParms = new SpatialParameters();
}
/**
* Sets parameters for helix swimmmer.
@@ -51,7 +63,9 @@
{
trajectory = new Line(r0, phi, lambda);
}
+ spatialParms.isInvalid = true;
}
+
public void setTrack(Track t)
{
double omega = t.getTrackParameter(2);
@@ -60,8 +74,11 @@
double lambda = Math.atan(t.getTrackParameter(4));
double d0 = t.getTrackParameter(0);
double[] ref = t.getReferencePoint();
+ // origin of the circle that is the x-y projection of the helix
Hep3Vector origin = new BasicHep3Vector( ref[0] -d0 * Math.sin(phi), ref[1] + d0 * Math.cos(phi), ref[2] + z0);
trajectory = new Helix(origin,1/omega,phi,lambda);
+ spatialParms.isInvalid = true;
+ track=t;
}
public Hep3Vector getPointAtDistance(double alpha)
{
@@ -90,4 +107,22 @@
public double getDistanceToPoint(Hep3Vector point) {
return trajectory.getDistanceToPoint(point);
}
+
+ /**
+ * Calculates px, py, pz, iq from the Track Parameters and the B field.
+ * @return a Parameter object with the new parameters
+ */
+ // This unfortunately has to go here, because the Track parameters can't be used to get the momentum.
+ // The B field is needed in addition.
+ public SpatialParameters getSpatialParameters() {
+ if (spatialParms.isInvalid) {
+ double omega = track.getTrackParameter(2);
+ double Pt = abs((1./omega) * field);
+ spatialParms.px = Pt * Math.cos(track.getTrackParameter(1));
+ spatialParms.py = Pt * Math.sin(track.getTrackParameter(1));
+ spatialParms.pz = Pt * track.getTrackParameter(4);
+ spatialParms.charge = (int) signum(omega);
+ }
+ return spatialParms;
+ }
}