MnParabolaFactory.cxx

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: MnParabolaFactory.cxx 23522 2008-04-24 15:09:19Z moneta $
00002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005  
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
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 // #include <iostream>
00020 
00021 MnParabola MnParabolaFactory::operator()(const MnParabolaPoint& p1, 
00022                                          const MnParabolaPoint& p2, 
00023                                          const MnParabolaPoint& p3) const {
00024    // construct the parabola from 3 points p1,p2,p3                                      
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    //   std::cout<<"MnParabolaFactory x1, x2, x3: "<<x1<<" "<<x2<<" "<<x3<<std::endl;
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    //   std::cout<<"MnParabolaFactory y1, y2, y3: "<<y1<<" "<<y2<<" "<<y3<<std::endl;
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    //   std::cout<<"a,b,c= "<<a<<" "<<b<<" "<<c<<std::endl;
00052    return MnParabola(a, b, c);
00053 }
00054 
00055 MnParabola MnParabolaFactory::operator()(const MnParabolaPoint& p1, 
00056                                          double dxdy1, 
00057                                          const MnParabolaPoint& p2) const {
00058    // construct the parabola from 2 points + derivative at first point dxdy1
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    }  // namespace Minuit2
00076 
00077 }  // namespace ROOT

Generated on Tue Jul 5 14:37:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1