Commit in lcsim/sandbox/Partridge on MAIN
HelicalTrack2DHit.java+62added 1.1
HelicalTrack3DHit.java+39added 1.1
HelicalTrackFit.java+108added 1.1
+209
3 added files


lcsim/sandbox/Partridge
HelicalTrack2DHit.java added at 1.1
diff -N HelicalTrack2DHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HelicalTrack2DHit.java	21 Nov 2007 16:24:27 -0000	1.1
@@ -0,0 +1,62 @@
+/*
+ * HelicalTrack2DHit.java
+ *
+ * Created on November 13, 2007, 1:10 PM
+ *
+ */
+
+package org.lcsim.fit.helicaltrack;
+
+import org.lcsim.event.TrackerHit;
+import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
+
+/**
+ * Encapsulate 2D hit info needed by HelicalTrackFit
+ * @author Richard Partridge
+ * @version 1.0
+ */
+public class HelicalTrack2DHit extends HelicalTrackHit {
+    private double _zmin;
+    private double _zmax;
+    
+    /**
+     * Creates a new instance of HelicalTrack2DHit from a SpacePoint
+     * @param pos Position of the hit
+     * @param wrphi Weight of this hit in the circle fit (generally, 1/sigma_xy^2)
+     * @param dz Uncertainty in z coordinate
+     */
+    public HelicalTrack2DHit(TrackerHit hit, BarrelEndcapFlag beflag, double zmin, double zmax) {
+        super(hit, beflag);
+        _zmin = zmin;
+        _zmax = zmax;
+    }
+    
+    /**
+     * Creates a new instance of HelicalTrack2DHit from a TrackerHit
+     * @param hit TrackerHit to be used
+     */
+    public HelicalTrack2DHit(TrackerHit hit) {
+        super(hit, BarrelEndcapFlag.BARREL);
+        double z = this.z();
+        double[] cov = hit.getCovMatrix();
+        _zmin = z - Math.sqrt(cov[5]);
+        _zmax = z + Math.sqrt(cov[5]);
+    }
+    
+    
+    /**
+     * Return the minimum z coordinate
+     * @return minimum z coordinate
+     */
+    public double zmin() {
+        return _zmin;
+    }
+    
+    /**
+     * Return the maximum z coordinate
+     * @return maximum z coordinate
+     */
+    public double zmax() {
+        return _zmax;
+    }
+}
\ No newline at end of file

lcsim/sandbox/Partridge
HelicalTrack3DHit.java added at 1.1
diff -N HelicalTrack3DHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HelicalTrack3DHit.java	21 Nov 2007 16:24:27 -0000	1.1
@@ -0,0 +1,39 @@
+/*
+ * HelicalTrack3DHit.java
+ *
+ * Created on November 13, 2007, 12:39 PM
+ *
+ */
+
+package org.lcsim.fit.helicaltrack;
+
+import org.lcsim.event.TrackerHit;
+import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
+
+/**
+ * Encapsulate 3D hit info needed by HelicalTrackFit
+ * @author Richard Partridge
+ * @version 1.0
+ */
+public class HelicalTrack3DHit extends HelicalTrackHit {
+    private double _dz;
+    
+    /**
+     * Creates a new instance of HelicalTrack3DHit from a SpacePoint
+     * @param pos Position of the hit
+     * @param wrphi Weight of this hit in the circle fit (generally, 1/sigma_xy^2)
+     * @param dz Uncertainty in z coordinate
+     */
+    public HelicalTrack3DHit(TrackerHit hit, BarrelEndcapFlag beflag) {
+        super(hit, beflag);
+        _dz = hit.getCovMatrix()[5];
+    }
+    
+    /**
+     * Return the uncertainty in the z coordinate
+     * @return uncertainty in the z coordinate
+     */
+    public double dz() {
+        return _dz;
+    }
+}
\ No newline at end of file

lcsim/sandbox/Partridge
HelicalTrackFit.java added at 1.1
diff -N HelicalTrackFit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HelicalTrackFit.java	21 Nov 2007 16:24:27 -0000	1.1
@@ -0,0 +1,108 @@
+/*
+ * HelicalTrackFit.java
+ *
+ * Created on March 25, 2006, 6:11 PM
+ *
+ * $Id: HelicalTrackFit.java,v 1.1 2007/11/21 16:24:27 partridge Exp $
+ */
+
+package org.lcsim.fit.helicaltrack;
+
+import hep.physics.matrix.SymmetricMatrix;
+
+import org.lcsim.fit.circle.CircleFit;
+import org.lcsim.fit.line.SlopeInterceptLineFit;
+import org.lcsim.fit.zsegment.ZSegmentFit;
+
+/**
+ * Represents the result of a fit to a helical track.
+ * @author Norman Graf
+ */
+public class HelicalTrackFit {
+    // fit independently to a circle in x-y and a line in s-z
+    // first is circle, second is line
+    private double[] _chisq = new double[2];
+    private int[] _ndf = new int[2];
+    private double[] _parameters;
+    private SymmetricMatrix _covmatrix;
+    
+    /** Creates a new instance of HelicalTrackFit */
+    public HelicalTrackFit(double[] pars, SymmetricMatrix cov, double[] chisq, int[] ndf) {
+        _parameters = pars;
+        _covmatrix = cov;
+        _chisq = chisq;
+        _ndf = ndf;
+    }
+    
+    public HelicalTrackFit(CircleFit cfit, int cdof, SlopeInterceptLineFit lfit) {
+        _covmatrix = new SymmetricMatrix(5);
+        circle(cfit, cdof);
+        line(lfit);
+    }
+    
+    public double[] parameters() {
+        return _parameters;
+    }
+    public SymmetricMatrix 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();
+    }
+    
+    private void circle(CircleFit cfit, int cdof) {
+        _chisq[0] = cfit.chisq();
+        _ndf[0] = cdof;
+        _parameters[0] = -cfit.dca();
+        _parameters[1] = cfit.phi();
+        _parameters[2] = cfit.curvature();
+        double[] cov = cfit.cov();
+        _covmatrix.setElement(0, 0, cov[0]);
+        _covmatrix.setElement(0, 1, cov[1]);
+        _covmatrix.setElement(1, 1, cov[2]);
+        _covmatrix.setElement(0, 2, cov[3]);
+        _covmatrix.setElement(1, 2, cov[4]);
+        _covmatrix.setElement(2, 2, cov[5]);
+    }
+    
+    private void line(SlopeInterceptLineFit lfit) {
+        _chisq[1] = lfit.chisquared();
+        _ndf[1] = lfit.ndf();
+        _parameters[3] = lfit.intercept();
+        _parameters[4] = lfit.slope();
+        _covmatrix.setElement(3, 3, Math.pow(lfit.interceptUncertainty(),2));
+        _covmatrix.setElement(3, 4, lfit.covariance());
+        _covmatrix.setElement(4, 4, Math.pow(lfit.slopeUncertainty(),2));
+    }
+    
+    private void segment(ZSegmentFit zfit, double chisq, int ndof) {
+        _chisq[1] = chisq;
+        _ndf[1] = ndof;
+        double[] cent = zfit.getCentroid();
+        _parameters[3] = cent[0];
+        _parameters[4] = cent[1];
+        SymmetricMatrix cov = zfit.getCovariance();
+        _covmatrix.setElement(3, 3, cov.e(0, 0));
+        _covmatrix.setElement(3, 4, cov.e(0, 1));
+        _covmatrix.setElement(4, 4, cov.e(1, 1));
+    }
+    
+    
+}
CVSspam 0.2.8