00001 // @(#)root/minuit2:$Id: MnParabola.h 23522 2008-04-24 15:09:19Z moneta $ 00002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 00003 00004 /********************************************************************** 00005 * * 00006 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * 00007 * * 00008 **********************************************************************/ 00009 00010 #ifndef ROOT_Minuit2_MnParabola 00011 #define ROOT_Minuit2_MnParabola 00012 00013 #include <math.h> 00014 00015 namespace ROOT { 00016 00017 namespace Minuit2 { 00018 00019 00020 /** 00021 00022 This class defines a parabola of the form a*x*x + b*x + c 00023 00024 @author Fred James and Matthias Winkler; comments added by Andras Zsenei 00025 and Lorenzo Moneta 00026 00027 @ingroup Minuit 00028 00029 */ 00030 00031 class MnParabola { 00032 00033 public: 00034 00035 00036 /** 00037 00038 Constructor that initializes the parabola with its three parameters. 00039 00040 @param a the coefficient of the quadratic term 00041 @param b the coefficient of the linear term 00042 @param c the constant 00043 00044 */ 00045 00046 MnParabola(double a, double b, double c) : fA(a), fB(b), fC(c) {} 00047 00048 00049 ~MnParabola() {} 00050 00051 00052 /** 00053 00054 Evaluates the parabola a the point x. 00055 00056 @param x the coordinate where the parabola needs to be evaluated. 00057 00058 @return the y coordinate of the parabola corresponding to x. 00059 00060 */ 00061 00062 double Y(double x) const {return (fA*x*x + fB*x +fC);} 00063 00064 00065 /** 00066 00067 Calculates the bigger of the two x values corresponding to the 00068 given y Value. 00069 00070 <p> 00071 00072 ???????!!!!!!!!! And when there is none?? it looks like it will 00073 crash?? what is sqrt (-1.0) ? 00074 00075 @param y the y Value for which the x Value is to be calculated. 00076 00077 @return the bigger one of the two corresponding values. 00078 00079 */ 00080 00081 // ok, at first glance it does not look like the formula for the quadratic 00082 // equation, but it is! ;-) 00083 double X_pos(double y) const {return (sqrt(y/fA + Min()*Min() - fC/fA) + Min());} 00084 // maybe it is worth to check the performance improvement with the below formula?? 00085 // double X_pos(double y) const {return (sqrt(y/fA + fB*fB/(4.*fA*fA) - fC/fA) - fB/(2.*fA));} 00086 00087 00088 00089 /** 00090 00091 Calculates the smaller of the two x values corresponding to the 00092 given y Value. 00093 00094 <p> 00095 00096 ???????!!!!!!!!! And when there is none?? it looks like it will 00097 crash?? what is sqrt (-1.0) ? 00098 00099 @param y the y Value for which the x Value is to be calculated. 00100 00101 @return the smaller one of the two corresponding values. 00102 00103 */ 00104 00105 double X_neg(double y) const {return (-sqrt(y/fA + Min()*Min() - fC/fA) + Min());} 00106 00107 00108 /** 00109 00110 Calculates the x coordinate of the Minimum of the parabola. 00111 00112 @return x coordinate of the Minimum. 00113 00114 */ 00115 00116 double Min() const {return -fB/(2.*fA);} 00117 00118 00119 /** 00120 00121 Calculates the y coordinate of the Minimum of the parabola. 00122 00123 @return y coordinate of the Minimum. 00124 00125 */ 00126 00127 double YMin() const {return (-fB*fB/(4.*fA) + fC);} 00128 00129 00130 /** 00131 00132 Accessor to the coefficient of the quadratic term. 00133 00134 @return the coefficient of the quadratic term. 00135 00136 */ 00137 00138 double A() const {return fA;} 00139 00140 00141 /** 00142 00143 Accessor to the coefficient of the linear term. 00144 00145 @return the coefficient of the linear term. 00146 00147 */ 00148 00149 double B() const {return fB;} 00150 00151 00152 /** 00153 00154 Accessor to the coefficient of the constant term. 00155 00156 @return the coefficient of the constant term. 00157 00158 */ 00159 00160 double C() const {return fC;} 00161 00162 private: 00163 00164 double fA; 00165 double fB; 00166 double fC; 00167 }; 00168 00169 } // namespace Minuit2 00170 00171 } // namespace ROOT 00172 00173 #endif // ROOT_Minuit2_MnParabola