23 modified files
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- AbstractIntersection.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ AbstractIntersection.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -8,7 +8,7 @@
* interface to minimize the effort required to implement this interface.
*
* @author D. Onoprienko
- * @version $Id: AbstractIntersection.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: AbstractIntersection.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
abstract public class AbstractIntersection implements Intersection {
@@ -42,8 +42,8 @@
// -- Trajectory parameters at the next intersection point : ------------------
- public Hep3Vector getPoint() {
- return _trajectory.getPoint(getPathLength());
+ public Hep3Vector getPosition() {
+ return _trajectory.getPosition(getPathLength());
}
public Hep3Vector getDirection() {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- AbstractSurface.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ AbstractSurface.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -5,12 +5,12 @@
* interface to minimize the effort required to implement this interface.
*
* @author D. Onoprienko
- * @version $Id: AbstractSurface.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: AbstractSurface.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
abstract public class AbstractSurface implements Surface {
/**
- * Default implementation provided by this class throws <tt>UnsupportedOperationException</tt>
+ * Implementation provided by this class throws <tt>UnsupportedOperationException</tt>
* with a diagnostic message. Concrete subclasses must override to return intersection
* of the specified trajectory with this surface.
*/
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- AbstractTrajectory.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ AbstractTrajectory.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -12,7 +12,7 @@
* provided by this class throws <tt>UnsupportedOperationException</tt>.
*
* @author D. Onoprienko
- * @version $Id: AbstractTrajectory.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: AbstractTrajectory.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
abstract public class AbstractTrajectory implements Trajectory {
@@ -20,11 +20,11 @@
/**
* Returns the position of the origin of the trajectory.
- * Implemented by forwarding the call to {@link #getPoint(double)} with zero argument.
+ * Implemented by forwarding the call to {@link #getPosition(double)} with zero argument.
* Concrete subclasses can override.
*/
- public Hep3Vector getPoint() {
- return getPoint(0.);
+ public Hep3Vector getPosition() {
+ return getPosition(0.);
}
/**
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- BField.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ BField.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -1,7 +1,6 @@
package org.lcsim.contrib.onoprien.util.swim;
import hep.physics.vec.Hep3Vector;
-import org.lcsim.geometry.Detector;
import org.lcsim.contrib.onoprien.util.ConstHep3Vector;
import org.lcsim.contrib.onoprien.util.job.JobEvent;
@@ -13,21 +12,19 @@
* geometrical trajectory parameters into particle momentum.
*
* @author D. Onoprienko
- * @version $Id: BField.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: BField.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class BField implements JobEventListener {
// -- Constructors and initialization : ---------------------------------------
private BField() {
- JobManager jMan = JobManager.defaultInstance();
- jMan.addListener(this);
+ JobManager.defaultInstance().addListener(this);
}
/** Initialization - called by the framework. */
public void detectorChanged(JobEvent jobEvent) {
- Detector det = jobEvent.getDetector();
- _bField = det.getFieldMap().getField(ConstHep3Vector.V000).z();
+ _bField = jobEvent.getDetector().getFieldMap().getField(ConstHep3Vector.V000).z();
}
/** Returns default instance of <tt>BField</tt>. */
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Helix.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Helix.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -1,7 +1,5 @@
package org.lcsim.contrib.onoprien.util.swim;
-import java.util.*;
-
import hep.physics.matrix.SymmetricMatrix;
import hep.physics.vec.Hep3Vector;
@@ -11,187 +9,237 @@
* Helical {@link Trajectory} with its axis parallel to Z.
*
* @author D. Onoprienko
- * @version $Id: Helix.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Helix.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class Helix extends AbstractTrajectory {
- /**
- * Emumeration of helix parameters in C-representation.
- */
+ /** Emumeration of helix parameters in C-representation. */
public enum CRep {
- /** D0 (signed impact parameter in XY plane). */
+
+ /**
+ * D0 (signed impact parameter in XY plane).<br>
+ * D0 = - (X0-Xr)*sin(PHI0) + (Y0-Yr)*cos(PHI0)
+ */
D0,
- /** Phi0. */
+
+ /**
+ * Azimuthal angle of the trajectory direction at the point of closest approach
+ * in XY plane to the reference point.
+ */
PHI0,
- /** Omega (signed curvature). */
- OMEGA,
- /** Z0. */
+
+ /**
+ * Signed curvature. Positive if rotation in XY plane is clock-wise as viewed from positive Z.
+ * If magnetic field is along positive Z direction, positively charged particles
+ * will leave tracks with positive curvature.
+ */
+ C,
+
+ /** Z of the point of closest approach in XY plane to the reference point. */
Z0,
- /** Tangent of the dip angle. */
+
+ /** Tangent of the dip angle (dZ/sqrt(dX**2+dY**2)). */
LAMBDA
}
- /**
- * Emumeration of helix parameters in W-representation.
- */
- public enum WRep {
+ /** Emumeration of helix parameters in V-representation. */
+ public enum VRep {
+
/** X of the helix origin. */
X,
/** Y of the helix origin. */
Y,
/** Z of the helix origin. */
Z,
+
/** X component of the unit vector in the direction of the helix at its origin. */
DX,
/** Y component of the unit vector in the direction of the helix at its origin. */
DY,
/** Z component of the unit vector in the direction of the helix at its origin. */
DZ,
- /** Amplitude of the transverse component of the unit vector in the direction of
- * the helix at its origin, devided by the helix radius. */
- RO
+
+ /**
+ * Signed curvature. Positive if rotation in XY plane is clock-wise as viewed from positive Z.
+ * If magnetic field is along positive Z direction, positively charged particles
+ * will leave tracks with positive curvature.
+ */
+ C
}
// -- Constructors : ----------------------------------------------------------
-
+
+ /**
+ * Construct a Helix given origin, direction, and signed curvature.
+ * Reference point is not set.
+ */
public Helix(Hep3Vector origin, Hep3Vector direction, double curvature) {
-
if (origin instanceof ConstHep3Vector) {
_orig = (ConstHep3Vector) origin;
} else {
_orig = new ConstHep3Vector(origin);
}
-
double mag = direction.magnitude();
_dir = new ConstHep3Vector(direction.x()/mag, direction.y()/mag, direction.z()/mag);
-
- _ro = - curvature * Math.hypot(_dir.x(), _dir.y());
+ _c = - curvature;
+
+ _ro = Math.hypot(_dir.x(), _dir.y()) * _c;
}
-
+
+ /**
+ * Construct a helix from parameter vector in C-representation and reference point.
+ * The origin is set to the point of closest approach in XY plane.
+ */
public Helix(ParVector<CRep> parameters, Hep3Vector referencePoint) {
_ref = new ConstHep3Vector(referencePoint);
- _parC = new ParVector<CRep>(parameters);
- repCtoW();
+ _d0 = parameters.get(CRep.D0);
+ _phi0 = parameters.get(CRep.PHI0);
+ _c = parameters.get(CRep.C);
+ _z0 = parameters.get(CRep.Z0);
+ _tan = parameters.get(CRep.LAMBDA);
+ repCtoV();
}
- public Helix(ParVector<WRep> parameters) {
- _orig = new ConstHep3Vector(parameters.get(WRep.X), parameters.get(WRep.Y), parameters.get(WRep.Z));
- _dir = new ConstHep3Vector(parameters.get(WRep.DX), parameters.get(WRep.DY), parameters.get(WRep.DZ));
- _ro = parameters.get(WRep.RO);
+ /**
+ * Construct a helix from parameter vector in V-representation.
+ * Reference point is not set.
+ */
+ public Helix(ParVector<VRep> parameters) {
+ _orig = new ConstHep3Vector(parameters.get(VRep.X), parameters.get(VRep.Y), parameters.get(VRep.Z));
+ _dir = new ConstHep3Vector(parameters.get(VRep.DX), parameters.get(VRep.DY), parameters.get(VRep.DZ));
+ _c = parameters.get(VRep.C);
+ _ro = Math.hypot(_dir.x(), _dir.y()) * _c;
}
- /** Copy constructor. */
+ /**
+ * Copy constructor.
+ */
public Helix(Helix helix) {
+
_orig = helix._orig;
_dir = helix._dir;
- _ro = helix._ro;
+ _c = helix._c;
+
_ref = helix._ref;
+ _d0 = helix._d0;
+ _phi0 = helix._phi0;
+ _z0 = helix._z0;
+ _tan = helix._tan;
+
+ _ro = helix._ro;
}
// -- Get helix parameters : --------------------------------------------------
/**
* Returns helix parameters in the requested representation.
+ * An attempt to ask for parameters in C-representation before setting reference point
+ * results in <tt>IllegalArgumentException</tt>.
*
* @param representation Enum class that defines helix parameters representation.
- * Currently either {@link CRep} or {@link WRep}.
+ * Currently either {@link CRep} or {@link VRep}.
*/
public <T extends Enum<T>> ParVector<T> getParameters(Class<T> representation) {
if (CRep.class.isAssignableFrom(representation)) {
- if (_parC == null) repWtoC();
- return (ParVector) _parC;
- } else if (WRep.class.isAssignableFrom(representation)) {
- return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z(),_dir.x(),_dir.y(),_dir.z(),_ro);
+ if (_ref == null) throw new IllegalArgumentException(ERR1);
+ return new ParVector<T>(representation, _d0, _phi0, _c, _z0, _tan);
+ } else if (VRep.class.isAssignableFrom(representation)) {
+ return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z(),_dir.x(),_dir.y(),_dir.z(),_c);
} else {
throw new IllegalArgumentException();
}
}
-
+
/**
* Returns covariance matrix for helix parameters in the requested representation.
*
* @param representation Enum class that defines helix parameters representation.
- * Currently either {@link CRep} or {@link WRep}.
+ * Currently either {@link CRep} or {@link VRep}.
*/
public <T extends Enum<T>> ParCovMatrix<T> getCovMatrix(Class<T> representation) {
throw new UnsupportedOperationException("Covariance matrix operations are not yet implemented"); // FIXME
}
-
+
+ /** Returns helix period in Z. */
public double getZPeriod() {
return Math.abs(_dir.z()*TWOPI / _ro);
}
-
+
+ /** Returns helix period in path length. */
public double getLengthPeriod() {
return Math.abs(TWOPI / _ro);
}
+ /** Returns helix radius. */
+ public double getRadius() {
+ return 1./Math.abs(_c);
+ }
+
/**
- * Returns reference point used to calculate helix parameters in C-representation.
+ * Returns reference point used to calculate helix parameters in VRep-representation.
+ * Throws <tt>IllegalStateException</tt> if the reference point has not been set.
*/
public ConstHep3Vector getReferencePoint() {
- return (_ref == null) ? _orig : _ref ;
+ if (_ref == null) throw new IllegalStateException(ERR1) ;
+ return _ref;
}
+
+
+// -- Setting ref point and calculating parameters in C-representation : ------
/**
- * Sets the reference point for C-representation of the helix parameters.
- * Once set by this method, the reference point will not be affected by calls to {@link #swim}.
- * Calling this method with <tt>null</tt> vector resets the reference point to
- * the origin of this trajectory, and allows subsequent calls to {@link #swim} to
- * modify it.
+ * Sets the reference point for VRep-representation of the helix parameters.
*/
public void setReferencePoint(Hep3Vector referencePoint) {
- if (referencePoint == null) {
- _ref = null;
- } else {
- _ref = new ConstHep3Vector(referencePoint);
- }
- _parC = null;
+ _ref = (referencePoint instanceof ConstHep3Vector) ? (ConstHep3Vector)referencePoint : new ConstHep3Vector(referencePoint);
+ Intersection inter = intersect(new PocaXY(referencePoint));
+ if (!inter.hasNext()) inter.stepBack();
+ Hep3Vector pos = inter.getPosition();
+ Hep3Vector d = inter.getDirection();
+ _phi0 = Math.atan2(d.y(), d.x());
+ _d0 = (pos.y()-_ref.y())*Math.cos(_phi0) - (pos.x()-_ref.x())*Math.sin(_phi0);
+ _z0 = pos.z();
+ _tan = _dir.z()/Math.hypot(_dir.x(), _dir.y());
}
// -- Position at the given point : -------------------------------------------
- /**
- * Returns the position of the origin of the trajectory.
- */
- public ConstHep3Vector getPoint() {
+ /** Returns the position of the origin of the trajectory. */
+ public ConstHep3Vector getPosition() {
return _orig;
}
- /**
- * Returns the position at given path length along the trajectory.
- */
- public ConstHep3Vector getPoint(double pathLength) {
+ /** Returns the position at given path length along the trajectory. */
+ public ConstHep3Vector getPosition(double pathLength) {
+ double angle = Math.abs(_ro)*pathLength;
double nx = _dir.x()/_ro;
double ny = _dir.y()/_ro;
- double x, y, z;
+ double x, y;
if (Double.isInfinite(nx) || Double.isInfinite(ny)) {
x = _orig.x() + _dir.x() * pathLength;
y = _orig.y() + _dir.y() * pathLength;
} else {
- double sin = Math.sin(_ro*pathLength);
- double cos1 = 1. - Math.cos(_ro*pathLength);
- x = _orig.x() + nx * sin - ny * cos1;
- y = _orig.y() + ny * sin + nx * cos1;
+ double sin = Math.sin(angle);
+ double cos1 = 1. - Math.cos(angle);
+ x = _orig.x() + ny * cos1 - nx * sin;
+ y = _orig.y() - nx * cos1 - ny * sin;
}
- z = _orig.z() + _dir.z() * pathLength;
+ double z = _orig.z() + _dir.z() * pathLength;
return new ConstHep3Vector(x,y,z);
}
// -- Direction at the given point : ------------------------------------------
- /**
- * Returns the direction unit vector at the origin.
- */
+ /** Returns the direction unit vector at the origin. */
public ConstHep3Vector getDirection() {
return _dir;
}
- /**
- * Returns the direction unit vector at given path length along the trajectory.
- */
+ /** Returns the direction unit vector at given path length along the trajectory. */
public ConstHep3Vector getDirection(double pathLength) {
- double sin = Math.sin(_ro*pathLength);
- double cos = Math.cos(_ro*pathLength);
+ double angle = Math.abs(_ro)*pathLength;
+ double sin = Math.sin(angle);
+ double cos = Math.cos(angle);
double dx = _dir.x() * cos - _dir.y() * sin;
double dy = _dir.y() * cos + _dir.x() * sin;
return new ConstHep3Vector(dx, dy, _dir.z());
@@ -214,36 +262,51 @@
}
public Intersection intersect(Poca poca) {
- Hep3Vector point = poca.getPoint();
- double s = 0; // FIXME
- return new IntersectionSingle(s, this, poca);
+// Hep3Vector point = poca.getPoint();
+// double s = 0; // FIXME
+// return new IntersectionSingle(s, this, poca);
+ throw new UnsupportedOperationException();
}
-
+
+ /**
+ * Returns intersection with <tt>PocaXY</tt>.
+ * Z coordinate of the specified reference point is ignored - might want to change this behavior later.
+ */
public Intersection intersect(PocaXY poca) {
+ double roa = Math.abs(_ro);
Hep3Vector point = poca.getPoint();
- double s = 0; // FIXME
+ double deltaX = _orig.x() - point.x();
+ double deltaY = _orig.y() - point.y();
+ double a1 = 1. - _dir.z()*_dir.z() - roa*(_dir.y()*deltaX-_dir.x()*deltaY);
+ double a2 = _dir.x()*deltaX + _dir.y()*deltaY;
+ double a12 = Math.sqrt(a1*a1 + roa*roa*a2*a2);
+ double cos = a1/a12;
+ double sin = - (roa*a2)/a12;
+ double s = getLength(sin,cos);
return new IntersectionSingle(s, this, poca);
}
-
+
+ /** Returns intersection with <tt>ZPlane</tt>. */
public Intersection intersect(ZPlane zPlane) {
- double s = getLengthToZ(zPlane._z);
+ double s = findLengthToZ(zPlane._z);
return (Double.isInfinite(s)) ? new IntersectionNone(this, zPlane) : new IntersectionSingle(s, this, zPlane) ;
}
-
+
+ /** Returns intersection with <tt>ZDisk</tt>. */
public Intersection intersect(ZDisk zDisk) {
- double s = getLengthToZ(zDisk._z);
+ double s = findLengthToZ(zDisk._z);
if (Double.isInfinite(s)) return new IntersectionNone(this, zDisk);
- Hep3Vector pos = getPoint(s);
+ Hep3Vector pos = getPosition(s);
double x = pos.x();
double y = pos.y();
double r2 = x*x + y*y;
return (r2 > zDisk._rMin2 && r2 < zDisk._rMax2) ? new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
}
- public Intersection intersectZCylinder(ZCylinder zCylinder) { // FIXME
+ public Intersection intersect(ZCylinder zCylinder) { // FIXME
- double ro2 = _ro*_ro;
- double a1 = 1. - _dir.z()*_dir.z() - _ro*(_orig.x()*_dir.y() + _orig.y()*_dir.x());
+ double ro2 = _c*_c;
+ double a1 = 1. - _dir.z()*_dir.z() - _c*(_orig.x()*_dir.y() + _orig.y()*_dir.x());
double a2 = _orig.x()*_dir.x() - _orig.y()*_dir.y();
double deltaR = _orig.x()*_orig.x() + _orig.y()*_orig.y() - zCylinder._r*zCylinder._r;
double a12 = a1*a1 + ro2*a2*a2;
@@ -254,8 +317,8 @@
double cos1 = 1. - (ro2* (2.*a2*a2 - deltaR*a1 + a2*d) ) / (2.*a12);
double cos2 = 1. - (ro2* (2.*a2*a2 - deltaR*a1 - a2*d) ) / (2.*a12);
- double sin1 = (- _ro* (2.*a1*a2 + ro2*deltaR*a2 + a1*d)) / (2.*a12);
- double sin2 = (- _ro* (2.*a1*a2 + ro2*deltaR*a2 - a1*d)) / (2.*a12);
+ double sin1 = (- _c* (2.*a1*a2 + ro2*deltaR*a2 + a1*d)) / (2.*a12);
+ double sin2 = (- _c* (2.*a1*a2 + ro2*deltaR*a2 - a1*d)) / (2.*a12);
double s1 = getLength(sin1, cos1);
double s2 = getLength(sin2, cos2);
@@ -274,32 +337,44 @@
s = new double[]{s1,s2};
}
}
- s1 = getLengthToZ(zCylinder.getMinZ());
- s2 = getLengthToZ(zCylinder.getMaxZ());
+ s1 = findLengthToZ(zCylinder.getMinZ());
+ s2 = findLengthToZ(zCylinder.getMaxZ());
return new IntersectionPeriodicBound(false, s1, s2, s, getLengthPeriod(), this, zCylinder);
}
-
+
+
+// -- Helix-specific intersection methods : -----------------------------------
+
+ /** Returns path length to Z plane specified by the argument. */
+ double findLengthToZ(double z) {
+ return (z - _orig.z()) / _dir.z();
+ }
+
+
// -- Modifying the trajectory : ----------------------------------------------
-
- /**
+
+ /**
* Reverse the direction of the trajectory.
*/
public void reverse() {
- throw new UnsupportedOperationException(); // FIXME
+ _dir = new ConstHep3Vector(-_dir.x(), -_dir.y(), -_dir.z());
+ _c = - _c;
+ _ro = -_ro;
+ if (_ref != null) setReferencePoint(_ref);
}
-
+
/**
* Moves the origin by the specified path length along the trajectory.
- * Returns <tt>null</tt> if an attemt to move the origin by the requested length would place
- * it beyond the boundary of this trajectory.
- * Unless the reference point that defines C-representation of helix parameters has
- * been set explicitly in a constructor or through a call to {@link #setReferencePoint(Hep3Vector)}
- * method, the new origin also becomes the new reference point.
+ * Returns <tt>true</tt>.
*/
public boolean swim(double pathLength) {
- throw new UnsupportedOperationException(); // FIXME
+ ConstHep3Vector orig = getPosition(pathLength);
+ _dir = getDirection(pathLength);
+ _orig = orig;
+ return true;
}
-
+
+
// -- Helper methods : --------------------------------------------------------
double getLength(double sin, double cos) {
@@ -307,39 +382,27 @@
if (sin < 0.) {
ros = - ros;
}
- return ros/_ro;
+ return ros/Math.abs(_ro);
}
- /** Returns path length to Z plane specified by the argument. */
- double getLengthToZ(double z) {
- return (z - _orig.z()) / _dir.z();
- }
-
- private void repWtoC() {
- throw new UnsupportedOperationException(); // FIXME
- }
-
- private void repCtoW() {
+ private void repCtoV() {
throw new UnsupportedOperationException(); // FIXME
}
// -- Private parts : ---------------------------------------------------------
- // W-representation :
-
- ConstHep3Vector _orig;
- ConstHep3Vector _dir;
- double _ro;
- SymmetricMatrix _covW;
-
- // C-representation :
-
- ConstHep3Vector _ref; // Ref.point
- ParVector<CRep> _parC; // D0, Phi0, Omega, Z0, Tan Lambda at XY POCA to ref.point
- SymmetricMatrix _covC;
-
- static private final double TWOPI = 2. * Math.PI;
+ ConstHep3Vector _orig; // trajectory origin
+ ConstHep3Vector _dir; // direction at origin
+ double _c; // signed curvature
+
+ ConstHep3Vector _ref; // Ref.point
+ double _d0, _phi0, _z0, _tan; // parameters in CRep representation
+
+ SymmetricMatrix _covW; // covariance matrix in VRep representation
+ SymmetricMatrix _covC; // covariance matrix in CRep representation
+ double _ro; // sqrt(dx**2+dy**2) * _c
-
+ static private final double TWOPI = 2. * Math.PI;
+ static private final String ERR1 = "Reference point not set";
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Intersection.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Intersection.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -16,7 +16,7 @@
* after the last point. The cursor can be moved by calling <tt>step(int)</tt>,
* <tt>stepForward()</tt>, and <tt>stepBack()</tt> methods. <tt>hasPrevious()</tt> and
* <tt>hasNext()</tt> methods check whether thare is an intersection point upstream and
- * downstream from the cursor. <tt>getPathLength()</tt>, <tt>getPoint()</tt>, and
+ * downstream from the cursor. <tt>getPathLength()</tt>, <tt>getPosition()</tt>, and
* <tt>getDirection()</tt> methods return trajectory parameters at the point downstream
* from the cursor. An attempt to move the cursor beyond the ends of the point list, or to
* obtain trajectory parameters when the cursor is downstream from the last intersection point,
@@ -29,7 +29,7 @@
* from the origin.
*
* @author D. Onoprienko
- * @version $Id: Intersection.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Intersection.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public interface Intersection {
@@ -57,7 +57,7 @@
public double getPathLength();
- public Hep3Vector getPoint();
+ public Hep3Vector getPosition();
public Hep3Vector getDirection();
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionHelixZ.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionHelixZ.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -14,7 +14,7 @@
* a surface parallel to Z axis.
*
* @author D. Onoprienko
- * @version $Id: IntersectionHelixZ.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionHelixZ.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionHelixZ extends IntersectionPeriodicBound {
@@ -94,8 +94,8 @@
}
protected void init(double zMin, double zMax, Helix helix) {
- double sMin = helix.getLengthToZ(zMin);
- double sMax = helix.getLengthToZ(zMax);
+ double sMin = helix.findLengthToZ(zMin);
+ double sMax = helix.findLengthToZ(zMax);
if (sMin > sMax) {
double temp = sMin;
sMin = sMax;
@@ -106,7 +106,7 @@
// -- Trajectory parameters at the next intersection point : ------------------
- public ConstHep3Vector getPoint() {
+ public ConstHep3Vector getPosition() {
if (hasNext()) {
if (_index.iPeriod == 0) {
return _pos[_index.iNext];
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionMultiple.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionMultiple.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -3,12 +3,12 @@
import java.util.*;
/**
- * An implementation of {@link Intersection} interface suitable for use when there is
+ * An implementation of {@link Intersection} interface suitable for situations when there is
* a finite number of intersection points, and their locations along the path length of
* the trajectory need to be explicitly specified to the constructor.
*
* @author D. Onoprienko
- * @version $Id: IntersectionMultiple.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionMultiple.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionMultiple extends AbstractIntersection {
@@ -65,5 +65,4 @@
protected double[] _path;
protected int _next;
-
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionNone.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionNone.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -5,11 +5,11 @@
import hep.physics.vec.Hep3Vector;
/**
- * An implementation of {@link Intersection} interface suitable for use when the trajectory
- * and the surface have no intersection points.
+ * An implementation of {@link Intersection} interface suitable for situations
+ * when the trajectory and the surface have no intersection points.
*
* @author D. Onoprienko
- * @version $Id: IntersectionNone.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionNone.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionNone extends AbstractIntersection {
@@ -43,7 +43,7 @@
public double getPathLength() {throw new NoSuchElementException();}
- public Hep3Vector getPoint() {throw new NoSuchElementException();}
+ public Hep3Vector getPosition() {throw new NoSuchElementException();}
public Hep3Vector getDirection() {throw new NoSuchElementException();}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionPeriodic.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionPeriodic.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -3,11 +3,11 @@
import java.util.*;
/**
- * Specialized implementation of {@link Intersection} interface suitable for use when
+ * Specialized implementation of {@link Intersection} interface suitable for situations when
* locations of intersection points are periodic along the path length of the trajectory.
*
* @author D. Onoprienko
- * @version $Id: IntersectionPeriodic.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionPeriodic.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionPeriodic extends AbstractIntersection {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionPeriodicBound.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionPeriodicBound.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -3,12 +3,12 @@
import java.util.*;
/**
- * Specialized implementation of {@link Intersection} interface suitable for use when
+ * Specialized implementation of {@link Intersection} interface suitable for situations when
* locations of intersection points are periodic along the path length of the trajectory,
* but bounded to certain path length interval.
*
* @author D. Onoprienko
- * @version $Id: IntersectionPeriodicBound.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionPeriodicBound.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionPeriodicBound extends IntersectionPeriodic {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- IntersectionSingle.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ IntersectionSingle.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -3,11 +3,11 @@
import java.util.NoSuchElementException;
/**
- * An implementation of {@link Intersection} interface suitable for use when there
- * is a single intersection point.
+ * An implementation of {@link Intersection} interface suitable for situations
+ * when there is a single intersection point.
*
* @author D. Onoprienko
- * @version $Id: IntersectionSingle.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: IntersectionSingle.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class IntersectionSingle extends AbstractIntersection {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Line.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Line.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -8,14 +8,14 @@
* Straight line {@link Trajectory}.
*
* @author D. Onoprienko
- * @version $Id: Line.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Line.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class Line extends AbstractTrajectory {
/**
* Emumeration of line parameters in W-representation.
*/
- public enum WRep {
+ public enum VRep {
/** X of the line origin. */
X,
/** Y of the line origin. */
@@ -63,13 +63,13 @@
// -- Get line parameters : ---------------------------------------------------
/**
- * Returns helix parameters in the requested representation.
+ * Returns line parameters in the requested representation.
*
* @param representation Enum class that defines helix parameters representation.
- * Currently either {@link CRep} or {@link WRep}.
+ * Currently either {@link CRep} or {@link VRep}.
*/
public <T extends Enum<T>> ParVector<T> getParameters(Class<T> representation) {
- if (WRep.class.isAssignableFrom(representation)) {
+ if (VRep.class.isAssignableFrom(representation)) {
return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z(),_dir.x(),_dir.y(),_dir.z());
} else {
throw new IllegalArgumentException();
@@ -80,7 +80,7 @@
* Returns covariance matrix for helix parameters in the requested representation.
*
* @param representation Enum class that defines helix parameters representation.
- * Currently either {@link CRep} or {@link WRep}.
+ * Currently either {@link CRep} or {@link VRep}.
*/
public <T extends Enum<T>> ParCovMatrix<T> getCovMatrix(Class<T> representation) {
throw new UnsupportedOperationException("Covariance matrix operations are not yet implemented"); // FIXME
@@ -91,14 +91,14 @@
/**
* Returns the position of the origin of the trajectory.
*/
- public Hep3Vector getPoint() {
+ public Hep3Vector getPosition() {
return _orig;
}
/**
* Returns the position at given path length along the trajectory.
*/
- public Hep3Vector getPoint(double pathLength) {
+ public Hep3Vector getPosition(double pathLength) {
return new ConstHep3Vector(_orig.x() + pathLength * _dir.x(),
_orig.y() + pathLength * _dir.y(),
_orig.z() + pathLength * _dir.z());
@@ -176,14 +176,14 @@
public Intersection intersect(ZDisk zDisk) {
double s = (zDisk._z - _orig.z()) / _dir.z();
if (Double.isInfinite(s)) return new IntersectionNone(this, zDisk);
- Hep3Vector pos = getPoint(s);
+ Hep3Vector pos = getPosition(s);
double x = pos.x();
double y = pos.y();
double r2 = x*x + y*y;
return (r2 > zDisk._rMin2 && r2 < zDisk._rMax2) ? new IntersectionSingle(s, this, zDisk) : new IntersectionNone(this, zDisk);
}
- public Intersection intersectZCylinder(ZCylinder zCylinder) {
+ public Intersection intersect(ZCylinder zCylinder) {
double d2 = _dir.x() * _dir.x() + _dir.y() * _dir.y();
if (d2 == 0.) return new IntersectionNone(this, zCylinder);
double b = _orig.x() * _dir.x() + _orig.y() * _dir.y();
@@ -199,7 +199,7 @@
if (Double.isInfinite(s)) {
good[i] = false;
} else {
- double z = getPoint(s).z();
+ double z = getPosition(s).z();
good[i] = z > zCylinder._zMin && z < zCylinder._zMax;
}
}
@@ -218,5 +218,4 @@
private ConstHep3Vector _orig;
private ConstHep3Vector _dir;
-
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- ParCovMatrix.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ ParCovMatrix.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -9,7 +9,7 @@
* described in {@link Helix.CRep} and {@link Helix.WRep} representations).
*
* @author D. Onoprienko
- * @version $Id: ParCovMatrix.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: ParCovMatrix.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class ParCovMatrix<T extends Enum<T>> extends SymmetricMatrix {
@@ -31,21 +31,40 @@
}
// -- Getters : ---------------------------------------------------------------
-
+
+ /**
+ * Returns the diagonal covariance matrix element corresponding to the specified parameter.
+ */
public double get(T parameter) {
return diagonal(parameter.ordinal());
}
-
+
+ /**
+ * Returns the covariance matrix element corresponding to the specified parameters.
+ */
public double get(T parameter1, T parameter2) {
return e(parameter1.ordinal(), parameter2.ordinal());
}
+
+ /**
+ * Returns representation used by this <tt>ParCovMatrix</tt> object.
+ */
+ public Class<T> representation() {
+ return _rep;
+ }
// -- Setters : ---------------------------------------------------------------
-
+
+ /**
+ * Assign value to the diagonal covariance matrix element corresponding to the specified parameter.
+ */
public void set(T parameter, double value) {
setElement(parameter.ordinal(), parameter.ordinal(), value);
}
+ /**
+ * Assign value to the covariance matrix element corresponding to the specified parameters.
+ */
public void set(T parameter1, T parameter2, double value) {
setElement(parameter1.ordinal(), parameter2.ordinal(), value);
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- ParVector.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ ParVector.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -7,7 +7,7 @@
* described in {@link Helix.CRep} and {@link Helix.WRep} representations).
*
* @author D. Onoprienko
- * @version $Id: ParVector.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: ParVector.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class ParVector<T extends Enum<T>> {
@@ -38,12 +38,19 @@
}
/**
- * Returns parameter values as an array.
+ * Returns parameter values as an array (ordered by ordinal of the representation Enum).
* The returned array is owned by this <tt>ParVector</tt> object, any modifications will persist.
*/
public double[] v() {
return _pars;
}
+
+ /**
+ * Returns representation used by this <tt>ParVector</tt> object.
+ */
+ public Class<T> representation() {
+ return _rep;
+ }
// -- Setters : ---------------------------------------------------------------
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Poca.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Poca.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -9,7 +9,7 @@
* its constructor.
*
* @author D. Onoprienko
- * @version $Id: Poca.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Poca.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class Poca extends AbstractSurface {
@@ -32,7 +32,11 @@
}
// -- Getters : ---------------------------------------------------------------
-
+
+ /**
+ * Intersecting this surface with a trajectory returns the position of closest
+ * approach of that trajectory to the point returned by this method.
+ */
public ConstHep3Vector getPoint() {
return _point;
}
@@ -55,5 +59,4 @@
// -- Private parts : ---------------------------------------------------------
private ConstHep3Vector _point;
-
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- PocaXY.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ PocaXY.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -9,7 +9,7 @@
* point supplied to its constructor.
*
* @author D. Onoprienko
- * @version $Id: PocaXY.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: PocaXY.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class PocaXY extends AbstractSurface {
@@ -33,6 +33,10 @@
// -- Getters : ---------------------------------------------------------------
+ /**
+ * Intersecting this surface with a trajectory returns the position of closest
+ * approach in XY plane of that trajectory to the point returned by this method.
+ */
public ConstHep3Vector getPoint() {
return _point;
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Surface.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Surface.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -1,12 +1,10 @@
package org.lcsim.contrib.onoprien.util.swim;
-import hep.physics.vec.Hep3Vector;
-
/**
* A surface in space.
*
* @author D. Onoprienko
- * @version $Id: Surface.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Surface.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public interface Surface {
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- Trajectory.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ Trajectory.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -7,7 +7,7 @@
* Trajectory is characterized by its shape, origin, and direction.
*
* @author D. Onoprienko
- * @version $Id: Trajectory.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: Trajectory.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public interface Trajectory {
@@ -16,13 +16,13 @@
/**
* Returns the position of the origin of the trajectory.
*/
- public Hep3Vector getPoint();
+ public Hep3Vector getPosition();
/**
* Returns the position at given path length along the trajectory.
* Returns <tt>null</tt> if the requested point does not exist on this trajectory.
*/
- public Hep3Vector getPoint(double pathLength);
+ public Hep3Vector getPosition(double pathLength);
/**
* Returns direction unit vector at the origin.
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- ZCylinder.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ ZCylinder.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -7,7 +7,7 @@
* This surface is characterized by radius, low Z bound, and high Z bound.
*
* @author D. Onoprienko
- * @version $Id: ZCylinder.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: ZCylinder.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class ZCylinder extends AbstractSurface {
@@ -39,10 +39,8 @@
* Returns intersection of the specified trajectory with this surface.
*/
public Intersection intersect(Trajectory trajectory) {
- if (trajectory instanceof Line) {
- return ((Line)trajectory).intersect(this);
- } else if (trajectory instanceof Helix) {
- return ((Helix)trajectory).intersect(this);
+ if (trajectory instanceof Line || trajectory instanceof Helix) {
+ return trajectory.intersect(this);
} else {
return super.intersect(trajectory);
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- ZDisk.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ ZDisk.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -1,12 +1,10 @@
package org.lcsim.contrib.onoprien.util.swim;
-import hep.physics.vec.Hep3Vector;
-
/**
* {@link Surface} that represents a disk centered around Z axis and perpendicular to it.
*
* @author D. Onoprienko
- * @version $Id: ZDisk.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: ZDisk.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class ZDisk extends AbstractSurface {
@@ -41,10 +39,8 @@
* Returns intersection of the specified trajectory with this surface.
*/
public Intersection intersect(Trajectory trajectory) {
- if (trajectory instanceof Line) {
- return ((Line)trajectory).intersect(this);
- } else if (trajectory instanceof Helix) {
- return ((Helix)trajectory).intersect(this);
+ if (trajectory instanceof Line || trajectory instanceof Helix) {
+ return trajectory.intersect(this);
} else {
return super.intersect(trajectory);
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- ZPlane.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ ZPlane.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -4,7 +4,7 @@
* {@link Surface} that represents a plane perpendicular to Z axis.
*
* @author D. Onoprienko
- * @version $Id: ZPlane.java,v 1.1.1.1 2008/12/10 22:03:06 jeremy Exp $
+ * @version $Id: ZPlane.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
*/
public class ZPlane extends AbstractSurface {
@@ -27,10 +27,8 @@
* Returns intersection of the specified trajectory with this surface.
*/
public Intersection intersect(Trajectory trajectory) {
- if (trajectory instanceof Line) {
- return ((Line)trajectory).intersect(this);
- } else if (trajectory instanceof Helix) {
- return ((Helix)trajectory).intersect(this);
+ if (trajectory instanceof Line || trajectory instanceof Helix) {
+ return trajectory.intersect(this);
} else {
return super.intersect(trajectory);
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.1.1.1 -r1.2
--- package-info.java 10 Dec 2008 22:03:06 -0000 1.1.1.1
+++ package-info.java 22 Jan 2009 21:01:58 -0000 1.2
@@ -1,6 +1,10 @@
/**
* Classes for representing trajectories and surfaces, finding their
* intersections, and propagating parameters and their covariance matrices along trajectories.
+ * <p>
+ * <i>This package is a work in progress, not all functionality is currently implemented.</i>
+ *
+ * @author D. Onoprienko
*/
package org.lcsim.contrib.onoprien.util.swim;
CVSspam 0.2.8