CbmRoot
Loading...
Searching...
No Matches
CbmRichRingFitterEllipseBase.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2012 UGiessen/JINR-LIT, Giessen/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer] */
4
15#ifndef CBM_RICH_RING_FITTER_ELLIPSE_BASE
16#define CBM_RICH_RING_FITTER_ELLIPSE_BASE
17
19
30 public:
35
40
41 protected:
46 virtual void CalcChi2(CbmRichRingLight* ring)
47 {
48 int nofHits = ring->GetNofHits();
49 if (nofHits <= 5) {
50 ring->SetChi2(-1.);
51 return;
52 }
53
54 double axisA = ring->GetAaxis();
55 double axisB = ring->GetBaxis();
56
57 if (axisA < axisB) {
58 ring->SetChi2(-1.);
59 return;
60 }
61
62 // calculate ellipse focuses
63 double xf1 = ring->GetXF1();
64 double yf1 = ring->GetYF1();
65 double xf2 = ring->GetXF2();
66 double yf2 = ring->GetYF2();
67
68 // calculate chi2
69 double chi2 = 0.;
70 for (int iHit = 0; iHit < nofHits; iHit++) {
71 double x = ring->GetHit(iHit).fX;
72 double y = ring->GetHit(iHit).fY;
73
74 double d1 = sqrt((x - xf1) * (x - xf1) + (y - yf1) * (y - yf1));
75 double d2 = sqrt((x - xf2) * (x - xf2) + (y - yf2) * (y - yf2));
76
77 chi2 += (d1 + d2 - 2. * axisA) * (d1 + d2 - 2. * axisA);
78 }
79 ring->SetChi2(chi2);
80 }
81
92 virtual void CalcChi2(double A, double B, double C, double D, double E, double F, CbmRichRingLight* ring)
93 {
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 = sqrt(pow(2 * A * x + B * y + D, 2) + pow(B * x + 2 * C * y + E, 2));
106
107 chi2 += (d1 * d1) / (d2 * d2);
108 }
109 ring->SetChi2(chi2);
110 }
111};
112
113#endif /* CBMRICHRINGFITTERELLIPSEBASEH */
Abstract base class for concrete Rich Ring fitting algorithms. Each derived class must implement the ...
friend fvec sqrt(const fvec &a)
Abstract base class for concrete Rich Ring fitting algorithms. Each derived class must implement the ...
Base class for concrete ellipse fitting algorithms. Each derived class must implement the method DoFi...
CbmRichRingFitterEllipseBase()
Default constructor.
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.
virtual void CalcChi2(CbmRichRingLight *ring)
Calculate chi2 of the ellipse fit.
double GetXF1() const
Calculate and return X coordinate of the first focus.
double GetYF1() const
Calculate and return Y coordinate of the first focus.
double GetYF2() const
Calculate and return Y coordinate of the second focus.
double GetXF2() const
Calculate and return X coordinate of the second focus.
float GetAaxis() const
int GetNofHits() const
Return number of hits in ring.
float GetBaxis() const
CbmRichHitLight GetHit(int ind)
Return hit by the index.
void SetChi2(float chi2)