Print

Print


Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util on MAIN
swim/Point.java+145added 1.1
    /Intersection.java+34-61.2 -> 1.3
    /Line.java+6-41.7 -> 1.8
vector/BasicHep3Vector.java+70-81.1 -> 1.2
      /ConstHep3Vector.java+74-121.1 -> 1.2
      /AbstractHep3Vector.java-901.1 removed
+329-120
1 added + 1 removed + 4 modified, total 6 files
Move all heprep converters to a separate package
Add new types of cuts to IDefinition
Miscellaneous enhancements to ITC algorithm

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
Point.java added at 1.1
diff -N Point.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Point.java	10 Jun 2009 17:53:52 -0000	1.1
@@ -0,0 +1,145 @@
+package org.lcsim.contrib.onoprien.util.swim;
+
+import hep.physics.vec.Hep3Vector;
+
+import org.lcsim.contrib.onoprien.util.vector.ConstHep3Vector;
+
+/**
+ * Special {@link Trajectory} that describes a point in space. Trying to swim this trajectory,
+ * intersect it with any surface, or ask for direction, will result in
+ * <tt>UnsupportedOperationException</tt>. The only allowed operations are asking for the
+ * origin position and associated covariance matrix. Parameters of this kind of trajectory
+ * can be retrieved in {@link Line.VRep} or {@link Helix.VRep} representation (in addition
+ * to {Point.VRep}) - irrelevant parameters will be set to <tt>NaN</tt>.
+ *
+ * @author D. Onoprienko
+ * @version $Id: Point.java,v 1.1 2009/06/10 17:53:52 onoprien Exp $
+ */
+public class Point extends AbstractTrajectory {
+  
+  /** 
+   * Emumeration of line parameters in W-representation.
+   */
+  public enum VRep {
+    /** X of the point. */
+    X,
+    /** Y of the point. */
+    Y,
+    /** Z of the point. */
+    Z
+  }
+
+
+// -- Private parts :  ---------------------------------------------------------
+
+  private ConstHep3Vector _orig;
+
+  static private String _ERR_NS = "Cannot swim Point";
+  static private String _ERR_ND = "Point does not have direction";
+  static private String _ERR_NI = "Cannot intersect Point with any surface";
+
+
+// -- Constructors :  ----------------------------------------------------------
+  
+  /**
+   * Construct from origin.
+   */
+  public Point(Hep3Vector origin) {
+    _orig = (origin instanceof ConstHep3Vector) ? (ConstHep3Vector) origin : new ConstHep3Vector(origin);
+  }
+  
+  /**
+   * Copy constructor.
+   */
+  public Point(Point point) {
+    _orig = point._orig;
+  }
+
+
+// -- Get point parameters :  ---------------------------------------------------
+  
+  /** 
+   * Returns this <tt>Line</tt> parameters in the requested representation.
+   *
+   * @param representation  Enum class that specifies Point parameters representation.
+   *                        Currently either {@link Point.VRep} or {@link Line.VRep} or {@link Helix.VRep}.
+   */
+  public <T extends Enum<T>> ParVector<T> getParameters(Class<T> representation) {
+    if (VRep.class.isAssignableFrom(representation)) {
+      return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z());
+    } else if (Line.VRep.class.isAssignableFrom(representation)) {
+      return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z(),Double.NaN,Double.NaN,Double.NaN);
+    } else if (Helix.VRep.class.isAssignableFrom(representation)) {
+      return new ParVector<T>(representation, 0., _orig.x(),_orig.y(),_orig.z(),Double.NaN,Double.NaN,Double.NaN);
+    } else {
+      throw new IllegalArgumentException();
+    }
+  }
+  
+  /** 
+   * Returns covariance matrix for helix parameters in the requested representation.
+   *
+   * @param representation  Enum class that defines Point parameters representation.
+   *                        Currently either {@link Point.VRep} or {@link Line.VRep} or {@link Helix.VRep}.
+   */
+  public <T extends Enum<T>> ParCovMatrix<T> getCovMatrix(Class<T> representation) {
+    throw new UnsupportedOperationException("Covariance matrix operations are not yet implemented");  // FIXME
+  }
+  
+// -- Position at the given point :  -------------------------------------------
+  
+  /**
+   * Returns the position of the origin of the trajectory.
+   */
+  public Hep3Vector getPosition() {
+    return _orig;
+  }
+
+  /**
+   * Throws <tt>UnsupportedOperationException</tt>.
+   */
+  public Hep3Vector getPosition(double pathLength) {
+    throw new UnsupportedOperationException(_ERR_NS);
+  }
+  
+// -- Direction at the given point :  ------------------------------------------
+  
+  /**
+   * Throws <tt>UnsupportedOperationException</tt>.
+   */
+  public Hep3Vector getDirection() {
+    throw new UnsupportedOperationException(_ERR_ND);
+  }
+  
+  /**
+   * Throws <tt>UnsupportedOperationException</tt>.
+   */
+  public Hep3Vector getDirection(double pathLength) {
+    throw new UnsupportedOperationException(_ERR_ND);
+  }
+  
+// -- Modifying the trajectory :  ----------------------------------------------
+  
+  /** 
+   * Reverse the direction of the trajectory (does nothing since <tt>Point</tt> has no direction).
+   */
+  public void reverse() {
+  }
+  
+  /**
+   * Throws <tt>UnsupportedOperationException</tt>.
+   */
+  public boolean swim(double pathLength) {
+    throw new UnsupportedOperationException(_ERR_NS);
+  }
+  
+// -- Intersections :  ---------------------------------------------------------
+  
+  /**
+   * Throws <tt>UnsupportedOperationException</tt>.
+   */
+  public Intersection intersect(Surface surface) {
+    throw new UnsupportedOperationException(_ERR_NI);
+  }
+
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
Intersection.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- Intersection.java	22 Jan 2009 21:01:58 -0000	1.2
+++ Intersection.java	10 Jun 2009 17:53:52 -0000	1.3
@@ -29,7 +29,7 @@
  * from the origin.
  *
  * @author D. Onoprienko
