00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "Minuit2/MnParabolaFactory.h"
00011 #include "Minuit2/MnParabola.h"
00012 #include "Minuit2/MnParabolaPoint.h"
00013
00014 namespace ROOT {
00015
00016 namespace Minuit2 {
00017
00018
00019
00020
00021 MnParabola MnParabolaFactory::operator()(const MnParabolaPoint& p1,
00022 const MnParabolaPoint& p2,
00023 const MnParabolaPoint& p3) const {
00024
00025 double x1 = p1.X();
00026 double x2 = p2.X();
00027 double x3 = p3.X();
00028 double dx12 = x1-x2;
00029 double dx13 = x1-x3;
00030 double dx23 = x2-x3;
00031
00032
00033
00034 double xm = (x1+x2+x3)/3.;
00035 x1 -= xm;
00036 x2 -= xm;
00037 x3 -= xm;
00038
00039 double y1 = p1.Y();
00040 double y2 = p2.Y();
00041 double y3 = p3.Y();
00042
00043
00044 double a = y1/(dx12*dx13) - y2/(dx12*dx23) + y3/(dx13*dx23);
00045 double b = -y1*(x2+x3)/(dx12*dx13) + y2*(x1+x3)/(dx12*dx23) - y3*(x1+x2)/(dx13*dx23);
00046 double c = y1 - a*x1*x1 - b*x1;
00047
00048 c += xm*(xm*a - b);
00049 b -= 2.*xm*a;
00050
00051
00052 return MnParabola(a, b, c);
00053 }
00054
00055 MnParabola MnParabolaFactory::operator()(const MnParabolaPoint& p1,
00056 double dxdy1,
00057 const MnParabolaPoint& p2) const {
00058
00059 double x1 = p1.X();
00060 double xx1 = x1*x1;
00061 double x2 = p2.X();
00062 double xx2 = x2*x2;
00063 double y1 = p1.Y();
00064 double y12 = p1.Y() - p2.Y();
00065
00066 double det = xx1-xx2 - 2.*x1*(x1-x2);
00067 double a = -( y12 + (x2-x1)*dxdy1)/det;
00068 double b = -( -2.*x1*y12 + (xx1-xx2)*dxdy1)/det;
00069 double c = y1 - a*xx1 - b*x1;
00070
00071 return MnParabola(a, b, c);
00072 }
00073
00074
00075 }
00076
00077 }