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
16 namespace Minuit2 {
17
18
19// #include <iostream>
20
22 const MnParabolaPoint& p2,
23 const MnParabolaPoint& p3) const {
24 // construct the parabola from 3 points p1,p2,p3
25 double x1 = p1.X();
26 double x2 = p2.X();
27 double x3 = p3.X();
28 double dx12 = x1-x2;
29 double dx13 = x1-x3;
30 double dx23 = x2-x3;
31
32 // std::cout<<"MnParabolaFactory x1, x2, x3: "<<x1<<" "<<x2<<" "<<x3<<std::endl;
33
34 double xm = (x1+x2+x3)/3.;
35 x1 -= xm;
36 x2 -= xm;
37 x3 -= xm;
38
39 double y1 = p1.Y();
40 double y2 = p2.Y();
41 double y3 = p3.Y();
42 // std::cout<<"MnParabolaFactory y1, y2, y3: "<<y1<<" "<<y2<<" "<<y3<<std::endl;
43
44 double a = y1/(dx12*dx13) - y2/(dx12*dx23) + y3/(dx13*dx23);
45 double b = -y1*(x2+x3)/(dx12*dx13) + y2*(x1+x3)/(dx12*dx23) - y3*(x1+x2)/(dx13*dx23);
46 double c = y1 - a*x1*x1 - b*x1;
47
48 c += xm*(xm*a - b);
49 b -= 2.*xm*a;
50
51 // std::cout<<"a,b,c= "<<a<<" "<<b<<" "<<c<<std::endl;
52 return MnParabola(a, b, c);
53}
54
56 double dxdy1,
57 const MnParabolaPoint& p2) const {
58 // construct the parabola from 2 points + derivative at first point dxdy1
59 double x1 = p1.X();
60 double xx1 = x1*x1;
61 double x2 = p2.X();
62 double xx2 = x2*x2;
63 double y1 = p1.Y();
64 double y12 = p1.Y() - p2.Y();
65
66 double det = xx1-xx2 - 2.*x1*(x1-x2);
67 double a = -( y12 + (x2-x1)*dxdy1)/det;
68 double b = -( -2.*x1*y12 + (xx1-xx2)*dxdy1)/det;
69 double c = y1 - a*xx1 - b*x1;
70
71 return MnParabola(a, b, c);
72}
73
74
75 } // namespace Minuit2
76
77} // 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:31
VSD Structures.
Definition: StringConv.hxx:21
auto * a
Definition: textangle.C:12