- * @version $Id: Intersection.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: Intersection.java,v 1.3 2009/06/10 17:53:52 onoprien Exp $
  */
 public interface Intersection {
   
@@ -42,23 +42,51 @@
   public int size();
   
 // -- Stepping through intersection points :  ----------------------------------
-  
+
+  /**
+   * Moves cursor the specified number of intersection points. Positive number of steps
+   * moves cursor forward, negative number of steps moves cursor backwards. Throws
+   * <tt>NoSuchElementException</tt> if there are not enough intersection points in the
+   * chosen direction.
+   */
   public void step(int steps);
-  
+
+  /**
+   * Moves cursor one intersection point forward.
+   * Throws <tt>NoSuchElementException</tt> if there is no next intersection point.
+   */
   public void stepForward();
-  
+
+  /**
+   * Moves cursor one intersection point back.
+   * Throws <tt>NoSuchElementException</tt> if there is no previous intersection point.
+   */
   public void stepBack();
-  
+
+  /** Returns <tt>true</tt> if there is an intersection point in forward direction from the cursor. */
   public boolean hasNext();
   
+  /** Returns <tt>true</tt> if there is an intersection point in backward direction from the cursor. */
   public boolean hasPrevious();
   
 // -- Trajectory parameters at the next intersection point :  ------------------
-  
+
+  /**
+   * Returns path length along the trajectory to the next intersection point in forward direction from the cursor.
+   * Throws <tt>NoSuchElementException</tt> if there is no next intersection point.
+   */
   public double getPathLength();
   
+  /**
+   * Returns position of the next intersection point in forward direction from the cursor.
+   * Throws <tt>NoSuchElementException</tt> if there is no next intersection point.
+   */
   public Hep3Vector getPosition();
   
+  /**
+   * Returns position of the next intersection point in backward direction from the cursor.
+   * Throws <tt>NoSuchElementException</tt> if there is no next intersection point.
+   */
   public Hep3Vector getDirection();
   
 // -- Access to intersecting objects :  ----------------------------------------

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
Line.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- Line.java	6 Apr 2009 19:49:30 -0000	1.7
+++ Line.java	10 Jun 2009 17:53:52 -0000	1.8
@@ -8,7 +8,7 @@
  * Straight line {@link Trajectory}.
  *
  * @author D. Onoprienko
- * @version $Id: Line.java,v 1.7 2009/04/06 19:49:30 onoprien Exp $
+ * @version $Id: Line.java,v 1.8 2009/06/10 17:53:52 onoprien Exp $
  */
 public class Line extends AbstractTrajectory {
   
@@ -61,14 +61,16 @@
 // -- Get line parameters :  ---------------------------------------------------
   
   /** 
-   * Returns line parameters in the requested representation.
+   * Returns this <tt>Line</tt> parameters in the requested representation.
    *
-   * @param representation  Enum class that defines helix parameters representation.
-   *                        Currently either {@link CRep} or {@link VRep}.
+   * @param representation  Enum class that specifies Line parameters representation.
+   *                        Currently either {@link Line.VRep} or {@link Helix.VRep}.
    */
   public <T extends Enum<T>> ParVector<T> getParameters(Class<T> representation) {
     if (VRep.class.isAssignableFrom(representation)) {
       return new ParVector<T>(representation, _orig.x(),_orig.y(),_orig.z(),_dir.x(),_dir.y(),_dir.z()); 
+    } else if (Helix.VRep.class.isAssignableFrom(representation)) {
+      return new ParVector<T>(representation, 0., _orig.x(),_orig.y(),_orig.z(),_dir.x(),_dir.y(),_dir.z());
     } else {
       throw new IllegalArgumentException();
     }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/vector
BasicHep3Vector.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- BasicHep3Vector.java	6 Apr 2009 19:49:30 -0000	1.1
+++ BasicHep3Vector.java	10 Jun 2009 17:53:52 -0000	1.2
@@ -10,30 +10,72 @@
  * Coordinates supplied to constructors and setters are interpreted as cartesian.
  *
  * @author D. Onoprienko
- * @version $Id: BasicHep3Vector.java,v 1.1 2009/04/06 19:49:30 onoprien Exp $
+ * @version $Id: BasicHep3Vector.java,v 1.2 2009/06/10 17:53:52 onoprien Exp $
  */
-final public class BasicHep3Vector extends AbstractHep3Vector implements Serializable {
+final public class BasicHep3Vector implements Hep3Vector, Serializable {
+
+// -- Private parts :  ---------------------------------------------------------
+
+  private double _x, _y, _z;
+
 
 // -- Constructors and initialization :  ---------------------------------------
 
   public BasicHep3Vector() {
-    super();
+    _x = 0.;
+    _y = 0.;
+    _z = 0.;
   }
 
   public BasicHep3Vector(double x, double y, double z) {
-    super(x,y,z);
-  }
+    _x = x;
+    _y = y;
+    _z = z;
+   }
 
   public BasicHep3Vector(double[] d) {
-    super(d);
+    _x = d[0];
+    _y = d[1];
+    _z = d[2];
   }
 
   public BasicHep3Vector(float[] f) {
-    super(f);
+    _x = f[0];
+    _y = f[1];
+    _z = f[2];
   }
 
   public BasicHep3Vector(Hep3Vector vector) {
-    super(vector);
+    _x = vector.x();
+    _y = vector.y();
+    _z = vector.z();
+  }
+
+
+// -- Implementing Hep3Vector :  -----------------------------------------------
+
+  public double x() {
+    return _x;
+  }
+
+  public double y() {
+    return _y;
+  }
+
+  public double z() {
+    return _z;
+  }
+
+  public double magnitude() {
+    return Math.sqrt(_x*_x + _y*_y + _z*_z);
+  }
+
+  public double magnitudeSquared() {
+    return _x*_x + _y*_y + _z*_z;
+  }
+
+  public double[] v() {
+    return new double[] { _x, _y, _z };
   }
 
 
@@ -176,4 +218,24 @@
     return this;
   }
 
+
+// -- Overriding Object :  -----------------------------------------------------
+
+  public boolean equals(Object obj) {
+    if (obj instanceof Hep3Vector) {
+      Hep3Vector that = (Hep3Vector) obj;
+      return _x == that.x() && _y == that.y() && _z == that.z();
+    } else {
+      return false;
+    }
+  }
+
+  public String toString() {
+    return "("+ _x +" "+ _y +" "+ _z +")";
+  }
+
+  public int hashCode() {
+    return (int) (Double.doubleToLongBits(_x) + Double.doubleToLongBits(_y) + Double.doubleToLongBits(_z));
+  }
+
 }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/vector
ConstHep3Vector.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ConstHep3Vector.java	6 Apr 2009 19:49:30 -0000	1.1
+++ ConstHep3Vector.java	10 Jun 2009 17:53:52 -0000	1.2
@@ -11,9 +11,9 @@
  * Coordinates supplied to constructors are interpreted as cartesian.
  *
  * @author D. Onoprienko
- * @version $Id: ConstHep3Vector.java,v 1.1 2009/04/06 19:49:30 onoprien Exp $
+ * @version $Id: ConstHep3Vector.java,v 1.2 2009/06/10 17:53:52 onoprien Exp $
  */
-final public class ConstHep3Vector extends AbstractHep3Vector implements Serializable {
+final public class ConstHep3Vector implements Hep3Vector, Serializable {
   
 // -- Constant vectors :  ------------------------------------------------------
   
@@ -30,26 +30,88 @@
   static public final ConstHep3Vector V001 = new ConstHep3Vector(0.,0.,1.);
 
 
+// -- Private parts :  ---------------------------------------------------------
+
+  private final double _x, _y, _z;
+
+
 // -- Constructors :  ----------------------------------------------------------
-  
+
   public ConstHep3Vector() {
-    super();
+    _x = 0.;
+    _y = 0.;
+    _z = 0.;
   }
 
   public ConstHep3Vector(double x, double y, double z) {
-    super(x,y,z);
-  }
-  
+    _x = x;
+    _y = y;
+    _z = z;
+   }
+
   public ConstHep3Vector(double[] d) {
-    super(d);
+    _x = d[0];
+    _y = d[1];
+    _z = d[2];
   }
-  
+
   public ConstHep3Vector(float[] f) {
-    super(f);
+    _x = f[0];
+    _y = f[1];
+    _z = f[2];
   }
-  
+
   public ConstHep3Vector(Hep3Vector vector) {
-    super(vector);
+    _x = vector.x();
+    _y = vector.y();
+    _z = vector.z();
+  }
+
+
+// -- Implementing Hep3Vector :  -----------------------------------------------
+
+  public double x() {
+    return _x;
+  }
+
+  public double y() {
+    return _y;
+  }
+
+  public double z() {
+    return _z;
+  }
+
+  public double magnitude() {
+    return Math.sqrt(_x*_x + _y*_y + _z*_z);
+  }
+
+  public double magnitudeSquared() {
+    return _x*_x + _y*_y + _z*_z;
+  }
+
+  public double[] v() {
+    return new double[] { _x, _y, _z };
+  }
+
+
+// -- Overriding Object :  -----------------------------------------------------
+
+  public boolean equals(Object obj) {
+    if (obj instanceof Hep3Vector) {
+      Hep3Vector that = (Hep3Vector) obj;
+      return _x == that.x() && _y == that.y() && _z == that.z();
+    } else {
+      return false;
+    }
+  }
+
+  public String toString() {
+    return "("+ _x +" "+ _y +" "+ _z +")";
+  }
+
+  public int hashCode() {
+    return (int) (Double.doubleToLongBits(_x) + Double.doubleToLongBits(_y) + Double.doubleToLongBits(_z));
   }
 
 }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/vector
AbstractHep3Vector.java removed after 1.1
diff -N AbstractHep3Vector.java
--- AbstractHep3Vector.java	6 Apr 2009 19:49:30 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,90 +0,0 @@
-package org.lcsim.contrib.onoprien.util.vector;
-
-import hep.physics.vec.Hep3Vector;
-
-/**
- * Abstract class that provides a skeletal implementation of {@link Hep3Vector}.
- *
- * @author D. Onoprienko
- * @version $Id: AbstractHep3Vector.java,v 1.1 2009/04/06 19:49:30 onoprien Exp $
- */
-abstract public class AbstractHep3Vector implements Hep3Vector {
-
-// -- Private parts :  ---------------------------------------------------------
-
-  double _x, _y, _z;
-
-
-// -- Constructors and initialization :  ---------------------------------------
-
-  public AbstractHep3Vector() {
-    _x = 0.;
-    _y = 0.;
-    _z = 0.;
-  }
-
-  public AbstractHep3Vector(double x, double y, double z) {
-    _x = x;
-    _y = y;
-    _z = z;
-   }
-
-  public AbstractHep3Vector(double[] d) {
-    _x = d[0];
-    _y = d[1];
-    _z = d[2];
-  }
-
-  public AbstractHep3Vector(float[] f) {
-    _x = f[0];
-    _y = f[1];
-    _z = f[2];
-  }
-
-  public AbstractHep3Vector(Hep3Vector vector) {
-    _x = vector.x();
-    _y = vector.y();
-    _z = vector.z();
-  }
-
-// -- Implementing Hep3Vector :  -----------------------------------------------
-
-  public double x() {
-    return _x;
-  }
-  public double y() {
-    return _y;
-  }
-  public double z() {
-    return _z;
-  }
-  public double magnitude() {
-    return Math.sqrt(_x*_x + _y*_y + _z*_z);
-  }
-  public double magnitudeSquared() {
-    return _x*_x + _y*_y + _z*_z;
-  }
-  public double[] v() {
-    return new double[] { _x, _y, _z };
-  }
-
-// -- Overriding Object :  -----------------------------------------------------
-
-  public boolean equals(Object obj) {
-    if (obj instanceof Hep3Vector) {
-      Hep3Vector that = (Hep3Vector) obj;
-      return _x == that.x() && _y == that.y() && _z == that.z();
-    } else {
-      return false;
-    }
-  }
-
-  public String toString() {
-    return "("+ _x +" "+ _y +" "+ _z +")";
-  }
-
-  public int hashCode() {
-    return (int) (Double.doubleToLongBits(_x) + Double.doubleToLongBits(_y) + Double.doubleToLongBits(_z));
-  }
-
-}
CVSspam 0.2.8