hps-java/src/main/java/org/lcsim/hps/users/phansson
diff -u -r1.1 -r1.2
--- WTrackUtils.java 9 Oct 2012 01:20:02 -0000 1.1
+++ WTrackUtils.java 23 Oct 2012 01:30:02 -0000 1.2
@@ -15,7 +15,7 @@
* @author phansson
*/
public class WTrackUtils {
- boolean _debug = false;
+ private boolean _debug = false;
List<Double> _delta_point = new ArrayList<Double>();
public WTrackUtils() {
@@ -28,6 +28,10 @@
public void setDebug(boolean debug) {
_debug = debug;
}
+
+ public boolean getDebug() {
+ return _debug;
+ }
public List<Double> getDeltas() {
return _delta_point;
@@ -59,31 +63,31 @@
* Find the approximate path length to the point xp
* in arbitrary oriented, constant magnetic field with unit vector h
*/
- if(_debug) {
- System.out.println(this.getClass().getSimpleName() + ": getPathLengthToPlaneApprox ");
- System.out.println(this.getClass().getSimpleName() + ": " + track.toString());
- System.out.println(this.getClass().getSimpleName() + ": xp " + xp.toString());
- System.out.println(this.getClass().getSimpleName() + ": eta " + eta.toString());
- System.out.println(this.getClass().getSimpleName() + ": h " + h.toString());
- }
double a = track.getBfieldConstant();
Hep3Vector p0 = track.getP0();
Hep3Vector x0 = track.getX0();
double p = p0.magnitude();
- double rho = a / p0.magnitude();
+ double rho = a / p;
double A = VecOp.dot(eta,VecOp.cross(p0, h))/p*0.5*rho;
double B = VecOp.dot(p0,eta)/p;
double C = VecOp.dot(VecOp.sub(x0,xp),eta);
- double root1 = (-B + Math.sqrt(B*B-4*A*C)) /(2*A);
- double root2 = (-B - Math.sqrt(B*B-4*A*C)) /(2*A);
- double root = -99999999;
- if(_debug) {
+ double t = B*B-4*A*C;
+ if(t<0) {
+ System.out.println(this.getClass().getSimpleName() + ": getPathLengthToPlaneApprox ERROR t is undefined " + t );
System.out.println(this.getClass().getSimpleName() + ": p " + p + " rho " + rho + " A " + A + " B " + B + " C " + C);
- }
+ System.out.println(this.getClass().getSimpleName() + ": track params\n" + track.toString());
+ System.out.println(this.getClass().getSimpleName() + ": xp " + xp.toString());
+ System.out.println(this.getClass().getSimpleName() + ": eta " + eta.toString());
+ System.out.println(this.getClass().getSimpleName() + ": h " + h.toString());
+ System.exit(1);
+ }
+ double root1 = (-B + Math.sqrt(t)) /(2*A);
+ double root2 = (-B - Math.sqrt(t)) /(2*A);
+
// choose the smallest positive solution
// if both negative choose the smallest negative ???
//if(root1==0 || root2==0) root=0;
- root = Math.abs(root1) <= Math.abs(root2) ? root1 : root2;
+ double root = Math.abs(root1) <= Math.abs(root2) ? root1 : root2;
// else if(Math.signum(root1)>0 && Math.signum(root2)<0) root = root1;
// else if(Math.signum(root2)>0 && Math.signum(root1)<0) root = root2;
// else if(Math.signum(root1)>0 && Math.signum(root2)>0) root = root1 > root2 ? root2 : root1;
@@ -93,6 +97,12 @@
// System.exit(1);
// }
if(_debug) {
+ System.out.println(this.getClass().getSimpleName() + ": getPathLengthToPlaneApprox ");
+ System.out.println(this.getClass().getSimpleName() + ": " + track.toString());
+ System.out.println(this.getClass().getSimpleName() + ": xp " + xp.toString());
+ System.out.println(this.getClass().getSimpleName() + ": eta " + eta.toString());
+ System.out.println(this.getClass().getSimpleName() + ": h " + h.toString());
+ System.out.println(this.getClass().getSimpleName() + ": p " + p + " rho " + rho + " t " + t + " A " + A + " B " + B + " C " + C);
System.out.println(this.getClass().getSimpleName() + ": root1 " + root1 + " root2 " + root2 + " -> root " + root);
}
return root;
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.7 -r1.8
--- TrackUtils.java 18 Oct 2012 14:45:03 -0000 1.7
+++ TrackUtils.java 23 Oct 2012 01:30:02 -0000 1.8
@@ -17,27 +17,23 @@
//--- org.lcsim ---//
import org.lcsim.event.Track;
-import org.lcsim.event.TrackState;
import org.lcsim.fit.helicaltrack.*;
import org.lcsim.hps.users.phansson.WTrack;
import org.lcsim.hps.users.phansson.WTrackUtils;
-import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
-import org.lcsim.recon.tracking.seedtracker.SeedTrack;
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: TrackUtils.java,v 1.7 2012/10/18 14:45:03 phansson Exp $
+ * @version $Id: TrackUtils.java,v 1.8 2012/10/23 01:30:02 phansson Exp $
* TODO: Switch to JLab coordinates
*/
public class TrackUtils {
- boolean _debug = false;
- boolean isTrackSet = false;
- double[] trackParameters;
- WTrackUtils _wutils = new WTrackUtils();
- Hep3Vector _bfield_vec = new BasicHep3Vector(0,0,1);
+ private boolean _debug = false;
+ private boolean isTrackSet = false;
+ private double[] trackParameters;
+ private WTrackUtils _wutils = new WTrackUtils();
/**
@@ -47,13 +43,12 @@
isTrackSet = false;
}
- /**
+ /**
*
*/
- public void setTrack(Track track){
- trackParameters = new double[9];
- this.setTrackParameters(track);
- isTrackSet = true;
+ public void setDebug(boolean debug){
+ this._debug = debug;
+ _wutils.setDebug(debug);
}
/**
@@ -205,6 +200,25 @@
trackParameters[8] = -(this.getR() - this.getDoca())*Math.cos(this.getPhi0()); // yc
if(_debug) this.printTrackParameters();
}
+
+ /**
+ *
+ */
+ public void setTrack(Track track){
+ trackParameters = new double[9];
+ // All track parameters are in LCSim coordinates system
+ trackParameters[0] = track.getTrackParameter(0); // DOCA
+ trackParameters[1] = track.getTrackParameter(1); // phi0
+ trackParameters[2] = 1/track.getTrackParameter(2); // R
+ trackParameters[3] = -this.getDoca()*Math.sin(this.getPhi0()); // x0
+ trackParameters[4] = this.getDoca()*Math.cos(this.getPhi0()); // y0
+ trackParameters[5] = track.getTrackParameter(3); // z0
+ trackParameters[6] = track.getTrackParameter(4); // tan(Lambda)
+ trackParameters[7] = (this.getR() - this.getDoca())*Math.sin(this.getPhi0()); // xc
+ trackParameters[8] = -(this.getR() - this.getDoca())*Math.cos(this.getPhi0()); // yc
+ if(_debug) this.printTrackParameters();
+ isTrackSet = true;
+ }
/**
*
@@ -248,12 +262,19 @@
return new BasicHep3Vector(x, y, z);
}
-
public Hep3Vector calculateIterativeHelixInterceptXPlane(HelicalTrackFit helfit, HelicalTrackStrip strip, double bfield) {
- WTrack wtrack = new WTrack(helfit,bfield);
+ return this.calculateIterativeHelixInterceptXPlane(helfit, strip, bfield,false);
+ }
+
+ public Hep3Vector calculateIterativeHelixInterceptXPlane(HelicalTrackFit helfit, HelicalTrackStrip strip, double bfield, boolean debug) {
+ WTrack wtrack = new WTrack(helfit,bfield,true); // B-field sign is flipped so flip!
Hep3Vector point_on_plane = strip.origin();
Hep3Vector unit_vec_normal_to_plane = VecOp.cross(strip.u(),strip.v());//strip.w();
- Hep3Vector intercept_point = _wutils.getHelixAndPlaneIntercept(wtrack, point_on_plane, unit_vec_normal_to_plane, _bfield_vec);
+ if(debug) System.out.printf("%s: find intercept between plane defined by point on plane %s, unit vec %s, bfield %.3f, and track pars:\n%s \n",this.getClass().getSimpleName(),point_on_plane.toString(),unit_vec_normal_to_plane.toString(), bfield,helfit.toString());
+ boolean d = _wutils.getDebug();
+ if(debug) _wutils.setDebug(debug);
+ Hep3Vector intercept_point = _wutils.getHelixAndPlaneIntercept(wtrack, point_on_plane, unit_vec_normal_to_plane, new BasicHep3Vector(0,0,1));
+ _wutils.setDebug(d); //turn off if needed
return intercept_point;
}