Go to the documentation of this file.00001
00011 #ifndef CBM_RICH_RING_FITTER_ELLIPSE_BASE
00012 #define CBM_RICH_RING_FITTER_ELLIPSE_BASE
00013
00014 #include "CbmRichRingFitterBase.h"
00015
00025 class CbmRichRingFitterEllipseBase: public CbmRichRingFitterBase {
00026 public:
00030 CbmRichRingFitterEllipseBase(){ };
00031
00035 virtual ~CbmRichRingFitterEllipseBase(){ };
00036
00037 protected:
00038
00043 virtual void CalcChi2(
00044 CbmRichRingLight* ring)
00045 {
00046 int nofHits = ring->GetNofHits();
00047 if (nofHits <= 5){
00048 ring->SetChi2(-1.);
00049 return;
00050 }
00051
00052 double axisA = ring->GetAaxis();
00053 double axisB = ring->GetBaxis();
00054
00055 if (axisA < axisB){
00056 ring->SetChi2(-1.);
00057 return;
00058 }
00059
00060
00061 double xf1 = ring->GetXF1();
00062 double yf1 = ring->GetYF1();
00063 double xf2 = ring->GetXF2();
00064 double yf2 = ring->GetYF2();
00065
00066
00067 double chi2 = 0.;
00068 for(int iHit = 0; iHit < nofHits; iHit++){
00069 double x = ring->GetHit(iHit).fX;
00070 double y = ring->GetHit(iHit).fY;
00071
00072 double d1 = sqrt( (x-xf1)*(x-xf1) + (y-yf1)*(y-yf1) );
00073 double d2 = sqrt( (x-xf2)*(x-xf2) + (y-yf2)*(y-yf2) );
00074
00075 chi2 += (d1 + d2 - 2.*axisA)*(d1 + d2 - 2.*axisA);
00076 }
00077 ring->SetChi2(chi2);
00078 }
00079
00090 virtual void CalcChi2(
00091 double A,
00092 double B,
00093 double C,
00094 double D,
00095 double E,
00096 double F,
00097 CbmRichRingLight* ring)
00098 {
00099 int nofHits = ring->GetNofHits();
00100 if (nofHits <= 5){
00101 ring->SetChi2(-1.);
00102 return;
00103 }
00104 double chi2 = 0.;
00105 for(int iHit = 0; iHit < nofHits; iHit++){
00106 double x = ring->GetHit(iHit).fX;
00107 double y = ring->GetHit(iHit).fY;
00108
00109 double d1 = fabs(A*x*x + B*x*y + C*y*y + D*x + E*y + F);
00110 double d2 = sqrt( pow(2*A*x + B*y + D, 2) + pow(B*x + 2*C*y + E, 2) );
00111
00112 chi2 += (d1*d1)/(d2*d2);
00113 }
00114 ring->SetChi2(chi2);
00115 }
00116
00117 };
00118
00119 #endif