Commit in lcsim/src/org/lcsim/fit/helicaltrack on MAIN
HelicalTrackFitter.java+47-11.1 -> 1.2
HelicalTrackFit.java+34-11.1 -> 1.2
+81-2
2 modified files
Fleshing out functionality.

lcsim/src/org/lcsim/fit/helicaltrack
HelicalTrackFitter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HelicalTrackFitter.java	28 Mar 2006 07:19:50 -0000	1.1
+++ HelicalTrackFitter.java	28 Mar 2006 20:16:12 -0000	1.2
@@ -3,7 +3,7 @@
  *
  * Created on March 25, 2006, 6:11 PM
  *
- * $Id: HelicalTrackFitter.java,v 1.1 2006/03/28 07:19:50 ngraf Exp $
+ * $Id: HelicalTrackFitter.java,v 1.2 2006/03/28 20:16:12 ngraf Exp $
  */
 
 package org.lcsim.fit.helicaltrack;
@@ -14,6 +14,7 @@
 import static java.lang.Math.sin;
 import org.lcsim.fit.circle.CircleFit;
 import org.lcsim.fit.circle.CircleFitter;
+import org.lcsim.fit.line.SlopeInterceptLineFit;
 import org.lcsim.fit.line.SlopeInterceptLineFitter;
 /**
  *
@@ -24,6 +25,8 @@
     private CircleFitter _cfitter = new CircleFitter();
     private SlopeInterceptLineFitter _lfitter = new SlopeInterceptLineFitter();
     
+    private HelicalTrackFit _fit;
+    
     /** Creates a new instance of HelicalTrackFitter */
     public HelicalTrackFitter()
     {
@@ -48,6 +51,8 @@
         double yc = (radius-dca)*cos(phi0);
         // fit a line in the s-z plane
         // assumes points are in increasing order
+        //TODO check whether hit has z information
+        // TODO double-check path length calculation
         double[] s = new double[np];
         double[] wz = new double[np];
         for(int i=0; i<np; ++i)
@@ -58,6 +63,7 @@
         
         success = _lfitter.fit(s, z, dz, np);
         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...
@@ -77,9 +83,49 @@
         // 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];
+        int[] ndf = new int[2];
+        
+        chisq[0] = cfit.chisq();
+        chisq[1] = lfit.chisquared();
+        
+        ndf[1] = lfit.ndf();
+        // TODO fix this so CircleFit returns ndf
+        ndf[0] = lfit.ndf();
+        
+        // d0, xy impact parameter.
+        pars[0] = cfit.dca();
+        // phi0
+        pars[1] =  cfit.phi();
+        // omega signed curvature
+        // TODO calculate charge.
+        pars[2] = cfit.curvature();
+        
+        // z0
+        pars[3] = lfit.intercept();
+        // tan lambda
+        pars[4] = lfit.slope();
+        
+        // TODO fill in covariance matrix
+//        for(int i=0; i<5; ++i)
+//        {
+//            System.out.println("pars["+i+"]= "+pars[i]);
+//        }
+        _fit = new HelicalTrackFit(pars, cov, chisq, ndf);
+        
         return true;
     }
     
+    public HelicalTrackFit getFit()
+    {
+        return _fit;
+    }
+    
     double s(double radius, double xcenter, double ycenter, double x1, double y1, double x2, double y2)
     {
         double phi1 = atan2( (y1-ycenter), (x1-xcenter) );

lcsim/src/org/lcsim/fit/helicaltrack
HelicalTrackFit.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HelicalTrackFit.java	28 Mar 2006 07:19:50 -0000	1.1
+++ HelicalTrackFit.java	28 Mar 2006 20:16:12 -0000	1.2
@@ -3,7 +3,7 @@
  *
  * Created on March 25, 2006, 6:11 PM
  *
- * $Id: HelicalTrackFit.java,v 1.1 2006/03/28 07:19:50 ngraf Exp $
+ * $Id: HelicalTrackFit.java,v 1.2 2006/03/28 20:16:12 ngraf Exp $
  */
 
 package org.lcsim.fit.helicaltrack;
@@ -30,4 +30,37 @@
         _ndf = ndf;
     }
     
+    public double[] parameters()
+    {
+        return _parameters;
+    }
+    //TODO add Matrix
+    public double[][] covariance()
+    {
+        return _covmatrix;
+    }
+    
+    public double[] chisq()
+    {
+        return _chisq;
+    }
+    
+    public int[] ndf()
+    {
+        return _ndf;
+    }
+    
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer("HelicalTrackFit: \n");
+        
+        sb.append("d0= "+_parameters[0]+"\n");
+        sb.append("phi0= "+_parameters[1]+"\n");
+        sb.append("curvature: "+_parameters[2]+"\n");
+        sb.append("z0= "+_parameters[3]+"\n");
+        sb.append("tanLambda= "+_parameters[4]+"\n");
+        
+        return sb.toString();
+    }
+    
 }
CVSspam 0.2.8