CbmRoot
CbmRichRingFitterEllipseBase.h
Go to the documentation of this file.
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:
42  virtual void CalcChi2(CbmRichRingLight* ring) {
43  int nofHits = ring->GetNofHits();
44  if (nofHits <= 5) {
45  ring->SetChi2(-1.);
46  return;
47  }
48 
49  double axisA = ring->GetAaxis();
50  double axisB = ring->GetBaxis();
51 
52  if (axisA < axisB) {
53  ring->SetChi2(-1.);
54  return;
55  }
56 
57  // calculate ellipse focuses
58  double xf1 = ring->GetXF1();
59  double yf1 = ring->GetYF1();
60  double xf2 = ring->GetXF2();
61  double yf2 = ring->GetYF2();
62 
63  // calculate chi2
64  double chi2 = 0.;
65  for (int iHit = 0; iHit < nofHits; iHit++) {
66  double x = ring->GetHit(iHit).fX;
67  double y = ring->GetHit(iHit).fY;
68 
69  double d1 = sqrt((x - xf1) * (x - xf1) + (y - yf1) * (y - yf1));
70  double d2 = sqrt((x - xf2) * (x - xf2) + (y - yf2) * (y - yf2));
71 
72  chi2 += (d1 + d2 - 2. * axisA) * (d1 + d2 - 2. * axisA);
73  }
74  ring->SetChi2(chi2);
75  }
76 
87  virtual void CalcChi2(double A,
88  double B,
89  double C,
90  double D,
91  double E,
92  double F,
93  CbmRichRingLight* ring) {
94  int nofHits = ring->GetNofHits();
95  if (nofHits <= 5) {
96  ring->SetChi2(-1.);
97  return;
98  }
99  double chi2 = 0.;
100  for (int iHit = 0; iHit < nofHits; iHit++) {
101  double x = ring->GetHit(iHit).fX;
102  double y = ring->GetHit(iHit).fY;
103 
104  double d1 = fabs(A * x * x + B * x * y + C * y * y + D * x + E * y + F);
105  double d2 =
106  sqrt(pow(2 * A * x + B * y + D, 2) + pow(B * x + 2 * C * y + E, 2));
107 
108  chi2 += (d1 * d1) / (d2 * d2);
109  }
110  ring->SetChi2(chi2);
111  }
112 };
113 
114 #endif /* CBMRICHRINGFITTERELLIPSEBASEH */
CbmRichRingFitterEllipseBase::CalcChi2
virtual void CalcChi2(CbmRichRingLight *ring)
Calculate chi2 of the ellipse fit.
Definition: CbmRichRingFitterEllipseBase.h:42
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmRichRingFitterEllipseBase
Base class for concrete ellipse fitting algorithms. Each derived class must implement the method DoFi...
Definition: CbmRichRingFitterEllipseBase.h:25
CbmRichHitLight::fX
float fX
Definition: CbmRichRingLight.h:34
CbmRichRingLight::GetYF2
double GetYF2() const
Calculate and return Y coordinate of the second focus.
Definition: CbmRichRingLight.h:206
CbmRichRingLight::GetNofHits
int GetNofHits() const
Return number of hits in ring.
Definition: CbmRichRingLight.h:108
CbmRichRingLight::GetXF2
double GetXF2() const
Calculate and return X coordinate of the second focus.
Definition: CbmRichRingLight.h:196
CbmRichRingFitterBase.h
Abstract base class for concrete Rich Ring fitting algorithms. Each derived class must implement the ...
CbmRichRingLight::GetAaxis
float GetAaxis() const
Definition: CbmRichRingLight.h:163
CbmRichRingLight::GetXF1
double GetXF1() const
Calculate and return X coordinate of the first focus.
Definition: CbmRichRingLight.h:173
CbmRichRingLight::GetBaxis
float GetBaxis() const
Definition: CbmRichRingLight.h:164
CbmRichRingFitterEllipseBase::CalcChi2
virtual void CalcChi2(double A, double B, double C, double D, double E, double F, CbmRichRingLight *ring)
Calculate chi2 of the ellipse fitting using parameters of 2D curve.
Definition: CbmRichRingFitterEllipseBase.h:87
CbmRichRingFitterBase
Abstract base class for concrete Rich Ring fitting algorithms. Each derived class must implement the ...
Definition: CbmRichRingFitterBase.h:23
CbmRichHitLight::fY
float fY
Definition: CbmRichRingLight.h:35
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmRichRingLight::GetHit
CbmRichHitLight GetHit(int ind)
Return hit by the index.
Definition: CbmRichRingLight.h:114
CbmRichRingLight::GetYF1
double GetYF1() const
Calculate and return Y coordinate of the first focus.
Definition: CbmRichRingLight.h:183
CbmRichRingFitterEllipseBase::~CbmRichRingFitterEllipseBase
virtual ~CbmRichRingFitterEllipseBase()
Destructor.
Definition: CbmRichRingFitterEllipseBase.h:35
CbmRichRingLight::SetChi2
void SetChi2(float chi2)
Definition: CbmRichRingLight.h:154
CbmRichRingLight
Definition: CbmRichRingLight.h:39
CbmRichRingFitterEllipseBase::CbmRichRingFitterEllipseBase
CbmRichRingFitterEllipseBase()
Default constructor.
Definition: CbmRichRingFitterEllipseBase.h:30