EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingFitterEllipseBase.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingFitterEllipseBase.h
1 
11 #ifndef CBM_RICH_RING_FITTER_ELLIPSE_BASE
12 #define CBM_RICH_RING_FITTER_ELLIPSE_BASE
13 
14 #include "CbmRichRingFitterBase.h"
15 
26 public:
31 
36 
37 protected:
38 
43  virtual void CalcChi2(
44  CbmRichRingLight* ring)
45  {
46  int nofHits = ring->GetNofHits();
47  if (nofHits <= 5){
48  ring->SetChi2(-1.);
49  return;
50  }
51 
52  double axisA = ring->GetAaxis();
53  double axisB = ring->GetBaxis();
54 
55  if (axisA < axisB){
56  ring->SetChi2(-1.);
57  return;
58  }
59 
60  // calculate ellipse focuses
61  double xf1 = ring->GetXF1();
62  double yf1 = ring->GetYF1();
63  double xf2 = ring->GetXF2();
64  double yf2 = ring->GetYF2();
65 
66  // calculate chi2
67  double chi2 = 0.;
68  for(int iHit = 0; iHit < nofHits; iHit++){
69  double x = ring->GetHit(iHit).fX;
70  double y = ring->GetHit(iHit).fY;
71 
72  double d1 = sqrt( (x-xf1)*(x-xf1) + (y-yf1)*(y-yf1) );
73  double d2 = sqrt( (x-xf2)*(x-xf2) + (y-yf2)*(y-yf2) );
74 
75  chi2 += (d1 + d2 - 2.*axisA)*(d1 + d2 - 2.*axisA);
76  }
77  ring->SetChi2(chi2);
78  }
79 
90  virtual void CalcChi2(
91  double A,
92  double B,
93  double C,
94  double D,
95  double E,
96  double F,
97  CbmRichRingLight* ring)
98  {
99  int nofHits = ring->GetNofHits();
100  if (nofHits <= 5){
101  ring->SetChi2(-1.);
102  return;
103  }
104  double chi2 = 0.;
105  for(int iHit = 0; iHit < nofHits; iHit++){
106  double x = ring->GetHit(iHit).fX;
107  double y = ring->GetHit(iHit).fY;
108 
109  double d1 = fabs(A*x*x + B*x*y + C*y*y + D*x + E*y + F);
110  double d2 = sqrt( pow(2*A*x + B*y + D, 2) + pow(B*x + 2*C*y + E, 2) );
111 
112  chi2 += (d1*d1)/(d2*d2);
113  }
114  ring->SetChi2(chi2);
115  }
116 
117 };
118 
119 #endif /* CBMRICHRINGFITTERELLIPSEBASEH */