Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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"
12#include "Minuit2/MnPoint.h"
13
14namespace ROOT {
15
16namespace Minuit2 {
17
19{
20 // construct the parabola from 3 points p1,p2,p3
21 double x1 = p1.X();
22 double x2 = p2.X();
23 double x3 = p3.X();
24 double dx12 = x1 - x2;
25 double dx13 = x1 - x3;
26 double dx23 = x2 - x3;
27
28 // std::cout<<"MnParabolaFactory x1, x2, x3: "<<x1<<" "<<x2<<" "<<x3<<std::endl;
29
30 double xm = (x1 + x2 + x3) / 3.;
31 x1 -= xm;
32 x2 -= xm;
33 x3 -= xm;
34
35 double y1 = p1.Y();
36 double y2 = p2.Y();
37 double y3 = p3.Y();
38 // std::cout<<"MnParabolaFactory y1, y2, y3: "<<y1<<" "<<y2<<" "<<y3<<std::endl;
39
40 double a = y1 / (dx12 * dx13) - y2 / (dx12 * dx23) + y3 / (dx13 * dx23);
41 double b = -y1 * (x2 + x3) / (dx12 * dx13) + y2 * (x1 + x3) / (dx12 * dx23) - y3 * (x1 + x2) / (dx13 * dx23);
42 double c = y1 - a * x1 * x1 - b * x1;
43
44 c += xm * (xm * a - b);
45 b -= 2. * xm * a;
46
47 // std::cout<<"a,b,c= "<<a<<" "<<b<<" "<<c<<std::endl;
48 return MnParabola(a, b, c);
49}
50
52{
53 // construct the parabola from 2 points + derivative at first point dxdy1
54 double x1 = p1.X();
55 double xx1 = x1 * x1;
56 double x2 = p2.X();
57 double xx2 = x2 * x2;
58 double y1 = p1.Y();
59 double y12 = p1.Y() - p2.Y();
60
61 double det = xx1 - xx2 - 2. * x1 * (x1 - x2);
62 double a = -(y12 + (x2 - x1) * dxdy1) / det;
63 double b = -(-2. * x1 * y12 + (xx1 - xx2) * dxdy1) / det;
64 double c = y1 - a * xx1 - b * x1;
65
66 return MnParabola(a, b, c);
67}
68
69} // namespace Minuit2
70
71} // namespace ROOT
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
MnParabola operator()(const MnPoint &, const MnPoint &, const MnPoint &) const
This class defines a parabola of the form a*x*x + b*x + c.
Definition MnParabola.h:30
A point in x-y.
Definition MnPoint.h:28
Namespace for new ROOT classes and functions.