lcsim/src/org/lcsim/contrib/seedtracker
diff -u -r1.2 -r1.3
--- HelicalTrackFitter.java 29 Aug 2006 20:44:26 -0000 1.2
+++ HelicalTrackFitter.java 30 Aug 2006 01:06:54 -0000 1.3
@@ -3,7 +3,7 @@
*
* Created on March 25, 2006, 6:11 PM
*
- * $Id: HelicalTrackFitter.java,v 1.2 2006/08/29 20:44:26 partridge Exp $
+ * $Id: HelicalTrackFitter.java,v 1.3 2006/08/30 01:06:54 partridge Exp $
*/
package org.lcsim.contrib.seedtracker;
@@ -18,7 +18,16 @@
import org.lcsim.fit.line.SlopeInterceptLineFit;
import org.lcsim.fit.line.SlopeInterceptLineFitter;
/**
- *
+ * Fit a helix to a set of space points. First, a circle is fit to the x-y coordinates.
+ * A straight-line fit is then performed on the s-z coordinates.
+ *
+ * The r-phi and z coordinate measurements are assumed to be uncorrelated. A block
+ * diagonal covariance matrix is formed from the results of the circle and s-z fits,
+ * ignoring any correlations between these fits.
+ *
+ * The resulting track parameters follow the "L3 Convention" adopted by org.lcsim.
+ *
+ * Modified August 2006 by Richard Partridge
* @author Norman Graf
*/
public class HelicalTrackFitter
@@ -30,11 +39,26 @@
private double[] _circleParameters = new double[3];
- /** Creates a new instance of HelicalTrackFitter */
+ /**
+ * Creates a new instance of HelicalTrackFitter.
+ */
public HelicalTrackFitter()
{
}
+ /**
+ * Fit a helix to a set of space points. The space points should be ordered in
+ * increasing track length. The code will properly handle loopers provided
+ * that the change in direction between successive points is less than pi.
+ * @param x Array of x coordinates
+ * @param y Array of y coordinates
+ * @param z Array of z coordinates
+ * @param drphi Error in r-phi hit position
+ * @param dz Error in z coordinate. A negative value indicates that this point is to
+ * be excluded in the s-z fit.
+ * @param np Number of points
+ * @return True for successful fit
+ */
public boolean fit(double[] x, double[] y, double[] z, double[] drphi, double[] dz, int np)
{
// fit a circle in the x-y plane
@@ -82,27 +106,6 @@
if(!success) return false;
SlopeInterceptLineFit lfit = _lfitter.getFit();
- // TODO convert fit results to track parameters and covariance matrix.
- // now have the fits, need to assemble the track parameters...
-
- // see org.lcsim.event.Track.Parameters
- // The track parameters for LCD are defined as follows
- // <table>
- // <tr><th>Index</th><th>Meaning</th></tr>
- // <tr><td> 0 </td><td> d0 = XY impact parameter </td><tr>
- // <tr><td> 1 </td><td> phi0 </td><tr> </td><tr>
- // <tr><td> 2 </td><td> omega = 1/curv.radius (negative for negative tracks) </td><tr>
- // <tr><td> 3 </td><td> z0 = z of track origin (z impact parameter) </td><tr>
- // <tr><td> 4 </td><td> s = tan lambda </td><tr>
- // </table>
-
- // tanlambda = line fit slope
- // z0 = line fit intercept
- //TODO should shift s-z line fit to centroid of x-y fit and introduce covariance terms to be correct.
-
-
-// System.out.println("circle fit: "+cfit);
-// System.out.println("line fit: "+lfit);;
double[] pars = new double[5];
double[][] cov = new double[5][5];
double[] chisq = new double[2];
@@ -114,7 +117,7 @@
ndf[1] = lfit.ndf();
ndf[0] = np - 3;
- // d0, xy impact parameter.
+ // d0, xy impact parameter. Note: - sign due to opposite sign convention in CircleFitter
pars[0] = -cfit.dca();
// phi0
pars[1] = cfit.phi();
@@ -127,9 +130,9 @@
// fill in covariance matrix
cov[0][0] = cfit.cov()[0];
- cov[0][1] = -cfit.cov()[1];
+ cov[0][1] = -cfit.cov()[1]; // Need - sign due to sign convention in CircleFitter
cov[1][1] = cfit.cov()[2];
- cov[0][2] = -cfit.cov()[3];
+ cov[0][2] = -cfit.cov()[3]; // Need - sign due to sign convention in CircleFitter
cov[1][2] = cfit.cov()[4];
cov[2][2] = cfit.cov()[5];
cov[0][3] = 0.;
@@ -146,20 +149,24 @@
cov[j][i] = cov[i][j];
}
}
-// for(int i=0; i<5; ++i)
-// {
-// System.out.println("pars["+i+"]= "+pars[i]);
-// }
_fit = new HelicalTrackFit(pars, cov, chisq, ndf);
_fit.setCircleParameters(_circleParameters);
return true;
}
+ /**
+ * Get the results of the most recent fit.
+ * @return HelicalTrackFit corresponding to most recent fit
+ */
public HelicalTrackFit getFit()
{
return _fit;
}
+ /**
+ * Get the circle paramaters (xc, yc, R) from the most recent fit.
+ * @return Circle parameters (xc, yc, R)
+ */
public double[] getCircleParameters()
{
return _circleParameters;
@@ -168,9 +175,7 @@
double s(double radius, double xcenter, double ycenter, double x1, double y1, double x2, double y2)
{
double phi1 = atan2( (y1-ycenter), (x1-xcenter) );
- if (phi1<0) phi1 += 2*PI;
double phi2 = atan2( (y2-ycenter), (x2-xcenter) );
- if (phi2<0) phi2 += 2*PI;
double dphi = abs(phi1-phi2);
if(dphi>PI) dphi = 2.*PI-dphi;
return abs(radius)*dphi;