 ROOT   Reference Guide 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.
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  */
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) ?
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>
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);}
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);}
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;}
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;}
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;}
162 private:
163
164  double fA;
165  double fB;
166  double fC;
167 };
168
169  } // namespace Minuit2
170
171 } // namespace ROOT
173 #endif // ROOT_Minuit2_MnParabola
c
#define c(i)
Definition: RSha256.hxx:119
ROOT::Minuit2::MnParabola::A
double A() const
Accessor to the coefficient of the quadratic term.
Definition: MnParabola.h:150
ROOT::Minuit2::MnParabola::C
double C() const
Accessor to the coefficient of the constant term.
Definition: MnParabola.h:172
ROOT::Minuit2::MnParabola::YMin
double YMin() const
Calculates the y coordinate of the Minimum of the parabola.
Definition: MnParabola.h:139
ROOT::Minuit2::MnParabola::Min
double Min() const
Calculates the x coordinate of the Minimum of the parabola.
Definition: MnParabola.h:128
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Minuit2::MnParabola::X_neg
double X_neg(double y) const
Calculates the smaller of the two x values corresponding to the given y Value.
Definition: MnParabola.h:117
ROOT::Minuit2::MnParabola::fB
double fB
Definition: MnParabola.h:177
ROOT::Minuit2::MnParabola::~MnParabola
~MnParabola()
Definition: MnParabola.h:61
b
#define b(i)
Definition: RSha256.hxx:118
ROOT::Minuit2::MnParabola::X_pos
double X_pos(double y) const
Calculates the bigger of the two x values corresponding to the given y Value.
Definition: MnParabola.h:95
ROOT::Minuit2::MnParabola::fC
double fC
Definition: MnParabola.h:178
a
auto * a
Definition: textangle.C:12
ROOT::Minuit2::MnParabola::MnParabola
MnParabola(double a, double b, double c)
Constructor that initializes the parabola with its three parameters.
Definition: MnParabola.h:58
y
Double_t y[n]
Definition: legend1.C:17
sqrt
double sqrt(double)
ROOT::Minuit2::MnParabola::B
double B() const
Accessor to the coefficient of the linear term.
Definition: MnParabola.h:161
ROOT::Minuit2::MnParabola::fA
double fA
Definition: MnParabola.h:176
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Minuit2::MnParabola::Y
double Y(double x) const
Evaluates the parabola a the point x.
Definition: MnParabola.h:74