Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:25

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_MnParabola
0011 #define ROOT_Minuit2_MnParabola
0012 
0013 #include <cmath>
0014 
0015 namespace ROOT {
0016 
0017 namespace Minuit2 {
0018 
0019 /**
0020 
0021 This class defines a parabola of the form a*x*x + b*x + c
0022 
0023 @author Fred James and Matthias Winkler; comments added by Andras Zsenei
0024 and Lorenzo Moneta
0025 
0026 @ingroup Minuit
0027 
0028  */
0029 
0030 class MnParabola {
0031 
0032 public:
0033    /**
0034 
0035    Constructor that initializes the parabola with its three parameters.
0036 
0037    @param a the coefficient of the quadratic term
0038    @param b the coefficient of the linear term
0039    @param c the constant
0040 
0041    */
0042 
0043    MnParabola(double a, double b, double c) : fA(a), fB(b), fC(c) {}
0044 
0045    ~MnParabola() {}
0046 
0047    /**
0048 
0049    Evaluates the parabola a the point x.
0050 
0051    @param x the coordinate where the parabola needs to be evaluated.
0052 
0053    @return the y coordinate of the parabola corresponding to x.
0054 
0055    */
0056 
0057    double Y(double x) const { return (fA * x * x + fB * x + fC); }
0058 
0059    /**
0060 
0061    Calculates the bigger of the two x values corresponding to the
0062    given y Value.
0063 
0064    <p>
0065 
0066    ???????!!!!!!!!! And when there is none?? it looks like it will
0067    crash?? what is sqrt (-1.0) ?
0068 
0069    @param y the y Value for which the x Value is to be calculated.
0070 
0071    @return the bigger one of the two corresponding values.
0072 
0073    */
0074 
0075    // ok, at first glance it does not look like the formula for the quadratic
0076    // equation, but it is!  ;-)
0077    double X_pos(double y) const { return (std::sqrt(y / fA + Min() * Min() - fC / fA) + Min()); }
0078    // maybe it is worth to check the performance improvement with the below formula??
0079    //   double X_pos(double y) const {return (std::sqrt(y/fA + fB*fB/(4.*fA*fA) - fC/fA)  - fB/(2.*fA));}
0080 
0081    /**
0082 
0083    Calculates the smaller of the two x values corresponding to the
0084    given y Value.
0085 
0086    <p>
0087 
0088    ???????!!!!!!!!! And when there is none?? it looks like it will
0089    crash?? what is sqrt (-1.0) ?
0090 
0091    @param y the y Value for which the x Value is to be calculated.
0092 
0093    @return the smaller one of the two corresponding values.
0094 
0095    */
0096 
0097    double X_neg(double y) const { return (-std::sqrt(y / fA + Min() * Min() - fC / fA) + Min()); }
0098 
0099    /**
0100 
0101    Calculates the x coordinate of the Minimum of the parabola.
0102 
0103    @return x coordinate of the Minimum.
0104 
0105    */
0106 
0107    double Min() const { return -fB / (2. * fA); }
0108 
0109    /**
0110 
0111    Calculates the y coordinate of the Minimum of the parabola.
0112 
0113    @return y coordinate of the Minimum.
0114 
0115    */
0116 
0117    double YMin() const { return (-fB * fB / (4. * fA) + fC); }
0118 
0119    /**
0120 
0121    Accessor to the coefficient of the quadratic term.
0122 
0123    @return the coefficient of the quadratic term.
0124 
0125     */
0126 
0127    double A() const { return fA; }
0128 
0129    /**
0130 
0131    Accessor to the coefficient of the linear term.
0132 
0133    @return the coefficient of the linear term.
0134 
0135    */
0136 
0137    double B() const { return fB; }
0138 
0139    /**
0140 
0141    Accessor to the coefficient of the constant term.
0142 
0143    @return the coefficient of the constant term.
0144 
0145    */
0146 
0147    double C() const { return fC; }
0148 
0149 private:
0150    double fA;
0151    double fB;
0152    double fC;
0153 };
0154 
0155 } // namespace Minuit2
0156 
0157 } // namespace ROOT
0158 
0159 #endif // ROOT_Minuit2_MnParabola