BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
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 <math.h>
14
15
namespace
ROOT
{
16
17
namespace
Minuit2 {
18
19
20
/**
21
22
This class defines a parabola of the form a*x*x + b*x + c
23
24
@author Fred James and Matthias Winkler; comments added by Andras Zsenei
25
and Lorenzo Moneta
26
27
@ingroup Minuit
28
29
*/
30
31
class
MnParabola
{
32
33
public
:
34
35
36
/**
37
38
Constructor that initializes the parabola with its three parameters.
39
40
@param a the coefficient of the quadratic term
41
@param b the coefficient of the linear term
42
@param c the constant
43
44
*/
45
46
MnParabola
(
double
a,
double
b,
double
c) :
fA
(a),
fB
(b),
fC
(c) {}
47
48
49
~MnParabola
() {}
50
51
52
/**
53
54
Evaluates the parabola a the point x.
55
56
@param x the coordinate where the parabola needs to be evaluated.
57
58
@return the y coordinate of the parabola corresponding to x.
59
60
*/
61
62
double
Y
(
double
x)
const
{
return
(
fA
*x*x +
fB
*x +
fC
);}
63
64
65
/**
66
67
Calculates the bigger of the two x values corresponding to the
68
given y Value.
69
70
<p>
71
72
???????!!!!!!!!! And when there is none?? it looks like it will
73
crash?? what is sqrt (-1.0) ?
74
75
@param y the y Value for which the x Value is to be calculated.
76
77
@return the bigger one of the two corresponding values.
78
79
*/
80
81
// ok, at first glance it does not look like the formula for the quadratic
82
// equation, but it is! ;-)
83
double
X_pos
(
double
y)
const
{
return
(sqrt(y/
fA
+
Min
()*
Min
() -
fC
/
fA
) +
Min
());}
84
// maybe it is worth to check the performance improvement with the below formula??
85
// double X_pos(double y) const {return (sqrt(y/fA + fB*fB/(4.*fA*fA) - fC/fA) - fB/(2.*fA));}
86
87
88
89
/**
90
91
Calculates the smaller of the two x values corresponding to the
92
given y Value.
93
94
<p>
95
96
???????!!!!!!!!! And when there is none?? it looks like it will
97
crash?? what is sqrt (-1.0) ?
98
99
@param y the y Value for which the x Value is to be calculated.
100
101
@return the smaller one of the two corresponding values.
102
103
*/
104
105
double
X_neg
(
double
y)
const
{
return
(-sqrt(y/
fA
+
Min
()*
Min
() -
fC
/
fA
) +
Min
());}
106
107
108
/**
109
110
Calculates the x coordinate of the Minimum of the parabola.
111
112
@return x coordinate of the Minimum.
113
114
*/
115
116
double
Min
()
const
{
return
-
fB
/(2.*
fA
);}
117
118
119
/**
120
121
Calculates the y coordinate of the Minimum of the parabola.
122
123
@return y coordinate of the Minimum.
124
125
*/
126
127
double
YMin
()
const
{
return
(-
fB
*
fB
/(4.*
fA
) +
fC
);}
128
129
130
/**
131
132
Accessor to the coefficient of the quadratic term.
133
134
@return the coefficient of the quadratic term.
135
136
*/
137
138
double
A
()
const
{
return
fA
;}
139
140
141
/**
142
143
Accessor to the coefficient of the linear term.
144
145
@return the coefficient of the linear term.
146
147
*/
148
149
double
B
()
const
{
return
fB
;}
150
151
152
/**
153
154
Accessor to the coefficient of the constant term.
155
156
@return the coefficient of the constant term.
157
158
*/
159
160
double
C
()
const
{
return
fC
;}
161
162
private
:
163
164
double
fA
;
165
double
fB
;
166
double
fC
;
167
};
168
169
}
// namespace Minuit2
170
171
}
// namespace ROOT
172
173
#endif
// ROOT_Minuit2_MnParabola
ROOT::Minuit2::MnParabola
Definition:
MnParabola.h:31
ROOT::Minuit2::MnParabola::X_neg
double X_neg(double y) const
Definition:
MnParabola.h:105
ROOT::Minuit2::MnParabola::X_pos
double X_pos(double y) const
Definition:
MnParabola.h:83
ROOT::Minuit2::MnParabola::fC
double fC
Definition:
MnParabola.h:166
ROOT::Minuit2::MnParabola::YMin
double YMin() const
Definition:
MnParabola.h:127
ROOT::Minuit2::MnParabola::B
double B() const
Definition:
MnParabola.h:149
ROOT::Minuit2::MnParabola::C
double C() const
Definition:
MnParabola.h:160
ROOT::Minuit2::MnParabola::fB
double fB
Definition:
MnParabola.h:165
ROOT::Minuit2::MnParabola::fA
double fA
Definition:
MnParabola.h:164
ROOT::Minuit2::MnParabola::Min
double Min() const
Definition:
MnParabola.h:116
ROOT::Minuit2::MnParabola::A
double A() const
Definition:
MnParabola.h:138
ROOT::Minuit2::MnParabola::~MnParabola
~MnParabola()
Definition:
MnParabola.h:49
ROOT::Minuit2::MnParabola::MnParabola
MnParabola(double a, double b, double c)
Definition:
MnParabola.h:46
ROOT::Minuit2::MnParabola::Y
double Y(double x) const
Definition:
MnParabola.h:62
ROOT
Definition:
TUUID.h:7
Fit
3rdparty
RootMinimizers
Minuit2
MnParabola.h
Generated by
1.9.1