Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util on MAIN
swim/IntersectionCombo.java+167added 1.1
    /AbstractIntersection.java+4-31.2 -> 1.3
    /BField.java+26-51.2 -> 1.3
constants/Units.java+68added 1.1
         /package-info.java+7added 1.1
+272-8
3 added + 2 modified, total 5 files
Switching back to my own measurement units class

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
IntersectionCombo.java added at 1.1
diff -N IntersectionCombo.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ IntersectionCombo.java	27 Jan 2009 20:48:53 -0000	1.1
@@ -0,0 +1,167 @@
+package org.lcsim.contrib.onoprien.util.swim;
+
+import java.util.NoSuchElementException;
+
+import hep.physics.vec.Hep3Vector;
+
+/**
+ * An implementation of {@link Intersection} interface suitable for situations when the
+ * intersection is a union of several intersections. Typically used for describing
+ * intersection of a trajectory with several surfaces.
+ *
+ * @author D. Onoprienko
+ * @version $Id: IntersectionCombo.java,v 1.1 2009/01/27 20:48:53 onoprien Exp $
+ */
+public class IntersectionCombo implements Intersection {
+
+// -- Constructors :  ----------------------------------------------------------
+
+  public IntersectionCombo(Intersection... intersections) {
+    if (intersections.length == 0) throw new IllegalArgumentException();
+    _int = intersections;
+    double sNext = Double.MAX_VALUE;
+    double sPrev = - Double.MAX_VALUE;
+    for (Intersection inter : _int) {
+      if (inter.hasNext()) {
+        double s = inter.getPathLength();
+        if (s < sNext) {
+          s = sNext;
+          _next = inter;
+        }
+      }
+      if (inter.hasPrevious()) {
+        inter.stepBack();
+        double s = inter.getPathLength();
+        inter.stepForward();
+        if (s > sPrev) {
+          s = sPrev;
+          _prev = inter;
+        }
+      }
+    }
+  }
+
+// -- Number of intersection points :  -----------------------------------------
+
+  /**
+   * Returns the number of intersection points.
+   * If the number is infinite, returns <tt>-1</tt>.
+   */
+  public int size() {
+    int size = 0;
+    for (Intersection inter : _int) {
+      int s = inter.size();
+      if (s == -1) {
+        return -1;
+      } else {
+        size += s;
+      }
+    }
+    return size;
+  }
+  
+// -- Stepping through intersection points :  ----------------------------------
+
+  public void step(int steps) {
+    while (steps != 0) {
+      if (steps > 0) {
+        stepForward();
+        steps--;
+      } else {
+        stepBack();
+        steps++;
+      }
+    }
+  }
+
+  public void stepForward() {
+    if (hasNext()) {
+      _next.stepForward();
+      _prev = _next;
+      _next = null;
+      double sNext = Double.MAX_VALUE;
+      for (Intersection inter : _int) {
+        if (inter.hasNext()) {
+          double s = inter.getPathLength();
+          if (s < sNext) {
+            s = sNext;
+            _next = inter;
+          }
+        }
+      }
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  public void stepBack() {
+    if (hasPrevious()) {
+      _prev.stepBack();
+      _next = _prev;
+      _prev = null;
+      double sPrev = - Double.MAX_VALUE;
+      for (Intersection inter : _int) {
+        if (inter.hasPrevious()) {
+          inter.stepBack();
+          double s = inter.getPathLength();
+          inter.stepForward();
+          if (s > sPrev) {
+            s = sPrev;
+            _prev = inter;
+          }
+        }
+      }
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  public boolean hasNext() {
+    return _next != null && _next.hasNext();
+  }
+
+  public boolean hasPrevious() {
+    return _prev != null && _prev.hasPrevious();
+  }
+
+
+// -- Trajectory parameters at the next intersection point :  ------------------
+
+  public double getPathLength() {
+    if (_next == null) throw new NoSuchElementException();
+    return _next.getPathLength();
+  }
+
+  public Hep3Vector getPosition() {
+    if (_next == null) throw new NoSuchElementException();
+    return _next.getPosition();
+  }
+
+  public Hep3Vector getDirection() {
+    if (_next == null) throw new NoSuchElementException();
+    return _next.getDirection();
+  }
+
+
+// -- Access to intersecting objects :  ----------------------------------------
+
+  /**
+   * Returns the trajectory this intersection belongs to.
+   */
+  public Trajectory getTrajectory() {
+    return _int[0].getTrajectory();
+  }
+
+  /**
+   * Returns the surface associated with the next intersection point. If there is
+   * no next point, returns <tt>null</tt>.
+   */
+  public Surface getSurface() {
+    return (hasNext()) ? _next.getSurface() : null ;
+  }
+
+// -- Private parts :  ---------------------------------------------------------
+
+  Intersection[] _int;
+  Intersection _next, _prev;
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
AbstractIntersection.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- AbstractIntersection.java	22 Jan 2009 21:01:58 -0000	1.2
+++ AbstractIntersection.java	27 Jan 2009 20:48:53 -0000	1.3
@@ -1,14 +1,15 @@
 package org.lcsim.contrib.onoprien.util.swim;
 
 import hep.physics.vec.Hep3Vector;
-import org.lcsim.units.clhep.SystemOfUnits;
+
+import org.lcsim.contrib.onoprien.util.constants.Units;
 
 /**
  * Abstract class that provides a skeletal implementation of the {@link Intersection}
  * interface to minimize the effort required to implement this interface.
  *
  * @author D. Onoprienko
- * @version $Id: AbstractIntersection.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: AbstractIntersection.java,v 1.3 2009/01/27 20:48:53 onoprien Exp $
  */
 abstract public class AbstractIntersection implements Intersection {
   
@@ -18,7 +19,7 @@
    * <b>This behavior is currently disabled.</b></i>
    * Default value: 0.1 micrometer.
    */
-  public static double pathLengthTolerance = .1 * SystemOfUnits.micrometer;
+  public static double pathLengthTolerance = .1 * Units.micrometer;
   
 // -- Constructors :  ----------------------------------------------------------
   

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
BField.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- BField.java	22 Jan 2009 21:01:58 -0000	1.2
+++ BField.java	27 Jan 2009 20:48:53 -0000	1.3
@@ -3,6 +3,7 @@
 import hep.physics.vec.Hep3Vector;
 
 import org.lcsim.contrib.onoprien.util.ConstHep3Vector;
+import org.lcsim.contrib.onoprien.util.constants.Units;
 import org.lcsim.contrib.onoprien.util.job.JobEvent;
 import org.lcsim.contrib.onoprien.util.job.JobEventListener;
 import org.lcsim.contrib.onoprien.util.job.JobManager;
@@ -12,7 +13,7 @@
  * geometrical trajectory parameters into particle momentum.
  *
  * @author D. Onoprienko
- * @version $Id: BField.java,v 1.2 2009/01/22 21:01:58 onoprien Exp $
+ * @version $Id: BField.java,v 1.3 2009/01/27 20:48:53 onoprien Exp $
  */
 public class BField implements JobEventListener {
   
@@ -25,6 +26,7 @@
   /** Initialization - called by the framework. */
   public void detectorChanged(JobEvent jobEvent) {
     _bField = jobEvent.getDetector().getFieldMap().getField(ConstHep3Vector.V000).z();
+    _c2p = 0.299792458 * (_bField * Units.Tesla);
   }
   
   /** Returns default instance of <tt>BField</tt>. */
@@ -34,12 +36,30 @@
   
 // -- Conversion :  ------------------------------------------------------------
   
-  public double getMomentum(Helix helix) {
-    throw new UnsupportedOperationException();  // FIXME
+  /**
+   * Returns momentum of a particle with the specified trajectory.
+   * Unit charge is assumed.
+   */
+  public double getP(Helix helix) {
+    return Math.abs(_c2p/helix._ro);
   }
-  
+
+  /**
+   * Returns transverse momentum of a particle with the specified trajectory.
+   * Unit charge is assumed.
+   */
+  public double getPt(Helix helix) {
+    return Math.abs(_c2p/helix._c);
+  }
+
+  /**
+   * Returns new <tt>Helix</tt> describing the trajectory of a particle with specified parameters.
+   * The origin of the created <tt>Helix</tt> is set to the specified position.
+   */
   public Helix makeHelix(Hep3Vector position, Hep3Vector momentum, int charge) {
-    throw new UnsupportedOperationException();  // FIXME
+    double pT = Math.hypot(momentum.x(), momentum.y());
+    double curvature = (_c2p/pT)*charge*Math.signum(_bField);
+    return new Helix(position, momentum, curvature);
   }
   
 // -- Private parts :  ---------------------------------------------------------
@@ -47,4 +67,5 @@
   static private BField _def;
   
   private double _bField;
+  private double _c2p;
 }

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/constants
Units.java added at 1.1
diff -N Units.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Units.java	27 Jan 2009 20:48:53 -0000	1.1
@@ -0,0 +1,68 @@
+package org.lcsim.contrib.onoprien.util.constants;
+
+/**
+ * Measurement units.
+ * Constants defined by this class can be used for convertion between values in <tt>org.lcsim</tt>
+ * internal representation and various physical units.
+ *
+ * @author D. Onoprienko
+ * @version $Id: Units.java,v 1.1 2009/01/27 20:48:53 onoprien Exp $
+ */
+public class Units {
+
+// -- Length :  ----------------------------------------------------------------
+
+  public static final double millimeter = 1.;
+
+  public static final double nanometer = 1.e-6 * millimeter;
+  public static final double micrometer = 1.e-3 * millimeter;
+  public static final double centimeter = 10. * millimeter;
+  public static final double meter = 1.e3 * millimeter;
+  public static final double kilometer = 1.e6 * millimeter;
+
+	public static final double nm  = nanometer;
+	public static final double um  = micrometer;
+  public static final double mm = millimeter;
+  public static final double cm = centimeter;
+  public static final double m = meter;
+  public static final double km = kilometer;
+
+// -- Time :  ------------------------------------------------------------------
+
+  public static final double second = 1.;
+
+  public static final double nanosecond = 1.e-9 * second;
+  public static final double microsecond = 1.e-6 * second;
+  public static final double millisecond = 1.e-3 * second;
+
+  public static final double ns = nanosecond;
+  public static final double us = microsecond;
+  public static final double ms = millisecond;
+  public static final double s = second;
+
+// -- Magnetic field :  --------------------------------------------------------
+
+  public static final double Tesla = 1.;
+
+// -- Energy :  ----------------------------------------------------------------
+
+  public static final double GeV = 1.;
+
+  public static final double eV = 1.e-9 * GeV;
+  public static final double keV = 1.e-6 * GeV;
+  public static final double MeV = 1.e-3 * GeV;
+  public static final double TeV = 1.e3 * GeV;
+
+// -- Angle :  -----------------------------------------------------------------
+
+  public static final double radian = 1.;
+
+  public static final double microradian = 1.e-6 * radian;
+  public static final double milliradian = 1.e-3 * radian;
+  public static final double degree = Math.PI / 180.;
+
+  public static final double urad = microradian;
+  public static final double mrad = milliradian;
+  public static final double rad = radian;
+  public static final double deg = degree;
+}

lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/constants
package-info.java added at 1.1
diff -N package-info.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ package-info.java	27 Jan 2009 20:48:53 -0000	1.1
@@ -0,0 +1,7 @@
+/**
+ * Classes that define commonly used constants: measurement units, particle types, physical constants, etc.
+ *
+ * @author D. Onoprienko
+ */
+package org.lcsim.contrib.onoprien.util.constants;
+
CVSspam 0.2.8