Belle II Software development
Lpav.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <cmath>
10#include <iostream>
11
12#include "CLHEP/Vector/Sqr.h"
13#include "trg/cdc/Lpav.h"
14
15namespace Belle2 {
21//
22// constants, enums and typedefs
23//
25 extern "C" {
26 float prob_(float*, int*);
27 }
28
30 static double err_dis_inv(double x, double y, double w, double a, double b)
31 {
32 if (a == 0 && b == 0) {
33 return w;
34 } else {
35 double f = x * b - y * a;
36 double rsq = x * x + y * y;
37 f *= f;
38 return w * rsq / f;
39 }
40 }
41
42//
43// static data member definitions
44//
45
46//
47// constructors and destructor
48//
50 m_wsum(),
51 m_xsum(),
52 m_ysum(),
53 m_xxsum(),
54 m_yysum(),
55 m_xysum(),
56 m_xrrsum(),
57 m_yrrsum(),
58 m_rrrrsum(),
59 m_wsum_temp(),
60 m_xav(),
61 m_yav(),
62 m_xyavp(),
63 m_rscale(),
64 m_xxavp(),
65 m_yyavp(),
66 m_xrravp(),
67 m_yrravp(),
68 m_rrrravp(),
69 m_sinrot(),
70 m_cosrot(),
71 m_nc(),
72 m_chisq() // 2019/07/31 by ytlai
73 {
74 clear();
75 }
76
77// TRGCDCLpav::TRGCDCLpav( const TRGCDCLpav& )
78// {
79// }
80
82 {
83 }
84
85//
86// assignment operators
87//
88// const TRGCDCLpav& TRGCDCLpav::operator=( const TRGCDCLpav& )
89// {
90// }
91
92//
93// comparison operators
94//
95// bool TRGCDCLpav::operator==( const TRGCDCLpav& ) const
96// {
97// }
98
99// bool TRGCDCLpav::operator!=( const TRGCDCLpav& ) const
100// {
101// }
102
103//
104// member functions
105//
106 void TRGCDCLpav::calculate_average(double xi, double yi, double wi)
107 {
108 if (m_wsum <= 0) return;
109 m_wsum_temp = m_wsum + wi;
110 double rri(xi * xi + yi * yi);
111 double wrri(wi * rri);
112 double wsum_inv(1 / m_wsum_temp);
113 m_xav = (m_xsum + wi * xi) * wsum_inv;
114 m_yav = (m_ysum + wi * yi) * wsum_inv;
115
116 double xxav((m_xxsum + wi * xi * xi) * wsum_inv);
117 double yyav((m_yysum + wi * yi * yi) * wsum_inv);
118 double xyav((m_xysum + wi * xi * yi) * wsum_inv);
119 double xrrav((m_xrrsum + xi * wrri) * wsum_inv);
120 double yrrav((m_yrrsum + yi * wrri) * wsum_inv);
121 double rrrrav((m_rrrrsum + wrri * rri) * wsum_inv);
122
123 calculate_average_n(xxav, yyav, xyav, xrrav, yrrav, rrrrav);
124
125 }
126
128 {
129 if (m_wsum <= 0) return;
131 double wsum_inv(1 / m_wsum_temp);
132 m_xav = m_xsum * wsum_inv;
133 m_yav = m_ysum * wsum_inv;
134
135 double xxav(m_xxsum * wsum_inv);
136 double yyav(m_yysum * wsum_inv);
137 double xyav(m_xysum * wsum_inv);
138 double xrrav(m_xrrsum * wsum_inv);
139 double yrrav(m_yrrsum * wsum_inv);
140 double rrrrav(m_rrrrsum * wsum_inv);
141
142 calculate_average_n(xxav, yyav, xyav, xrrav, yrrav, rrrrav);
143 }
144
145 void TRGCDCLpav::calculate_average_n(double xxav, double yyav, double xyav,
146 double xrrav, double yrrav, double rrrrav)
147 {
148 double xxav_p = xxav - m_xav * m_xav;
149 double yyav_p = yyav - m_yav * m_yav;
150 double xyav_p = xyav - m_xav * m_yav;
151 double rrav_p = xxav_p + yyav_p;
152
153 double a = std::fabs(xxav_p - yyav_p);
154 double b = 4 * xyav_p * xyav_p;
155 double asqpb = a * a + b;
156 double rasqpb = std::sqrt(asqpb);
157 double splus = 1 + a / rasqpb;
158 double sminus = b / (asqpb * splus);
159 splus = std::sqrt(0.5 * splus);
160 sminus = std::sqrt(0.5 * sminus);
161//C
162//C== First require : SIGN(C**2 - S**2) = SIGN(XXAV - YYAV)
163//C
164 if (xxav_p <= yyav_p) {
165 m_cosrot = sminus;
166 m_sinrot = splus;
167 } else {
168 m_cosrot = splus;
169 m_sinrot = sminus;
170 }
171//C
172//C== Require : SIGN(S) = SIGN(XYAV)*SIGN(C) (Assuming SIGN(C) > 0)
173//C
174 if (xyav_p < 0) m_sinrot = - m_sinrot;
175//*
176//* We now have the smallest angle that guarantees <X**2> > <Y**2>
177//*
178//* To get the SIGN of the charge right, the new X-AXIS must point
179//* outward from the orgin. We are free to change signs of both
180//* COSROT and SINROT simultaneously to accomplish this.
181//*
182//* Choose SIGN of C wisely to be able to get the sign of the charge
183//*
184 if (m_cosrot * m_xav + m_sinrot * m_yav <= 0) {
185 m_cosrot = - m_cosrot;
186 m_sinrot = - m_sinrot;
187 }
188 m_rscale = std::sqrt(rrav_p);
189 double cos2 = m_cosrot * m_cosrot;
190 double sin2 = m_sinrot * m_sinrot;
191 double cs2 = 2 * m_sinrot * m_cosrot;
192 double rrav_p_inv(1 / rrav_p);
193 m_xxavp = (cos2 * xxav_p + cs2 * xyav_p + sin2 * yyav_p) * rrav_p_inv;
194 m_yyavp = (cos2 * yyav_p - cs2 * xyav_p + sin2 * xxav_p) * rrav_p_inv;
195
196 double xav2 = m_xav * m_xav;
197 double yav2 = m_yav * m_yav;
198 double xrrav_p = (xrrav - 2 * xxav * m_xav + xav2 * m_xav -
199 2 * xyav * m_yav + m_xav * yav2) - m_xav * rrav_p;
200 double yrrav_p = (yrrav - 2 * yyav * m_yav + yav2 * m_yav -
201 2 * xyav * m_xav + m_yav * xav2) - m_yav * rrav_p;
202 m_xrravp = (m_cosrot * xrrav_p + m_sinrot * yrrav_p) * rrav_p_inv / m_rscale;
203 m_yrravp = (- m_sinrot * xrrav_p + m_cosrot * yrrav_p) * rrav_p_inv / m_rscale;
204
205 double rrav = xxav + yyav;
206 double rrrrav_p = rrrrav
207 - 2 * m_yav * yrrav - 2 * m_xav * xrrav
208 + rrav * (xav2 + yav2)
209 - 2 * m_xav * xrrav_p - xav2 * rrav_p
210 - 2 * m_yav * yrrav_p - yav2 * rrav_p;
211 m_rrrravp = rrrrav_p * rrav_p_inv * rrav_p_inv;
212 m_xyavp = 0;
213 }
214
215 void TRGCDCLpav::calculate_average3(double xi, double yi, double wi)
216 {
217 if (m_wsum <= 0) return;
218 m_wsum_temp = m_wsum + wi;
219 double wsum_inv(1 / m_wsum_temp);
220 double rri(xi * xi + yi * yi);
221 m_xav = (m_xsum + wi * xi) * wsum_inv;
222 m_yav = (m_ysum + wi * yi) * wsum_inv;
223
224 m_rscale = 1;
225 m_cosrot = 1;
226 m_sinrot = 0;
227 m_xxavp = (m_xxsum + wi * xi * xi) * wsum_inv;
228 m_xyavp = (m_xysum + wi * xi * yi) * wsum_inv;
229 m_yyavp = (m_yysum + wi * yi * yi) * wsum_inv;
230 double wrri(wi * rri);
231 m_xrravp = (m_xrrsum + xi * wrri) * wsum_inv;
232 m_yrravp = (m_yrrsum + yi * wrri) * wsum_inv;
233 m_rrrravp = (m_rrrrsum + rri * wrri) * wsum_inv;
234 }
235
237 {
238 if (m_wsum <= 0) return;
240 double wsum_inv(1 / m_wsum_temp);
241 m_xav = m_xsum * wsum_inv;
242 m_yav = m_ysum * wsum_inv;
243
244 m_rscale = 1;
245 m_cosrot = 1;
246 m_sinrot = 0;
247 m_xxavp = m_xxsum * wsum_inv;
248 m_xyavp = m_xysum * wsum_inv;
249 m_yyavp = m_yysum * wsum_inv;
250 m_xrravp = m_xrrsum * wsum_inv;
251 m_yrravp = m_yrrsum * wsum_inv;
252 m_rrrravp = m_rrrrsum * wsum_inv;
253 }
254
255
256//
257// const member functions
258//
259
260//
261// static member functions
262//
263
265 std::ostream& operator<<(std::ostream& o, const TRGCDCLpav& a)
266 {
267// o << "wsum=" << a.m_wsum << " xsum=" << a.m_xsum << " ysum=" << a.m_ysum
268// << " xxsum=" << a.m_xxsum << " xysum=" << a.m_xysum
269// << " yysum=" << a.m_yysum
270// << " xrrsum=" << a.m_xrrsum << " yrrsum=" << a.m_yrrsum
271// << " rrrrsum=" << a.m_rrrrsum;
272// o << " rscale=" << a.m_rscale
273// << " xxavp=" << a.m_xxavp << " yyavp=" << a.m_yyavp
274// << " xrravp=" << a.m_xrravp << " yrravp=" << a.m_yrravp
275// << " rrrravp=" << a.m_rrrravp << " cosrot=" << a.m_cosrot
276// << " sinrot=" << a.m_sinrot
277// << std::endl;
278 o << " nc=" << a.m_nc << " chisq=" << a.m_chisq << " " << (TRGCDCLpar&) a;
279 return o;
280 }
281
283 {
284 if (m_rscale <= 0) return -1;
285 double xrrxrr = m_xrravp * m_xrravp;
286 double yrryrr = m_yrravp * m_yrravp;
287 double rrrrm1 = m_rrrravp - 1;
288 double xxyy = m_xxavp * m_yyavp;
289
290 double c0 = rrrrm1 * xxyy - xrrxrr * m_yyavp - yrryrr * m_xxavp;
291 double c1 = - rrrrm1 + xrrxrr + yrryrr - 4 * xxyy;
292 double c2 = 4 + rrrrm1 - 4 * xxyy;
293 double c4 = - 4;
294//
295//C COEFFICIENTS OF THE DERIVATIVE - USED IN NEWTON-RAPHSON ITERATIONS
296//
297 double c2d = 2 * c2;
298 double c4d = 4 * c4;
299//
300 double lambda = 0;
301
302 double chiscl = m_wsum_temp * m_rscale * m_rscale;
303 double dlamax = 0.001 / chiscl;
304 const int ntry = 5;
305 int itry = 0;
306 double dlambda = dlamax;
307 while (itry < ntry && std::fabs(dlambda) >= dlamax) {
308 double cpoly = c0 + lambda * (c1 + lambda *
309 (c2 + lambda * lambda * c4));
310 double dcpoly = c1 + lambda * (c2d + lambda * lambda * c4d);
311 dlambda = - cpoly / dcpoly;
312 lambda += dlambda;
313 itry ++;
314 }
315 lambda = lambda < 0 ? 0 : lambda;
316 return lambda;
317 }
318
320 {
321 if (m_rscale <= 0) return -1;
322 double xrrxrr = m_xrravp * m_xrravp;
323 double yrryrr = m_yrravp * m_yrravp;
324//cnv double rrrrm1 = m_rrrravp - 1;
325//cnv double xxyy = m_xxavp * m_yyavp;
326
327 double a = m_rrrravp;
328 double b = xrrxrr + yrryrr - m_rrrravp * (m_xxavp + m_yyavp);
329 double c = m_rrrravp * m_xxavp * m_yyavp
330 - m_yyavp * xrrxrr - m_xxavp * yrryrr
332 if (c >= 0 && b <= 0) {
333 return (-b - std::sqrt(b * b - 4 * a * c)) / 2 / a;
334 } else if (c >= 0 && b > 0) {
335 std::cout << " returning " << -1 << std::endl;
336 return -1;
337 } else if (c < 0) {
338 return (-b + std::sqrt(b * b - 4 * a * c)) / 2 / a;
339 }
340 return -1;
341 }
342
344 {
345 double lambda = solve_lambda();
346// changed on Oct-13-93
347// if (lambda<=0) return -1;
348 if (lambda < 0) return -1;
349 double h11 = m_xxavp - lambda;
350 double h22 = m_yyavp - lambda;
351 if (h11 == 0.0) return -1;
352 double h14 = m_xrravp;
353 double h24 = m_yrravp;
354 double h34 = 1 + 2 * lambda;
355 double rootsq = (h14 * h14 / h11 / h11) + 4 * h34;
356 if (std::fabs(h22) > std::fabs(h24)) {
357 if (h22 == 0.0) return -1;
358 double ratio = h24 / h22;
359 rootsq += ratio * ratio ;
360 m_kappa = 1 / std::sqrt(rootsq);
361 m_beta = - ratio * m_kappa;
362 } else {
363 if (h24 == 0.0) return -1;
364 double ratio = h22 / h24;
365 rootsq = 1 + ratio * ratio * rootsq;
366 m_beta = 1 / std::sqrt(rootsq);
367 m_beta = h24 > 0 ? -m_beta : m_beta;
368 m_kappa = -ratio * m_beta;
369 }
370 m_alpha = - (h14 / h11) * m_kappa;
371 m_gamma = - h34 * m_kappa;
372// if (lambda<0.0001) {
373// std::cout << " lambda=" << lambda << " h34=" << h34
374// << " rootsq=" << rootsq << " h22=" << h22
375// << " h11=" << h11 << " h14=" << h14 << " h24=" << h24 <<
376// " " << *this << std::endl;
377// }
378//
379//C TRANSFORM THESE INTO THE LAB COORDINATE SYSTEM
380//
381//C FIRST GET KAPPA AND GAMMA BACK TO REAL DIMENSIONS
382//
384//
385//C NEXT ROTATE ALPHA AND BETA
386//
388//
389//C THEN TRANSLATE BY (XAV,YAV)
390//
391 move(-m_xav, -m_yav);
392 if (m_yrravp < 0) neg();
393 m_chisq = lambda * m_wsum_temp * m_rscale * m_rscale;
394 return lambda;
395 }
396
398 {
399 double lambda = solve_lambda3();
400// changed on Oct-13-93
401// if (lambda<=0) return -1;
402 if (lambda < 0) return -1;
403 double h11 = m_xxavp - lambda;
404 double h22 = m_yyavp - lambda;
405 double h14 = m_xrravp;
406 double h24 = m_yrravp;
407 m_gamma = 0;
408 double h12 = m_xyavp;
409 double det = h11 * h22 - h12 * h12;
410 if (det != 0) {
411 double r1 = (h14 * h22 - h24 * h12) / (det);
412 double r2 = (h24 * h11 - h14 * h12) / (det);
413 double kinvsq = r1 * r1 + r2 * r2;
414 m_kappa = std::sqrt(1 / kinvsq);
415 if (h11 != 0) m_alpha = -m_kappa * r1;
416 else m_alpha = 1;
417 if (h22 != 0) m_beta = -m_kappa * r2;
418 else m_beta = 1;
419 } else {
420 m_kappa = 0;
421 if (h11 != 0 && h22 != 0) {
422 m_beta = 1 / std::sqrt(1 + h12 * h12 / h11 / h11);
423 m_alpha = std::sqrt(1 - m_beta * m_beta);
424 } else if (h11 != 0) {
425 m_beta = 1;
426 m_alpha = 0;
427 } else {
428 m_beta = 0;
429 m_alpha = 1;
430 }
431 }
432 if ((m_alpha * m_xav + m_beta * m_yav) *
433 (m_beta * m_xav - m_alpha * m_yav) < 0) neg();
434// if (std::fabs(m_alpha)<0.01 && std::fabs(m_beta)<0.01) {
435// std::cout << " lambda=" << lambda << " " << *this << std::endl;
436// }
437 m_chisq = lambda * m_wsum_temp * m_rscale * m_rscale;
438 return lambda;
439 }
440
441 double TRGCDCLpav::fit(double x, double y, double w)
442 {
443 if (m_nc <= 3) return -1;
444 m_chisq = -1;
445 if (m_nc < 4) {
447 double q = calculate_lpar3();
448 if (q > 0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
449 } else {
450 calculate_average(x, y, w);
451 double q = calculate_lpar();
452 if (q > 0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
453 }
454 return m_chisq;
455 }
456
457 double TRGCDCLpav::fit(void)
458 {
459 if (m_nc <= 3) return -1;
460 m_chisq = -1;
461 double q;
462 if (m_nc < 4) {
464 q = calculate_lpar3();
465 if (q > 0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
466 } else {
468 q = calculate_lpar();
469 if (q > 0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
470 }
471 return m_chisq;
472 }
473
474 CLHEP::HepSymMatrix TRGCDCLpav::cov(int inv) const
475#ifdef BELLE_OPTIMIZED_RETURN
476 return vret(4);
477 {
478#else
479 {
480 CLHEP::HepSymMatrix vret(4);
481#endif
482 vret(1, 1) = m_xxsum;
483 vret(2, 1) = m_xysum;
484 vret(2, 2) = m_yysum;
485 vret(3, 1) = m_xsum;
486 vret(3, 2) = m_ysum;
487 vret(3, 3) = m_wsum;
488 vret(4, 1) = m_xrrsum;
489 vret(4, 2) = m_yrrsum;
490 vret(4, 3) = m_xxsum + m_yysum;
491 vret(4, 4) = m_rrrrsum;
492 if (inv == 0)
493 {
494// int i=vret.Inv();
495 int i;
496 vret.invert(i);
497 if (i != 0) {
498 std::cout << "TRGCDCLpav::cov:could not invert nc=" << m_nc << vret;
499#ifdef HAVE_EXCEPTION
500 throw new Singular();
501#endif
502 }
503 }
504 return vret;
505 }
506
507 CLHEP::HepSymMatrix TRGCDCLpav::cov_c(int inv) const
508#ifdef BELLE_OPTIMIZED_RETURN
509 return vret(3);
510 {
511#else
512 {
513 CLHEP::HepSymMatrix vret(3);
514#endif
515#ifdef HAVE_EXCEPTION
516 try
517 {
518#endif
519 vret = cov(1).similarity(dldc());
520#ifdef HAVE_EXCEPTION
521 } catch (TRGCDCLpav::Singular)
522 {
523 throw new Singular_c();
524 }
525#endif
526 if (inv == 0)
527 {
528// int i = vret.Inv();
529 int i;
530 vret.invert(i);
531 if (i != 0) {
532 std::cout << "TRGCDCLpav::cov_c:could not invert " << vret;
533#ifdef HAVE_EXCEPTION
534 throw new Singular_c();
535#endif
536 }
537 }
538 return vret;
539 }
540
541 int TRGCDCLpav::extrapolate(double r, double& phi, double& dphi) const
542 {
543 double x, y;
544 if (m_chisq < 0) return -1;
545 if (xy(r, x, y) != 0) return -1;
546 phi = std::atan2(y, x);
547 if (phi < 0) phi += (2 * M_PI);
548 CLHEP::HepVector v(4);
549 v(1) = x;
550 v(2) = y;
551 v(3) = 1;
552 v(4) = r * r;
553// CLHEP::HepSymMatrix l = cov().similarityT(v);
554#ifdef HAVE_EXCEPTION
555 try {
556#endif
557// CLHEP::HepSymMatrix l = cov().similarity(v.T());
558// // std::cout << "delta d^2=" << l(1,1);
559// if (l(1,1)>0) {
560 double l = cov().similarity(v);
561 if (l > 0) {
562 double ls = std::sqrt(l);
563 dphi = ls / r;
564 // std::cout << " delta d=" << ls << " dphi=" << dphi;
565 }
566#ifdef HAVE_EXCEPTION
567 } catch (TRGCDCLpav::Singular) {
568 return -1;
569 }
570#endif
571// std::cout << std::endl;
572 return 0;
573 }
574
575 double TRGCDCLpav::similarity(double x, double y) const
576 {
577 if (m_nc <= 3) return -1;
578 CLHEP::HepVector v(4);
579 v(1) = x;
580 v(2) = y;
581 v(3) = 1;
582 v(4) = x * x + y * y;
583 double l;
584#ifdef HAVE_EXCEPTION
585 try {
586#endif
587 l = cov().similarity(v);
588#ifdef HAVE_EXCEPTION
589 } catch (TRGCDCLpav::Singular) {
590 return -1;
591 }
592#endif
593 return l;
594 }
595
596// void TRGCDCLpav::add(double xi, double yi, double w, double a, double b)
597// {
598//double wi = err_dis_inv(xi, yi, w, a, b);
599// add(xi, yi, wi); calling itself with output
600// }
601//
602 void TRGCDCLpav::add_point(double xi, double yi,
603 double wi)
604 {
605 m_wsum += wi;
606 m_xsum += wi * xi;
607 m_ysum += wi * yi;
608 m_xxsum += wi * xi * xi;
609 m_yysum += wi * yi * yi;
610 m_xysum += wi * xi * yi;
611//double rri = ( xi * xi + yi * yi );
612//double wrri = wi * rri;
613 double rri = (xi * xi + yi * yi);
614 double wrri = wi * rri;
615 m_xrrsum += wrri * xi;
616 m_yrrsum += wrri * yi;
617 m_rrrrsum += wrri * rri;
618 m_nc += 1;
619 }
620
621 void TRGCDCLpav::add_point_frac(double xi, double yi, double w, double a)
622 {
623//double wi = w * a;
624 double wi = w * a;
625 m_wsum += wi;
626 m_xsum += wi * xi;
627 m_ysum += wi * yi;
628 m_xxsum += wi * xi * xi;
629 m_yysum += wi * yi * yi;
630 m_xysum += wi * xi * yi;
631//double rri = ( xi * xi + yi * yi );
632//double wrri = wi * rri;
633 double rri = (xi * xi + yi * yi);
634 double wrri = wi * rri;
635 m_xrrsum += wrri * xi;
636 m_yrrsum += wrri * yi;
637 m_rrrrsum += wrri * rri;
638 m_nc += a;
639 }
640
641 void TRGCDCLpav::sub(double xi, double yi, double w, double a, double b)
642 {
643//double wi = err_dis_inv(xi, yi, w, a, b);
644 double wi = err_dis_inv(xi, yi, w, a, b);
645 m_wsum -= wi;
646 m_xsum -= wi * xi;
647 m_ysum -= wi * yi;
648 m_xxsum -= wi * xi * xi;
649 m_yysum -= wi * yi * yi;
650 m_xysum -= wi * xi * yi;
651//double rri = ( xi * xi + yi * yi );
652//double wrri = wi * rri;
653 double rri = (xi * xi + yi * yi);
654 double wrri = wi * rri;
655 m_xrrsum -= wrri * xi;
656 m_yrrsum -= wrri * yi;
657 m_rrrrsum -= wrri * rri;
658 m_nc -= 1;
659 }
660
662 {
663 m_wsum += la1.m_wsum;
664 m_xsum += la1.m_xsum;
665 m_ysum += la1.m_ysum;
666 m_xxsum += la1.m_xxsum;
667 m_yysum += la1.m_yysum;
668 m_xysum += la1.m_xysum;
669 m_xrrsum += la1.m_xrrsum;
670 m_yrrsum += la1.m_yrrsum;
671 m_rrrrsum += la1.m_rrrrsum;
672 m_nc += la1.m_nc;
673 return *this;
674 }
675
677#ifdef BELLE_OPTIMIZED_RETURN
678 return la;
679 {
680#else
681 {
682 TRGCDCLpav la;
683#endif
684 la.m_wsum = la1.m_wsum + la2.m_wsum;
685 la.m_xsum = la1.m_xsum + la2.m_xsum;
686 la.m_ysum = la1.m_ysum + la2.m_ysum;
687 la.m_xxsum = la1.m_xxsum + la2.m_xxsum;
688 la.m_yysum = la1.m_yysum + la2.m_yysum;
689 la.m_xysum = la1.m_xysum + la2.m_xysum;
690 la.m_xrrsum = la1.m_xrrsum + la2.m_xrrsum;
691 la.m_yrrsum = la1.m_yrrsum + la2.m_yrrsum;
692 la.m_rrrrsum = la1.m_rrrrsum + la2.m_rrrrsum;
693 la.m_nc = la1.m_nc + la2.m_nc;
694 return la;
695 }
696
697 double TRGCDCLpav::prob() const
698 {
699 if (m_nc <= 3) return 0;
700 if (m_chisq < 0) return 0;
701//cnv float c = m_chisq;
702//cnv int nci = (int)m_nc - 3;
703 // temporarily commented out
704 // double p = (double) prob_(&c, &nci);
705 double p = 0;
706 return p;
707 }
708
709 double TRGCDCLpav::chi_deg() const
710 {
711 if (m_nc <= 3) return -1;
712 else return m_chisq / (m_nc - 3);
713 }
714
715 double TRGCDCLpav::delta_chisq(double x, double y, double w) const
716 {
717 double sim = similarity(x, y);
718 if (sim < 0) return -1;
719 double d = d0(x, y);
720 double delta = sqr(d) * w / (1 + sim * w);
721 return delta;
722 }
723
725} // namespace Belle2
TRGCDCLpar class.
Definition: Lpar.h:35
double m_beta
data members
Definition: Lpar.h:176
double m_kappa
data members
Definition: Lpar.h:180
double m_gamma
data members
Definition: Lpar.h:178
void scale(double s)
private member functions
Definition: Lpar.h:132
double m_alpha
data members
Definition: Lpar.h:174
exception class, no covarience matrix.
Definition: Lpav.h:98
TRGCDCLpav class.
Definition: Lpav.h:31
double m_xsum
data members
Definition: Lpav.h:137
double m_xyavp
data members
Definition: Lpav.h:160
double m_xav
data members
Definition: Lpav.h:156
double m_rrrravp
data members
Definition: Lpav.h:173
double m_xrravp
data members
Definition: Lpav.h:169
double m_rrrrsum
data members
Definition: Lpav.h:151
double m_chisq
data members
Definition: Lpav.h:182
double m_wsum
data members
Definition: Lpav.h:135
double m_sinrot
data members
Definition: Lpav.h:175
double m_cosrot
data members
Definition: Lpav.h:177
double m_nc
data members
Definition: Lpav.h:180
double m_xxsum
data members
Definition: Lpav.h:141
double m_ysum
data members
Definition: Lpav.h:139
double m_xrrsum
data members
Definition: Lpav.h:147
double m_yav
data members
Definition: Lpav.h:158
double m_rscale
data members
Definition: Lpav.h:163
double m_yysum
data members
Definition: Lpav.h:143
double m_yrravp
data members
Definition: Lpav.h:171
double m_xxavp
data members
Definition: Lpav.h:165
double m_xysum
data members
Definition: Lpav.h:145
double m_wsum_temp
data members
Definition: Lpav.h:154
double m_yrrsum
data members
Definition: Lpav.h:149
double m_yyavp
data members
Definition: Lpav.h:167
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
Definition: B2Vector3.h:544
static double err_dis_inv(double x, double y, double w, double a, double b)
distance error
Definition: Lpav.cc:30
void add_point(double x, double y, double w=1)
member functions to add point
Definition: Lpav.cc:602
int extrapolate(double, double &, double &) const
const member function for extrapolation
Definition: Lpav.cc:541
void neg()
member functions
Definition: Lpar.h:242
double d0(double x, double y) const
private const member functions
Definition: Lpar.h:250
void calculate_average(void)
member functions for calculation
Definition: Lpav.cc:127
void calculate_average_n(double xxav, double yyav, double xyav, double xrrav, double yrrav, double rrrrav)
private member function calculate_average_n
Definition: Lpav.cc:145
CLHEP::HepSymMatrix cov(int=0) const
const member function cov
Definition: Lpav.cc:474
double solve_lambda(void)
private member function solve_lambda
Definition: Lpav.cc:282
bool xy(double, double &, double &, int dir=0) const
private const member functions
Definition: Lpar.cc:157
void calculate_average3(void)
member functions for calculation
Definition: Lpav.cc:236
double x(double r) const
private const member functions
Definition: Lpar.cc:174
double fit()
member functions for fit
Definition: Lpav.cc:457
double delta_chisq(double x, double y, double w=1) const
const member function for delta chisq
Definition: Lpav.cc:715
double solve_lambda3(void)
private member function solve_lambda3
Definition: Lpav.cc:319
void rotate(double c, double s)
private member functions
Definition: Lpar.h:222
void sub(double x, double y, double w=1, double a=0, double b=0)
private member functions
Definition: Lpav.cc:641
CLHEP::HepSymMatrix cov_c(int=0) const
const member function cov_c
Definition: Lpav.cc:507
TRGCDCLpav()
Constructor.
Definition: Lpav.cc:49
double calculate_lpar(void)
member functions for calculation
Definition: Lpav.cc:343
double d(double x, double y) const
const member functions
Definition: Lpar.h:255
double calculate_lpar3(void)
member functions for calculation
Definition: Lpav.cc:397
virtual ~TRGCDCLpav()
Destructor.
Definition: Lpav.cc:81
double chi_deg() const
const member function chi_deg
Definition: Lpav.cc:709
double prob() const
const member function prob
Definition: Lpav.cc:697
void clear()
member functions for clear
Definition: Lpav.h:252
double y(double r) const
private const member functions
Definition: Lpar.cc:181
float prob_(float *, int *)
prob function
const TRGCDCLpav & operator+=(const TRGCDCLpav &)
assignment operator(s)
Definition: Lpav.cc:661
double similarity(double, double) const
const member function similarity
Definition: Lpav.cc:575
double phi(double r, int dir=0) const
const member functions
Definition: Lpar.cc:188
void move(double x, double y)
private member functions
Definition: Lpar.h:230
void add_point_frac(double x, double y, double w, double f)
member functions to add point
Definition: Lpav.cc:621
Abstract base class for different kinds of events.