Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MnParabola.h
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
10#ifndef ROOT_Minuit2_MnParabola
11#define ROOT_Minuit2_MnParabola
12
13#include <cmath>
14
15namespace ROOT {
16
17namespace Minuit2 {
18
19/**
20
21This class defines a parabola of the form a*x*x + b*x + c
22
23@author Fred James and Matthias Winkler; comments added by Andras Zsenei
24and Lorenzo Moneta
25
26@ingroup Minuit
27
28 */
29
31
32public:
33 /**
34
35 Constructor that initializes the parabola with its three parameters.
36
37 @param a the coefficient of the quadratic term
38 @param b the coefficient of the linear term
39 @param c the constant
40
41 */
42
43 MnParabola(double a, double b, double c) : fA(a), fB(b), fC(c) {}
44
46
47 /**
48
49 Evaluates the parabola a the point x.
50
51 @param x the coordinate where the parabola needs to be evaluated.
52
53 @return the y coordinate of the parabola corresponding to x.
54
55 */
56
57 double Y(double x) const { return (fA * x * x + fB * x + fC); }
58
59 /**
60
61 Calculates the bigger of the two x values corresponding to the
62 given y Value.
63
64 <p>
65
66 ???????!!!!!!!!! And when there is none?? it looks like it will
67 crash?? what is sqrt (-1.0) ?
68
69 @param y the y Value for which the x Value is to be calculated.
70
71 @return the bigger one of the two corresponding values.
72
73 */
74
75 // ok, at first glance it does not look like the formula for the quadratic
76 // equation, but it is! ;-)
77 double X_pos(double y) const { return (std::sqrt(y / fA + Min() * Min() - fC / fA) + Min()); }
78 // maybe it is worth to check the performance improvement with the below formula??
79 // double X_pos(double y) const {return (std::sqrt(y/fA + fB*fB/(4.*fA*fA) - fC/fA) - fB/(2.*fA));}
80
81 /**
82
83 Calculates the smaller of the two x values corresponding to the
84 given y Value.
85
86 <p>
87
88 ???????!!!!!!!!! And when there is none?? it looks like it will
89 crash?? what is sqrt (-1.0) ?
90
91 @param y the y Value for which the x Value is to be calculated.
92
93 @return the smaller one of the two corresponding values.
94
95 */
96
97 double X_neg(double y) const { return (-std::sqrt(y / fA + Min() * Min() - fC / fA) + Min()); }
98
99 /**
100
101 Calculates the x coordinate of the Minimum of the parabola.
102
103 @return x coordinate of the Minimum.
104
105 */
106
107 double Min() const { return -fB / (2. * fA); }
108
109 /**
110
111 Calculates the y coordinate of the Minimum of the parabola.
112
113 @return y coordinate of the Minimum.
114
115 */
116
117 double YMin() const { return (-fB * fB / (4. * fA) + fC); }
118
119 /**
120
121 Accessor to the coefficient of the quadratic term.
122
123 @return the coefficient of the quadratic term.
124
125 */
126
127 double A() const { return fA; }
128
129 /**
130
131 Accessor to the coefficient of the linear term.
132
133 @return the coefficient of the linear term.
134
135 */
136
137 double B() const { return fB; }
138
139 /**
140
141 Accessor to the coefficient of the constant term.
142
143 @return the coefficient of the constant term.
144
145 */
146
147 double C() const { return fC; }
148
149private:
150 double fA;
151 double fB;
152 double fC;
153};
154
155} // namespace Minuit2
156
157} // namespace ROOT
158
159#endif // ROOT_Minuit2_MnParabola
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
This class defines a parabola of the form a*x*x + b*x + c.
Definition MnParabola.h:30
double X_neg(double y) const
Calculates the smaller of the two x values corresponding to the given y Value.
Definition MnParabola.h:97
double X_pos(double y) const
Calculates the bigger of the two x values corresponding to the given y Value.
Definition MnParabola.h:77
double YMin() const
Calculates the y coordinate of the Minimum of the parabola.
Definition MnParabola.h:117
double B() const
Accessor to the coefficient of the linear term.
Definition MnParabola.h:137
double C() const
Accessor to the coefficient of the constant term.
Definition MnParabola.h:147
double Min() const
Calculates the x coordinate of the Minimum of the parabola.
Definition MnParabola.h:107
double A() const
Accessor to the coefficient of the quadratic term.
Definition MnParabola.h:127
MnParabola(double a, double b, double c)
Constructor that initializes the parabola with its three parameters.
Definition MnParabola.h:43
double Y(double x) const
Evaluates the parabola a the point x.
Definition MnParabola.h:57
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.