#include <MdcLine.h>
Public Member Functions | |
MdcLine (int n) | |
~MdcLine () | |
int | fit (int nUse) |
Public Attributes | |
double * | x |
double * | y |
double * | sigma |
double * | resid |
int | nPoint |
double | slope |
double | intercept |
double | chisq |
double | errmat [3] |
Definition at line 13 of file MdcLine.h.
MdcLine::MdcLine | ( | int | n | ) | [inline] |
MdcLine::~MdcLine | ( | ) | [inline] |
int MdcLine::fit | ( | int | nUse | ) |
Definition at line 10 of file MdcLine.cxx.
References chisq, errmat, intercept, nPoint, resid, sigma, slope, weight, x, and y.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegInfoSterO::calcStereo(), and MdcSegFinder::tryPatterns().
00010 { 00011 00012 double s1, sx, sy, sxx, sxy; // The various sums. 00013 double delinv, denom; 00014 double weight = 0.013; // weight for hits, calculated from sigmas. 00015 int ihit; 00016 if (nUse > nPoint) nUse = nPoint; 00017 s1 = sx = sy = sxx = sxy = 0.0; 00018 chisq = 0.0; 00019 for (ihit = 0; ihit < nUse; ihit++) { 00020 00021 if (sigma[ihit] < 0.0) continue; 00022 weight = 1. / (sigma[ihit] * sigma[ihit]);//NEED sigma of MdcHits 00023 s1 += weight; 00024 sx += x[ihit] * weight; 00025 sy += y[ihit] * weight; 00026 sxx += x[ihit] * (x[ihit] * weight); 00027 sxy += y[ihit] * (x[ihit] * weight); 00028 00029 //std::cout<<__FILE__<<" "<<__LINE__<< " "<<ihit<<" sigma "<< 00030 //sigma[ihit] <<" weight " 00031 //<< weight<<" x " 00032 //<< x[ihit]<<" y " 00033 //<< y[ihit]<< std::endl; 00034 } 00035 00036 /* Calculate parameters. */ 00037 denom = s1 * sxx - sx * sx; 00038 delinv = (denom == 0.0) ? 1.e20 : 1. / denom; 00039 intercept = (sy * sxx - sx * sxy) * delinv; 00040 slope = (s1 * sxy - sx * sy) * delinv; 00041 errmat[0] = sxx * delinv; 00042 errmat[1] = -sx * delinv; 00043 errmat[2] = s1 * delinv; 00044 //std::cout << " After Fit:" << std::endl;//yzhang debug 00045 /* Calculate residuals. */ 00046 for (ihit = 0; ihit < nUse; ihit++) { 00047 if (sigma[ihit] < 0.0) continue; 00048 resid[ihit] = ( y[ihit] - intercept - slope * x[ihit] ); 00049 chisq += resid[ihit] * resid[ihit] / (sigma[ihit] * sigma[ihit]); 00050 //std::cout << "resid "<<ihit<<" "<<resid[ihit]<<" sigma "<<sigma[ihit]<<" chisq add "<<resid[ihit] * resid[ihit] / (sigma[ihit] * sigma[ihit]) << std::endl;//yzhang debug 00051 } 00052 00053 //std::cout<<__FILE__<<" "<<__LINE__ 00054 //<< " intercept "<<intercept<<" slope "<<slope 00055 //<< " chisq "<<chisq<<std::endl;//yzhang debug 00056 return 0; 00057 }
double MdcLine::chisq |
Definition at line 22 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), fit(), MdcSeg::setValues(), and MdcSegFinder::tryPatterns().
double MdcLine::errmat[3] |
double MdcLine::intercept |
Definition at line 21 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegInfoSterO::calcStereo(), fit(), MdcSeg::setValues(), and MdcSegFinder::tryPatterns().
int MdcLine::nPoint |
Definition at line 19 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), fit(), and MdcLine().
double* MdcLine::resid |
Definition at line 18 of file MdcLine.h.
Referenced by fit(), MdcLine(), MdcSegFinder::tryPatterns(), and ~MdcLine().
double* MdcLine::sigma |
Definition at line 17 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegInfoSterO::calcStereo(), fit(), MdcLine(), MdcSegFinder::tryPatterns(), MdcSegInfoSterO::zPosition(), and ~MdcLine().
double MdcLine::slope |
Definition at line 20 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegInfoSterO::calcStereo(), fit(), MdcSeg::setValues(), and MdcSegFinder::tryPatterns().
double* MdcLine::x |
Definition at line 15 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), MdcSegInfoSterO::calcStereo(), fit(), MdcLine(), MdcSegFinder::tryPatterns(), MdcSegInfoSterO::zPosition(), and ~MdcLine().
double* MdcLine::y |
Definition at line 16 of file MdcLine.h.
Referenced by MdcSegGrouper::calcParByHits(), fit(), MdcLine(), MdcSegFinder::tryPatterns(), MdcSegInfoSterO::zPosition(), and ~MdcLine().