Logo ROOT   6.12/07
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.
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 
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
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
double Min() const
Calculates the x coordinate of the Minimum of the parabola.
Definition: MnParabola.h:116
double A() const
Accessor to the coefficient of the quadratic term.
Definition: MnParabola.h:138
double X_neg(double y) const
Calculates the smaller of the two x values corresponding to the given y Value.
Definition: MnParabola.h:105
double YMin() const
Calculates the y coordinate of the Minimum of the parabola.
Definition: MnParabola.h:127
double sqrt(double)
Double_t x[n]
Definition: legend1.C:17
double C() const
Accessor to the coefficient of the constant term.
Definition: MnParabola.h:160
This class defines a parabola of the form a*x*x + b*x + c.
Definition: MnParabola.h:31
double B() const
Accessor to the coefficient of the linear term.
Definition: MnParabola.h:149
auto * a
Definition: textangle.C:12
double X_pos(double y) const
Calculates the bigger of the two x values corresponding to the given y Value.
Definition: MnParabola.h:83
MnParabola(double a, double b, double c)
Constructor that initializes the parabola with its three parameters.
Definition: MnParabola.h:46
Double_t y[n]
Definition: legend1.C:17
double Y(double x) const
Evaluates the parabola a the point x.
Definition: MnParabola.h:62
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630