lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/job
diff -u -r1.6 -r1.7
--- JobManager.java 18 Feb 2009 03:29:09 -0000 1.6
+++ JobManager.java 23 Feb 2009 03:44:19 -0000 1.7
@@ -1,5 +1,6 @@
package org.lcsim.contrib.onoprien.util.job;
+import java.io.PrintStream;
import java.util.*;
import org.lcsim.conditions.ConditionsListener;
@@ -27,7 +28,7 @@
* </ul>
*
* @author D. Onoprienko
- * @version $Id: JobManager.java,v 1.6 2009/02/18 03:29:09 onoprien Exp $
+ * @version $Id: JobManager.java,v 1.7 2009/02/23 03:44:19 onoprien Exp $
*/
public class JobManager extends org.lcsim.util.Driver implements ConditionsListener {
@@ -42,6 +43,14 @@
private AIDA _aida;
+ /**
+ * Standard output stream associated with this JobManager.
+ * Unless explicitly assigned a different value, points to <tt>System.out</tt>.
+ * When a job is run inside Jas3, sending output to <tt>JobManager.defaultInstance().out</tt>
+ * makes it possible to print to Jas3 console from any thread.
+ */
+ public PrintStream out;
+
private int _nEvents;
@@ -54,6 +63,7 @@
_singletons = new HashMap<Class, Object>();
_aida = AIDA.defaultInstance();
+ out = System.out;
getConditionsManager().addConditionsListener(this);
}
@@ -63,6 +73,7 @@
* ConditionsManager, before calling DetectorChanged() methods of any listeners.
*/
private void detectorChanged(JobEvent jobEvent) {
+ out = System.out;
}
lcsim-contrib/src/main/java/org/lcsim/contrib/onoprien/util/swim
diff -u -r1.3 -r1.4
--- Helix.java 29 Jan 2009 20:35:41 -0000 1.3
+++ Helix.java 23 Feb 2009 03:44:19 -0000 1.4
@@ -9,7 +9,7 @@
* Helical {@link Trajectory} with its axis parallel to Z.
*
* @author D. Onoprienko
- * @version $Id: Helix.java,v 1.3 2009/01/29 20:35:41 onoprien Exp $
+ * @version $Id: Helix.java,v 1.4 2009/02/23 03:44:19 onoprien Exp $
*/
public class Helix extends AbstractTrajectory {
@@ -91,7 +91,7 @@
* The origin is set to the point of closest approach in XY plane.
*/
public Helix(ParVector<CRep> parameters, Hep3Vector referencePoint) {
- _ref = new ConstHep3Vector(referencePoint);
+ _ref = (referencePoint instanceof ConstHep3Vector) ? (ConstHep3Vector)referencePoint : new ConstHep3Vector(referencePoint);
_d0 = parameters.get(CRep.D0);
_phi0 = parameters.get(CRep.PHI0);
_c = parameters.get(CRep.C);
@@ -175,6 +175,11 @@
return 1./Math.abs(_c);
}
+ /** Returns X,Y coordinates of the helix axis. Z is set to zero. */
+ public Hep3Vector getCenter() {
+ return new ConstHep3Vector(_orig.x() + _dir.y()/_ro, _orig.y() - _dir.x()/_ro, 0.);
+ }
+
/**
* Returns reference point used to calculate helix parameters in VRep-representation.
* Throws <tt>IllegalStateException</tt> if the reference point has not been set.
@@ -191,15 +196,22 @@
* Sets the reference point for VRep-representation of the helix parameters.
*/
public void setReferencePoint(Hep3Vector referencePoint) {
+// System.out.println("");
+// System.out.println("Setting reference point for "+ this);
+// System.out.println("Ref point "+ referencePoint);
+// System.out.println("Helix: origin "+ _orig +" dir "+ _dir +" curvature "+ _c);
+// System.out.println("Center "+ getCenter().x() +" "+ getCenter().y() +" Radius "+ getRadius());
_ref = (referencePoint instanceof ConstHep3Vector) ? (ConstHep3Vector)referencePoint : new ConstHep3Vector(referencePoint);
Intersection inter = intersect(new PocaXY(referencePoint));
if (!inter.hasNext()) inter.stepBack();
Hep3Vector pos = inter.getPosition();
+// System.out.println("POCA for "+ _ro +" : "+ pos);
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());
+// System.out.println("Phi0 "+ _phi0 +" d0 "+ _d0 +" _z0 "+ _z0 +" tanLambda "+ _tan);
}
// -- Position at the given point : -------------------------------------------
@@ -211,7 +223,7 @@
/** Returns the position at given path length along the trajectory. */
public ConstHep3Vector getPosition(double pathLength) {
- double angle = Math.abs(_ro)*pathLength;
+ double angle = _ro*pathLength;
double nx = _dir.x()/_ro;
double ny = _dir.y()/_ro;
double x, y;
@@ -221,8 +233,8 @@
} else {
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;
+ x = _orig.x() + nx * sin + ny * cos1;
+ y = _orig.y() + ny * sin - nx * cos1;
}
double z = _orig.z() + _dir.z() * pathLength;
return new ConstHep3Vector(x,y,z);
@@ -237,11 +249,11 @@
/** Returns the direction unit vector at given path length along the trajectory. */
public ConstHep3Vector getDirection(double pathLength) {
- double angle = Math.abs(_ro)*pathLength;
+ double angle = _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;
+ double dx = _dir.x() * cos + _dir.y() * sin;
+ double dy = _dir.y() * cos - _dir.x() * sin;
return new ConstHep3Vector(dx, dy, _dir.z());
}
@@ -273,16 +285,26 @@
* 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);
+// System.out.println("");
+// System.out.println("Finding intersection");
Hep3Vector point = poca.getPoint();
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 a1 = 1. - _dir.z()*_dir.z() - _ro*(_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 a12 = Math.sqrt(a1*a1 + _ro*_ro*a2*a2);
+ //double d2 = _dir.x()*_dir.x() + _dir.y() + _dir.y();
+ //double a12 = Math.sqrt(_ro*_ro*d2*(deltaX*deltaX+deltaY*deltaY)+2.*_ro*d2*(_dir.y()*deltaX-_dir.x()*deltaY)+d2*d2);
double cos = a1/a12;
- double sin = - (roa*a2)/a12;
+ double sin = - (_ro*a2)/a12;
double s = getLength(sin,cos);
+
+ double nx = _dir.x()/_ro;
+ double ny = _dir.y()/_ro;
+ double x = _orig.x() + nx * sin + ny * (1-cos);
+ double y = _orig.y() + ny * sin - nx * (1-cos);
+// System.out.println("Found "+ x +" "+ y);
+// System.out.println("Found s = "+ s +" to point "+ getPosition(s));
return new IntersectionSingle(s, this, poca);
}
@@ -382,7 +404,7 @@
if (sin < 0.) {
ros = - ros;
}
- return ros/Math.abs(_ro);
+ return ros/_ro;
}
private void repCtoV() {
@@ -401,7 +423,7 @@
SymmetricMatrix _covW; // covariance matrix in VRep representation
SymmetricMatrix _covC; // covariance matrix in CRep representation
- double _ro; // sqrt(dx**2+dy**2) * _c
+ 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";