00001 00010 #ifndef CBM_RICH_RING_FITTER_BASE 00011 #define CBM_RICH_RING_FITTER_BASE 00012 00013 #include "CbmRichRingLight.h" 00023 class CbmRichRingFitterBase 00024 { 00025 public: 00026 00030 CbmRichRingFitterBase(){ } 00031 00035 virtual ~CbmRichRingFitterBase() { } 00036 00043 virtual void DoFit( 00044 CbmRichRingLight* ring) = 0; 00045 00046 protected: 00047 00052 virtual void CalcChi2( 00053 CbmRichRingLight* ring) 00054 { 00055 int nofHits = ring->GetNofHits(); 00056 if ( nofHits < 4 ) { 00057 ring->SetChi2(-1.); 00058 return; 00059 } 00060 00061 float chi2 = 0.; 00062 float r = ring->GetRadius(); 00063 float xc = ring->GetCenterX(); 00064 float yc = ring->GetCenterY(); 00065 00066 for (int i = 0; i < nofHits; i++) { 00067 float xh = ring->GetHit(i).fX; 00068 float yh = ring->GetHit(i).fY; 00069 float d = r - sqrt((xc - xh)*(xc - xh) + (yc - yh)*(yc - yh)); 00070 00071 chi2 += d*d; 00072 } 00073 ring->SetChi2(chi2); 00074 } 00075 00076 static const int MAX_NOF_HITS_IN_RING = 400; // maximum possible number of hits 00077 }; 00078 00079 #endif