Logo ROOT  
Reference Guide
MnParabolaFactory.cxx
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
11#include "Minuit2/MnParabola.h"
13
14namespace ROOT {
15
16namespace Minuit2 {
17
19operator()(const MnParabolaPoint &p1, const MnParabolaPoint &p2, const MnParabolaPoint &p3) const
20{
21 // construct the parabola from 3 points p1,p2,p3
22 double x1 = p1.X();
23 double x2 = p2.X();
24 double x3 = p3.X();
25 double dx12 = x1 - x2;
26 double dx13 = x1 - x3;
27 double dx23 = x2 - x3;
28
29 // std::cout<<"MnParabolaFactory x1, x2, x3: "<<x1<<" "<<x2<<" "<<x3<<std::endl;
30
31 double xm = (x1 + x2 + x3) / 3.;
32 x1 -= xm;
33 x2 -= xm;
34 x3 -= xm;
35
36 double y1 = p1.Y();
37 double y2 = p2.Y();
38 double y3 = p3.Y();
39 // std::cout<<"MnParabolaFactory y1, y2, y3: "<<y1<<" "<<y2<<" "<<y3<<std::endl;
40
41 double a = y1 / (dx12 * dx13) - y2 / (dx12 * dx23) + y3 / (dx13 * dx23);
42 double b = -y1 * (x2 + x3) / (dx12 * dx13) + y2 * (x1 + x3) / (dx12 * dx23) - y3 * (x1 + x2) / (dx13 * dx23);
43 double c = y1 - a * x1 * x1 - b * x1;
44
45 c += xm * (xm * a - b);
46 b -= 2. * xm * a;
47
48 // std::cout<<"a,b,c= "<<a<<" "<<b<<" "<<c<<std::endl;
49 return MnParabola(a, b, c);
50}
51
53{
54 // construct the parabola from 2 points + derivative at first point dxdy1
55 double x1 = p1.X();
56 double xx1 = x1 * x1;
57 double x2 = p2.X();
58 double xx2 = x2 * x2;
59 double y1 = p1.Y();
60 double y12 = p1.Y() - p2.Y();
61
62 double det = xx1 - xx2 - 2. * x1 * (x1 - x2);
63 double a = -(y12 + (x2 - x1) * dxdy1) / det;
64 double b = -(-2. * x1 * y12 + (xx1 - xx2) * dxdy1) / det;
65 double c = y1 - a * xx1 - b * x1;
66
67 return MnParabola(a, b, c);
68}
69
70} // namespace Minuit2
71
72} // namespace ROOT
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
static const double x2[5]
static const double x1[5]
static const double x3[11]
MnParabola operator()(const MnParabolaPoint &, const MnParabolaPoint &, const MnParabolaPoint &) const
A point of a parabola.
double Y() const
Accessor to the y (second) coordinate.
double X() const
Accessor to the x (first) coordinate.
This class defines a parabola of the form a*x*x + b*x + c.
Definition: MnParabola.h:30
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: RNumpyDS.hxx:30
auto * a
Definition: textangle.C:12