1 removed + 7 modified, total 8 files
lcsim/src/org/lcsim/util/swim
diff -u -r1.6 -r1.7
--- Helix.java 22 Aug 2005 17:51:47 -0000 1.6
+++ Helix.java 23 Aug 2005 05:41:07 -0000 1.7
@@ -19,7 +19,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.6 2005/08/22 17:51:47 tonyj Exp $
+ * @version $Id: Helix.java,v 1.7 2005/08/23 05:41:07 jstrube Exp $
*/
public class Helix implements Trajectory
{
@@ -74,20 +74,14 @@
* Swims the helix along its trajectory to the
* point of closest approach to the given SpacePoint.
* The equation to solve for s is an O(2) Taylor-expansion.
- * The parameterization is as follows:<br />
- * p<sub>x</sub> = p<sub>0x</sub> cos(&rho s) - p<sub>0y</sub> sin(&rho s)<br />
- * p<sub>y</sub> = p<sub>0y</sub> cos(&rho s) + p<sub>0x</sub> sin(&rho s)<br />
- * p<sub>z</sub> = p<sub>0z</sub><br />
- * x = x<sub>0</sub> + p<sub>0x</sub>/a sin(&rho s) - p<sub>0y</sub>/a (1-cos(&rho s))<br />
- * y = y<sub>0</sub> + p<sub>0y</sub>/a sin(&rho s) + p<sub>0x</sub>/a (1-cos(&rho s))<br />
- * z = z<sub>0</sub> + p<sub>z</sub>/p s<br />
- * a = -0.299792458 B q, where [B] = T and [q] = e;<br />
- * &rh0 = a / p;<br />
* @param point Point in Space to swim to.
* @return the length Parameter s
*/
- public double getDOCA(Hep3Vector point) {
- // Calculate both solutions of the quadratic equation.
+ public double getDistanceFromHelixToPoint(Hep3Vector point) {
+ // FIXME Tony, could you please implement equals in VecOp or in Hep3Vector and fix this ?
+ if (point == origin)
+ return 0;
+ // Calculate both solutions of the quadratic equation.
// Then apply an additional constraint.
double cosPhi = cos(phi);
double sinPhi = sin(phi);
@@ -102,34 +96,32 @@
double numerator = (pMag + cosLambda*factorA)*radius;
double denominator = cosLambda*cosLambda* factorA;
-
+
double factorB = numerator/denominator;
double factorCNum = 2*radius*radius*(xDiff.x()*cosPhi + xDiff.y()*sinPhi + xDiff.z()*tanLambda);
double factorCDenom = cosLambda*cosLambda*(xDiff.x()*cosPhi + xDiff.y()*sinPhi);
double factorC = factorCNum/factorCDenom;
- // FIXME need to check for consistency between s and alpha. For now this function also swims.
-
// "plus case"
double length1 = factorB + sqrt(factorB*factorB + factorC);
// "minus case"
double length2 = factorB - sqrt(factorB*factorB + factorC);
// Swim the helix to the two possible positions and check which one is closer
- Hep3Vector newMomentum = getMomentumAtLength(length1);
- Hep3Vector newPosition = getPositionAtLength(length1);
+ Hep3Vector newMomentum = getMomentumAtDistance(length1);
+ Hep3Vector newPosition = getPointAtDistance(length1);
// see if the sufficient requirement of a minimum is met
// Momentum at the new position x B Field;
Hep3Vector pCrossB = new BasicHep3Vector(newMomentum.y(), -newMomentum.x(), 0);
// Spacial difference Vector at the new location
- Hep3Vector newXDiff = VecOp.sub(newMomentum, point);
- double rho = cosLambda/radius;
+ Hep3Vector newXDiff = VecOp.sub(newPosition, point);
+ double rho = -cosLambda/radius;
if (pMag-rho*VecOp.dot(newXDiff, pCrossB) > 0 )
return newXDiff.magnitude();
- return VecOp.sub(getPositionAtLength(length2), point).magnitude();
+ return VecOp.sub(getPointAtDistance(length2), point).magnitude();
}
// Returns the "momentum" at the length s from the starting point.
@@ -137,33 +129,18 @@
// FIXME if alpa and s can be transformed into one another, this function can be obsoleted
// NOTE to FIXME: x and p are orthogonal in the x-y plane (assuming x0 = (0,0,0))
// That should be enough of a requirement to obsolete this function
- private Hep3Vector getMomentumAtLength(double s) {
+ Hep3Vector getMomentumAtDistance(double s) {
double p0x = radius*cos(phi);
double p0y = radius*sin(phi);
double p0z = radius*sinLambda/cosLambda;
- double rho = cosLambda/radius;
+ 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));
return new BasicHep3Vector(px, py, pz);
}
-
- // Returns the point at the length s from the starting point.
- // FIXME if s and alpha are the same or can be transformed into one another, this is obsolete
- private Hep3Vector getPositionAtLength(double s) {
- double p0x = radius*cos(phi);
- double p0y = radius*sin(phi);
- double p0z = radius*sinLambda/cosLambda;
- double rho = cosLambda/radius;
- double p0Mag = sqrt(p0x*p0x + p0y*p0y + p0z*p0z);
-
- double x = origin.x() + p0x/rho/p0Mag*sin(rho*s) - p0y/rho/p0Mag*(1-cos(rho*s));
- double y = origin.y() + p0y/rho/p0Mag*sin(rho*s) + p0x/rho/p0Mag*(1-cos(rho*s));
- double z = origin.z() + p0z/rho/p0Mag*sin(rho*s) + p0z/p0Mag*(s-sin(rho*s)/rho);
- return new BasicHep3Vector(x, y, z);
- }
-
+
private Hep3Vector origin;
private double xCenter;
private double yCenter;
lcsim/src/org/lcsim/util/swim
diff -u -r1.3 -r1.4
--- Trajectory.java 22 Aug 2005 17:51:47 -0000 1.3
+++ Trajectory.java 23 Aug 2005 05:41:07 -0000 1.4
@@ -5,7 +5,7 @@
/**
* A particle trajectory (either a Helix or a Line)
* @author tonyj
- * @version $Id: Trajectory.java,v 1.3 2005/08/22 17:51:47 tonyj Exp $
+ * @version $Id: Trajectory.java,v 1.4 2005/08/23 05:41:07 jstrube Exp $
*/
public interface Trajectory
{
@@ -26,4 +26,12 @@
* Note distance may be negative.
*/
public double getDistanceToZPlane(double z);
+
+ /**
+ * Calculates the shortest distance of a point to the trajectory
+ * @param point The point in space
+ * @return the distance of closest approach in mm
+ */
+ // FIXME this should be a point rather than a vector
+ public double getDistanceFromHelixToPoint(Hep3Vector point);
}
lcsim/src/org/lcsim/util/swim
diff -u -r1.2 -r1.3
--- Line.java 20 Aug 2005 23:25:07 -0000 1.2
+++ Line.java 23 Aug 2005 05:41:07 -0000 1.3
@@ -6,7 +6,7 @@
/**
* A straight line
* @author tonyj
- * @version $Id: Line.java,v 1.2 2005/08/20 23:25:07 tonyj Exp $
+ * @version $Id: Line.java,v 1.3 2005/08/23 05:41:07 jstrube Exp $
*/
public class Line implements Trajectory
{
@@ -36,7 +36,7 @@
public double getDistanceToInfiniteCylinder(double r)
{
- // Fixme: Implement properly
+ // FIXME: Implement properly
return Double.NaN;
}
@@ -44,4 +44,9 @@
{
return (z-origin.z())/sinLambda;
}
+
+ // FIXME implementation
+ public double getDistanceFromHelixToPoint(Hep3Vector point) {
+ return Double.NaN;
+ }
}
lcsim/src/org/lcsim/util/swim
diff -u -r1.5 -r1.6
--- HelixSwimmer.java 22 Aug 2005 03:31:16 -0000 1.5
+++ HelixSwimmer.java 23 Aug 2005 05:41:07 -0000 1.6
@@ -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.5 2005/08/22 03:31:16 tonyj Exp $
+ * @version $Id: HelixSwimmer.java,v 1.6 2005/08/23 05:41:07 jstrube Exp $
*/
public class HelixSwimmer
{
@@ -88,4 +88,8 @@
double x2 = getDistanceToZ(z);
return Double.isNaN(x1) ? x2 : Math.min(x1,x2);
}
+
+ public double getDistanceToPoint(Hep3Vector point) {
+ return trajectory.getDistanceFromHelixToPoint(point);
+ }
}
\ No newline at end of file
lcsim/test/org/lcsim/util/swim
diff -u -r1.2 -r1.3
--- HelixSwimTest.java 20 Aug 2005 23:25:07 -0000 1.2
+++ HelixSwimTest.java 23 Aug 2005 05:41:08 -0000 1.3
@@ -56,20 +56,21 @@
}
public void test3() throws IOException
{
- AIDA aida = AIDA.defaultInstance();
+// AIDA aida = AIDA.defaultInstance();
HelixSwim swim = new HelixSwim(5);
SpacePoint origin = new SpacePoint();
swim.setTrack(new double[]{1,1,1},origin.getCartesianArray(), 1);
double radius = swim.getRc();
- ICloud2D xy = aida.cloud2D("xy");
- ICloud2D rz = aida.cloud2D("rz");
+// ICloud2D xy = aida.cloud2D("xy");
+// ICloud2D rz = aida.cloud2D("rz");
for (double alpha = 0 ; alpha < Math.PI * 2 * radius; alpha += 10)
{
SpacePoint point = swim.getPointAtLength(alpha);
- xy.fill(point.x(),point.y());
- rz.fill(point.rxy(),point.z());
+// xy.fill(point.x(),point.y());
+// rz.fill(point.rxy(),point.z());
}
- aida.saveAs("c:\\helix.aida");
+ // FIXME please don't save aida files in tests
+// aida.saveAs("c:\\helix.aida");
}
lcsim/src/org/lcsim/recon/vertexing/zvtop4
diff -u -r1.12 -r1.13
--- ZvSwimmer.java 16 Aug 2005 19:52:04 -0000 1.12
+++ ZvSwimmer.java 23 Aug 2005 05:41:08 -0000 1.13
@@ -166,18 +166,18 @@
} while (Math.abs(f) > stepMin); // master loop
// recalculate helix parameters
- int phi0 = Track.ParameterName.phi0.ordinal();
- int tanLambda = Track.ParameterName.s.ordinal();
- hlxPar[phi0] = Math.atan2(tangentUnit.y(), tangentUnit.x());
- if (hlxPar[phi0] < 0)
- hlxPar[phi0] += 2. * Math.PI; // phi
- // FIXME these parameters are screwed up for sure, ZvSwimmer is to be obsoleted anyway
+// int phi0 = Track.ParameterName.phi0.ordinal();
+// int tanLambda = Track.ParameterName.s.ordinal();
+// hlxPar[phi0] = Math.atan2(tangentUnit.y(), tangentUnit.x());
+// if (hlxPar[phi0] < 0)
+// hlxPar[phi0] += 2. * Math.PI; // phi
+// // FIXME these parameters are screwed up for sure, ZvSwimmer is to be obsoleted anyway
double cosL = Math.sqrt(1. - tangentUnit.z() * tangentUnit.z());
- hlxPar[2] = 1. / (pTot * cosL); // kappa
- hlxPar[tanLambda] = tangentUnit.z() / cosL; // tan(lambda)
- hlxPar[4] = vCurPos.x(); // x
- hlxPar[5] = vCurPos.y(); // y
- hlxPar[6] = vCurPos.z(); // z
+// hlxPar[2] = 1. / (pTot * cosL); // kappa
+// hlxPar[tanLambda] = tangentUnit.z() / cosL; // tan(lambda)
+// hlxPar[4] = vCurPos.x(); // x
+// hlxPar[5] = vCurPos.y(); // y
+// hlxPar[6] = vCurPos.z(); // z
// check current position
if ( vCurPos.rxy() > maxRadius || vCurPos.z() > maxZ )
lcsim/src/org/lcsim/recon/vertexing/zvtop4
diff -u -r1.16 -r1.17
--- ZvFitter.java 16 Aug 2005 19:52:04 -0000 1.16
+++ ZvFitter.java 23 Aug 2005 05:41:08 -0000 1.17
@@ -9,17 +9,14 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
-import java.util.Collection;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.lcsim.event.Track;
import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.FieldMap;
import org.lcsim.spacegeom.CartesianPoint;
import org.lcsim.spacegeom.SpacePoint;
-import org.lcsim.util.swim.HelixSwim;
+import org.lcsim.util.swim.HelixSwimmer;
import Jama.Matrix;
@@ -27,7 +24,7 @@
* Fitter class based on a least squares method
*
* @author W.Walkowiak, 09/18/00
- * @version $Id: ZvFitter.java,v 1.16 2005/08/16 19:52:04 jstrube Exp $
+ * @version $Id: ZvFitter.java,v 1.17 2005/08/23 05:41:08 jstrube Exp $
*/
/* TODO static members only
@@ -35,13 +32,8 @@
*/
// -------------------------------------------------------------------------
public class ZvFitter {
- /*
- * --------------------------------------------------------------------
- * constructors
- * --------------------------------------------------------------------
- */
- public ZvFitter() {
- }
+ // initial guess position
+ private SpacePoint _initVtxPos;
/*
* --------------------------------------------------------------------
@@ -49,71 +41,48 @@
* --------------------------------------------------------------------
*/
- /**
- * Set the Swimmer to be used. <br>
- * default: ZvSwimmer (with it's default settings)
- */
- public void setSwimmer(ZvSwimmer value) {
- this.swimmer = value;
- }
+ private Detector detector;
- // TODO proper constructor;
- public void setDetector(Detector d) {
- detector = d;
- }
+ // default steering parameters for vertex fitting
+ private int nMaxTry = 3;
- /**
- * Get a handle to the swimmer used.
- */
- public HelixSwim swimmer() {
- return swimmer;
- }
+ private int nMaxTryInner = 2;
- /**
- * Set the maximum number of tries for outer loop. <br> -- default: 3
- */
- public void setMaxTry(int value) {
- if (value <= 0)
- value = 0;
- this.nMaxTry = value;
- }
+ // status
+ private ZvFitStatus status = ZvFitStatus.NO_TRACKS;
- /**
- * Set the maximum number of tries for inner loop. <br> -- default: 2
- */
- public void setMaxTryInner(int value) {
- if (value <= 0)
- value = 0;
- this.nMaxTryInner = value;
- }
+ private double swimDistMin = 0.1;
- /**
- * Set the maximal vertex resolution. <br> -- vertex has converged, if two
- * subsequent fits are within this distance of each other <br> -- default:
- * 0.001
- */
- public void setVtxResMax(double value) {
- if (value <= 0.)
- value = 0;
- this.vtxResMax = value;
- }
+ // FIXME constructor
+ private HelixSwimmer swimmer = new HelixSwimmer(0);
- /**
- * Set the minimum swim distance. <br> -- otherwise no swimming for the
- * track necessary <br> -- default: 0.1
+ // trackList output option
+ private boolean takeNewTrackList = false;
+
+ private Matrix vInVtxErr = null;
+
+ // members internal to doFit and related methods
+ // initial position and error
+ private SpacePoint vInVtxPos = null;
+ private double vtxResMax = 0.001;
+
+ // the vertex position vector worked on
+ private SpacePoint vVtxPos = null;
+
+ /*
+ * --------------------------------------------------------------------
+ * private members
+ * --------------------------------------------------------------------
*/
- public void setDistMin(double value) {
- if (value <= 0.)
- value = 0;
- this.swimDistMin = value;
- }
- /**
- * Choose whether to record unswum (old) or swum (new) track parameters with
- * the fitted vertex' track list.
+ // try this vertex vector
+ private SpacePoint vVtxTry = null;
+ /*
+ * --------------------------------------------------------------------
+ * constructors
+ * --------------------------------------------------------------------
*/
- public void takeNewTrackList(boolean choice) {
- this.takeNewTrackList = choice;
+ public ZvFitter() {
}
public ZvFitStatus doFit(ZvVertex vtx) {
@@ -228,12 +197,12 @@
System.err.println("Could not remove element");
}
trackList.add(track);
- ZvFitStatus swimStatus = swimmer.swimTo(track, location);
- if (! swimStatus.success()) {
- System.out.println("SwimStatus is (in ZvFitter): " + swimStatus);
- status = ZvFitStatus.SWIM_FAILURE;
- return vertex;
- }
+// ZvFitStatus swimStatus = swimmer.getDistanceToPoint();
+// if (! swimStatus.success()) {
+// System.out.println("SwimStatus is (in ZvFitter): " + swimStatus);
+// status = ZvFitStatus.SWIM_FAILURE;
+// return vertex;
+// }
}
// fill tPar and tDee
// TODO trackParameters !
@@ -432,13 +401,13 @@
Track[] trackArray2 = trackList.toArray(new Track[0]);
for (int i = 0; i < nTrk; i++) {
Track track = trackArray2[i];
- ZvFitStatus swimStatus = swimmer.swimTo(track, vR0);
+// ZvFitStatus swimStatus = swimmer.swimTo(track, vR0);
- if (! swimStatus.success()) {
- System.out.println("SwimStatus is " + swimStatus);
- status = ZvFitStatus.SWIM_FAILURE;
- return null;
- }
+// if (! swimStatus.success()) {
+// System.out.println("SwimStatus is " + swimStatus);
+// status = ZvFitStatus.SWIM_FAILURE;
+// return null;
+// }
vertex.setTrackChi2(track, trkChi2[i]);
}
@@ -454,31 +423,36 @@
return vertex;
}
-
- /*
- * --------------------------------------------------------------------
- * private members
- * --------------------------------------------------------------------
+ // TODO proper constructor;
+ public void setDetector(Detector d) {
+ detector = d;
+ }
+ /**
+ * Set the minimum swim distance. <br> -- otherwise no swimming for the
+ * track necessary <br> -- default: 0.1
*/
+ public void setDistMin(double value) {
+ if (value <= 0.)
+ value = 0;
+ this.swimDistMin = value;
+ }
+ /**
+ * Set the maximum number of tries for outer loop. <br> -- default: 3
+ */
+ public void setMaxTry(int value) {
+ if (value <= 0)
+ value = 0;
+ this.nMaxTry = value;
+ }
- // members internal to doFit and related methods
- // initial position and error
- private SpacePoint vInVtxPos = null;
- private Matrix vInVtxErr = null;
-
- // try this vertex vector
- private SpacePoint vVtxTry = null;
- // the vertex position vector worked on
- private SpacePoint vVtxPos = null;
-
- // default steering parameters for vertex fitting
- private int nMaxTry = 3;
- private int nMaxTryInner = 2;
- private double swimDistMin = 0.1;
- private double vtxResMax = 0.001;
-
- // trackList output option
- private boolean takeNewTrackList = false;
+ /**
+ * Set the maximum number of tries for inner loop. <br> -- default: 2
+ */
+ public void setMaxTryInner(int value) {
+ if (value <= 0)
+ value = 0;
+ this.nMaxTryInner = value;
+ }
// tracks
//private List<ZvTrack> orgTrackList = null;
@@ -487,13 +461,36 @@
// resulting vertex
// private ZvVertex fittedVertex = null;
- // initial guess position
- private SpacePoint _initVtxPos;
+ /**
+ * Set the Swimmer to be used. <br>
+ * default: ZvSwimmer (with it's default settings)
+ */
+ public void setSwimmer(HelixSwimmer value) {
+ this.swimmer = value;
+ }
- private Detector detector;
+ /**
+ * Set the maximal vertex resolution. <br> -- vertex has converged, if two
+ * subsequent fits are within this distance of each other <br> -- default:
+ * 0.001
+ */
+ public void setVtxResMax(double value) {
+ if (value <= 0.)
+ value = 0;
+ this.vtxResMax = value;
+ }
- // status
- private ZvFitStatus status = ZvFitStatus.NO_TRACKS;
- // TODO constructor
- private ZvSwimmer swimmer = new ZvSwimmer(0);
+ /**
+ * Get a handle to the swimmer used.
+ */
+ public HelixSwimmer swimmer() {
+ return swimmer;
+ }
+ /**
+ * Choose whether to record unswum (old) or swum (new) track parameters with
+ * the fitted vertex' track list.
+ */
+ public void takeNewTrackList(boolean choice) {
+ this.takeNewTrackList = choice;
+ }
}
lcsim/src/org/lcsim/recon/vertexing/zvtop4
diff -N HepPoint.java
--- HepPoint.java 22 Aug 2005 16:09:29 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-package org.lcsim.recon.vertexing.zvtop4;
-
-import static java.lang.Math.sqrt;
-
-/**
- * Representation of a Point in 3D space.
- * @author jstrube
- * @version
- */
-
-public class HepPoint {
- enum Representation {Cartesian, Cylindrical, Spherical}
- Representation representation;
- private double[] coords;
- private HepPoint() {
- }
-
- private double Cartesian2SphericalR() {
- return sqrt(coords[0]*coords[0] + coords[1]*coords[1] + coords[2]*coords[2]);
- }
-
- private double Cartesian2SphericalPhi() {
- return 0;
- }
-
- private double Cartesian2SphericalTheta() {
- return 0;
- }
-
- private double Cartesian2CylindricalPhi() {
- return Cartesian2SphericalPhi();
- }
-
- private double Cartesian2CylindricalR() {
- return 0;
- }
-
- private double Cylindrical2SphericalR() {
- return 0;
- }
-
- private double Cylindrical2SphericalTheta() {
- return 0;
- }
-
- private double Cylindrical2CartesianX() {
- return 0;
- }
-
- private double Cylindrical2CartesianY() {
- return 0;
- }
-
- private double Spherical2CylindricalR() {
- return 0;
- }
-
- private double Spherical2CartesianZ() {
- return 0;
- }
-
- private double Spherical2CartesianX() {
- return 0;
- }
-
- private double Spherical2CartesianY() {
- return 0;
- }
-
- private double Spherical2CylindricalZ() {
- return Spherical2CartesianZ();
- }
-
- public double getX(){
- switch(representation) {
- case Cartesian: return coords[0];
- case Cylindrical: return Cylindrical2CartesianX();
- case Spherical: return Spherical2CartesianX();
- default: return Double.NaN;
- }
- }
-
-}
CVSspam 0.2.8