1 package org.lcsim.fit.circle; 2 /** 3 * Encapsulates the behavior of a circle fit to data points. 4 * Used in high-energy physics for a fit to hits left by 5 * charged particles originating near (0,0) in a constant 6 * magnetic field. 7 * @author Norman A. Graf 8 * @version 1.0 9 */ 10 public class CircleFit 11 { 12 private double _xref; // x reference position; 13 private double _yref; // y reference position; 14 15 private double _rho; // curvature 16 private double _phi; // phi angle at (_xref, _yref) 17 private double _dca; // distance of closest approach to (_xref, _yref) 18 private double _chisq; // chi-squared of circle fit 19 20 private double[] _covrfd; // covariance matrix of fit 21 // parameters in lower triangular form 22 //Constructor 23 public CircleFit(double x, double y, double rho, double phi, double dca, double chi2, double[] cov) 24 { 25 _xref = x; 26 _yref = y; 27 _rho = rho; 28 _phi = phi; 29 _dca = dca; 30 _chisq = chi2; 31 _covrfd = cov; 32 } 33 34 /** 35 * The phi angle at the point of reference. 36 * @return phi 37 */ 38 public double phi() 39 { 40 return _phi; 41 } 42 43 /** 44 * The curvature of the fit. 45 * @return the fit curvature. 46 */ 47 public double curvature() 48 { 49 return _rho; 50 } 51 52 /** 53 * The x position of the reference point 54 * @return x reference point. 55 */ 56 public double xref() 57 { 58 return _xref; 59 } 60 61 /** 62 * The y position of the reference point. 63 * @return y reference point. 64 */ 65 public double yref() 66 { 67 return _yref; 68 } 69 70 /** 71 * The distance of closest approach to the reference point. 72 * @return distance of closest approach to (xref, yref) 73 */ 74 public double dca() 75 { 76 return _dca; 77 } 78 79 /** 80 * The chi-squared for the fit. 81 * @return chi-squared for the circle fit. 82 */ 83 public double chisq() 84 { 85 return _chisq; 86 } 87 88 /** 89 * The covariance matrix of fit 90 * @return covariance matrix of fit 91 */ 92 public double [] cov() 93 { 94 double[] tmp = new double[6]; 95 System.arraycopy(_covrfd, 0, tmp, 0, 6); 96 return tmp; 97 } 98 99 /** 100 * String representation of this object 101 * @return string representation of this object. 102 */ 103 public String toString() 104 { 105 return "CircleFit at x= "+_xref+", y= "+_yref+System.getProperty("line.separator")+" with dca= "+_dca+", curvature= "+_rho+" and phi= "+_phi; 106 //return "CircleFit at x= "+_xref+", y= "+_yref+"\n with dca= "+_dca+", curvature= "+_rho+", phi= "+_phi+", chsq= "+_chisq; 107 108 } 109 /* 110 public static void main(String[] args) 111 { 112 double[] cov = {1.,0.,0.,1.,0.,1.}; 113 CircleFit cf = new CircleFit(0.,0.,.01,.3,0.1,12., cov); 114 System.out.println(cf); 115 double[] covmat = cf.cov(); 116 for(int i=0;i<covmat.length;++i) 117 { 118 System.out.println(covmat[i]); 119 } 120 } 121 */ 122 }