103 ring->
SetXYABP(-1., -1., -1., -1., -1.);
109 cout <<
"-E- CbmRichRingFitterEllipseTau::DoFit(), too many hits in the ring:" << nofHits << endl;
110 ring->
SetXYABP(-1., -1., -1., -1., -1.);
134 TMatrixD PQ(5, 5, PQa);
151 TMatrixDEigen eig(PQ);
152 TMatrixD evc = eig.GetEigenVectors();
154 Double_t AlgParF = 0.;
155 AlgParF -= evc(0, 0) *
fM[
GA05];
158 AlgParF -= evc(1, 0) *
fM[
GA15];
161 AlgParF -= evc(2, 0) *
fM[
GA25];
164 AlgParF -= evc(3, 0) *
fM[
GA35];
167 AlgParF -= evc(4, 0) *
fM[
GA45];
175 const unsigned int numHits = ring->
GetNofHits();
176 const unsigned int numHits2 = 2 * numHits;
177 const unsigned int numHits3 = 3 * numHits;
178 const unsigned int numHits4 = 4 * numHits;
179 const unsigned int numHits5 = 5 * numHits;
180 const unsigned int numHits6 = 6 * numHits;
181 const double oneOverNumHits = 1. / numHits;
183 for (
unsigned int i = 0; i < numHits; i++) {
188 fZ[i6 + 1] =
fZT[i + numHits] =
x *
y;
189 fZ[i6 + 2] =
fZT[i + numHits2] =
y *
y;
190 fZ[i6 + 3] =
fZT[i + numHits3] =
x;
191 fZ[i6 + 4] =
fZT[i + numHits4] =
y;
192 fZ[i6 + 5] =
fZT[i + numHits5] = 1.;
195 for (
unsigned int i = 0; i < numHits6; i++)
196 fM[i] = oneOverNumHits *
fM[i];
198 for (
int i = 0; i < 25; i++)
222 for (
int i = 0; i < 25; i++)
244 CalcChi2(Pxx, Pxy, Pyy, Px, Py, P, ring);
245 ring->
SetABCDEF(Pxx, Pxy, Pyy, Px, Py, P);
248 double QQx, QQy, Qxx, Qyy, Qx, Qy, Q;
249 double cosa, sina, cca, ssa, sin2a;
251 if (fabs(Pxx - Pyy) > 0.1e-10) {
252 alpha = atan(Pxy / (Pxx - Pyy));
262 sin2a =
sin(2. * alpha);
263 Pxy = Pxy * sin2a / 2.;
264 Qx = Px * cosa + Py * sina;
265 Qy = -Px * sina + Py * cosa;
268 Qxx = 1. / (Pxx * cca + Pxy + Pyy * ssa);
269 Qyy = 1. / (Pxx * ssa - Pxy + Pyy * cca);
270 Q = -P + Qxx * QQx / 4. + Qyy * QQy / 4.;
274 double axisA = TMath::Sqrt(Q * Qxx);
275 double axisB = TMath::Sqrt(Q * Qyy);
276 double centerX = -xc * cosa / 2. + yc * sina / 2.;
277 double centerY = -xc * sina / 2. - yc * cosa / 2.;
279 ring->
SetXYABP(centerX, centerY, axisA, axisB, alpha);
330 const double det3_123_012 =
fP[
GM10] * det2_23_12 -
fP[
GM11] * det2_23_02 +
fP[
GM12] * det2_23_01;
331 const double det3_123_013 =
fP[
GM10] * det2_23_13 -
fP[
GM11] * det2_23_03 +
fP[
GM13] * det2_23_01;
332 const double det3_123_014 =
fP[
GM10] * det2_23_14 -
fP[
GM11] * det2_23_04 +
fP[
GM14] * det2_23_01;
333 const double det3_123_023 =
fP[
GM10] * det2_23_23 -
fP[
GM12] * det2_23_03 +
fP[
GM13] * det2_23_02;
334 const double det3_123_024 =
fP[
GM10] * det2_23_24 -
fP[
GM12] * det2_23_04 +
fP[
GM14] * det2_23_02;
335 const double det3_123_034 =
fP[
GM10] * det2_23_34 -
fP[
GM13] * det2_23_04 +
fP[
GM14] * det2_23_03;
336 const double det3_123_123 =
fP[
GM11] * det2_23_23 -
fP[
GM12] * det2_23_13 +
fP[
GM13] * det2_23_12;
337 const double det3_123_124 =
fP[
GM11] * det2_23_24 -
fP[
GM12] * det2_23_14 +
fP[
GM14] * det2_23_12;
338 const double det3_123_134 =
fP[
GM11] * det2_23_34 -
fP[
GM13] * det2_23_14 +
fP[
GM14] * det2_23_13;
339 const double det3_123_234 =
fP[
GM12] * det2_23_34 -
fP[
GM13] * det2_23_24 +
fP[
GM14] * det2_23_23;
340 const double det3_124_012 =
fP[
GM10] * det2_24_12 -
fP[
GM11] * det2_24_02 +
fP[
GM12] * det2_24_01;
341 const double det3_124_013 =
fP[
GM10] * det2_24_13 -
fP[
GM11] * det2_24_03 +
fP[
GM13] * det2_24_01;
342 const double det3_124_014 =
fP[
GM10] * det2_24_14 -
fP[
GM11] * det2_24_04 +
fP[
GM14] * det2_24_01;
343 const double det3_124_023 =
fP[
GM10] * det2_24_23 -
fP[
GM12] * det2_24_03 +
fP[
GM13] * det2_24_02;
344 const double det3_124_024 =
fP[
GM10] * det2_24_24 -
fP[
GM12] * det2_24_04 +
fP[
GM14] * det2_24_02;
345 const double det3_124_034 =
fP[
GM10] * det2_24_34 -
fP[
GM13] * det2_24_04 +
fP[
GM14] * det2_24_03;
346 const double det3_124_123 =
fP[
GM11] * det2_24_23 -
fP[
GM12] * det2_24_13 +
fP[
GM13] * det2_24_12;
347 const double det3_124_124 =
fP[
GM11] * det2_24_24 -
fP[
GM12] * det2_24_14 +
fP[
GM14] * det2_24_12;
348 const double det3_124_134 =
fP[
GM11] * det2_24_34 -
fP[
GM13] * det2_24_14 +
fP[
GM14] * det2_24_13;
349 const double det3_124_234 =
fP[
GM12] * det2_24_34 -
fP[
GM13] * det2_24_24 +
fP[
GM14] * det2_24_23;
350 const double det3_134_012 =
fP[
GM10] * det2_34_12 -
fP[
GM11] * det2_34_02 +
fP[
GM12] * det2_34_01;
351 const double det3_134_013 =
fP[
GM10] * det2_34_13 -
fP[
GM11] * det2_34_03 +
fP[
GM13] * det2_34_01;
352 const double det3_134_014 =
fP[
GM10] * det2_34_14 -
fP[
GM11] * det2_34_04 +
fP[
GM14] * det2_34_01;
353 const double det3_134_023 =
fP[
GM10] * det2_34_23 -
fP[
GM12] * det2_34_03 +
fP[
GM13] * det2_34_02;
354 const double det3_134_024 =
fP[
GM10] * det2_34_24 -
fP[
GM12] * det2_34_04 +
fP[
GM14] * det2_34_02;
355 const double det3_134_034 =
fP[
GM10] * det2_34_34 -
fP[
GM13] * det2_34_04 +
fP[
GM14] * det2_34_03;
356 const double det3_134_123 =
fP[
GM11] * det2_34_23 -
fP[
GM12] * det2_34_13 +
fP[
GM13] * det2_34_12;
357 const double det3_134_124 =
fP[
GM11] * det2_34_24 -
fP[
GM12] * det2_34_14 +
fP[
GM14] * det2_34_12;
358 const double det3_134_134 =
fP[
GM11] * det2_34_34 -
fP[
GM13] * det2_34_14 +
fP[
GM14] * det2_34_13;
359 const double det3_134_234 =
fP[
GM12] * det2_34_34 -
fP[
GM13] * det2_34_24 +
fP[
GM14] * det2_34_23;
360 const double det3_234_012 =
fP[
GM20] * det2_34_12 -
fP[
GM21] * det2_34_02 +
fP[
GM22] * det2_34_01;
361 const double det3_234_013 =
fP[
GM20] * det2_34_13 -
fP[
GM21] * det2_34_03 +
fP[
GM23] * det2_34_01;
362 const double det3_234_014 =
fP[
GM20] * det2_34_14 -
fP[
GM21] * det2_34_04 +
fP[
GM24] * det2_34_01;
363 const double det3_234_023 =
fP[
GM20] * det2_34_23 -
fP[
GM22] * det2_34_03 +
fP[
GM23] * det2_34_02;
364 const double det3_234_024 =
fP[
GM20] * det2_34_24 -
fP[
GM22] * det2_34_04 +
fP[
GM24] * det2_34_02;
365 const double det3_234_034 =
fP[
GM20] * det2_34_34 -
fP[
GM23] * det2_34_04 +
fP[
GM24] * det2_34_03;
366 const double det3_234_123 =
fP[
GM21] * det2_34_23 -
fP[
GM22] * det2_34_13 +
fP[
GM23] * det2_34_12;
367 const double det3_234_124 =
fP[
GM21] * det2_34_24 -
fP[
GM22] * det2_34_14 +
fP[
GM24] * det2_34_12;
368 const double det3_234_134 =
fP[
GM21] * det2_34_34 -
fP[
GM23] * det2_34_14 +
fP[
GM24] * det2_34_13;
369 const double det3_234_234 =
fP[
GM22] * det2_34_34 -
fP[
GM23] * det2_34_24 +
fP[
GM24] * det2_34_23;
372 const double det4_0123_0123 =
374 const double det4_0123_0124 =
376 const double det4_0123_0134 =
378 const double det4_0123_0234 =
380 const double det4_0123_1234 =
382 const double det4_0124_0123 =
384 const double det4_0124_0124 =
386 const double det4_0124_0134 =
388 const double det4_0124_0234 =
390 const double det4_0124_1234 =
392 const double det4_0134_0123 =
394 const double det4_0134_0124 =
396 const double det4_0134_0134 =
398 const double det4_0134_0234 =
400 const double det4_0134_1234 =
402 const double det4_0234_0123 =
404 const double det4_0234_0124 =
406 const double det4_0234_0134 =
408 const double det4_0234_0234 =
410 const double det4_0234_1234 =
412 const double det4_1234_0123 =
414 const double det4_1234_0124 =
416 const double det4_1234_0134 =
418 const double det4_1234_0234 =
420 const double det4_1234_1234 =
424 const double det =
fP[
GM00] * det4_1234_1234 -
fP[
GM01] * det4_1234_0234 +
fP[
GM02] * det4_1234_0134
425 -
fP[
GM03] * det4_1234_0124 +
fP[
GM04] * det4_1234_0123;
433 const double oneOverDet = 1.0 / det;
434 const double mn1OverDet = -oneOverDet;
436 fP[
GM00] = det4_1234_1234 * oneOverDet;
437 fP[
GM01] = det4_0234_1234 * mn1OverDet;
438 fP[
GM02] = det4_0134_1234 * oneOverDet;
439 fP[
GM03] = det4_0124_1234 * mn1OverDet;
440 fP[
GM04] = det4_0123_1234 * oneOverDet;
442 fP[
GM10] = det4_1234_0234 * mn1OverDet;
443 fP[
GM11] = det4_0234_0234 * oneOverDet;
444 fP[
GM12] = det4_0134_0234 * mn1OverDet;
445 fP[
GM13] = det4_0124_0234 * oneOverDet;
446 fP[
GM14] = det4_0123_0234 * mn1OverDet;
448 fP[
GM20] = det4_1234_0134 * oneOverDet;
449 fP[
GM21] = det4_0234_0134 * mn1OverDet;
450 fP[
GM22] = det4_0134_0134 * oneOverDet;
451 fP[
GM23] = det4_0124_0134 * mn1OverDet;
452 fP[
GM24] = det4_0123_0134 * oneOverDet;
454 fP[
GM30] = det4_1234_0124 * mn1OverDet;
455 fP[
GM31] = det4_0234_0124 * oneOverDet;
456 fP[
GM32] = det4_0134_0124 * mn1OverDet;
457 fP[
GM33] = det4_0124_0124 * oneOverDet;
458 fP[
GM34] = det4_0123_0124 * mn1OverDet;
460 fP[
GM40] = det4_1234_0123 * oneOverDet;
461 fP[
GM41] = det4_0234_0123 * mn1OverDet;
462 fP[
GM42] = det4_0134_0123 * oneOverDet;
463 fP[
GM43] = det4_0124_0123 * mn1OverDet;
464 fP[
GM44] = det4_0123_0123 * oneOverDet;
468 int ncolsb,
double* cp)
472 const double* arp0 = ap;
473 while (arp0 < ap + na) {
474 for (
const double* bcp = bp; bcp < bp + ncolsb;) {
475 const double* arp = arp0;
477 while (bcp < bp + nb) {
478 cij += *arp++ * *bcp;
488#define ROTATE(a, i, j, k, l) \
491 a[i][j] = g - s * (h + g * tau); \
492 a[k][l] = h + s * (g - h * tau)
496 double tresh, theta, tau, t, sm, s,
h, g, c;
499 unsigned int ip, iq, i, j;
500 for (ip = 0; ip < 5; ip++) {
501 for (iq = 0; iq < 5; iq++)
506 for (ip = 0; ip < 5; ip++) {
515 for (sm = 0., ip = 0; ip < 5; ip++)
516 for (iq = ip + 1; iq < 5; iq++)
517 sm += fabs(a[ip][iq]);
522 tresh = (i < 4 ? 0.2 * sm / (5 * 5) : 0.);
524 for (ip = 0; ip < 4; ip++)
525 for (iq = ip + 1; iq < 5; iq++) {
527 g = 100. * fabs(a[ip][iq]);
528 if (i > 4 && (
float) fabs(d[ip] + g) == (
float) fabs(d[ip]) && (
float) fabs(d[iq] + g) == (
float) fabs(d[iq]))
531 else if (fabs(a[ip][iq]) > tresh) {
534 if ((
float) (fabs(
h) + g) == (
float) fabs(
h))
537 theta = 0.5 *
h / a[ip][iq];
538 t = 1. / (fabs(theta) +
sqrt(1. + theta * theta));
539 if (theta < 0.) t = -t;
541 c = 1. /
sqrt(1 + t * t);
550 for (j = 0; j < ip; j++) {
553 for (j = ip + 1; j < iq; j++) {
556 for (j = iq + 1; j < 5; j++) {
559 for (j = 0; j < 5; j++) {
565 for (ip = 0; ip < 5; ip++) {
577 for (i = 0; i < 5; i++) {
579 for (j = i + 1; j < 5; j++)
580 if (d[j] >= p) p = d[k = j];
584 for (j = 0; j < 5; j++) {
#define ROTATE(a, i, j, k, l)
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
friend fvec sqrt(const fvec &a)
friend fvec cos(const fvec &a)
friend fvec sin(const fvec &a)
static const int MAX_NOF_HITS_IN_RING
virtual void CalcChi2(CbmRichRingLight *ring)
Calculate chi2 of the ellipse fit.
CbmRichRingFitterEllipseTau()
Default constructor.
virtual ~CbmRichRingFitterEllipseTau()
Destructor.
void Taubin()
Perform Taubin method.
virtual void DoFit(CbmRichRingLight *ring)
Inherited from CbmRichRingFitterBase.
void AMultB(const double *const ap, int na, int ncolsa, const double *const bp, int nb, int ncolsb, double *cp)
Matrices multiplication.
void TransformEllipse(CbmRichRingLight *ring)
Transform fitted curve to ellipse parameters.
double fZT[MAX_NOF_HITS_IN_RING *6]
double fZ[MAX_NOF_HITS_IN_RING *6]
void Jacobi(double a[5][5], double d[5], double v[5][5])
Jacobi method.
void Inv5x5()
Invert 5x5 matrix.
void Eigsrt(double d[5], double v[5][5])
Find eigenvalues.
void InitMatrices(CbmRichRingLight *ring)
Initialize all matrices.
void SetXYABP(float x, float y, float a, float b, float p)
Set all 5 ellipse parameters.
void SetABCDEF(float a, float b, float c, float d, float e, float f)
Set all 6 parameters of curve equation Axx+Bxy+Cyy+Dx+Ey+F.
int GetNofHits() const
Return number of hits in ring.
CbmRichHitLight GetHit(int ind)
Return hit by the index.
Data class with information on a STS local track.