Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/Fit/ParameterSettings.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/mathcore:$Id$
0002 // Author: L. Moneta Thu Sep 21 16:21:48 2006
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 #ifndef ROOT_Fit_ParameterSettings
0012 #define ROOT_Fit_ParameterSettings
0013 
0014 #include <string>
0015 
0016 namespace ROOT::Fit {
0017 
0018 //___________________________________________________________________________________
0019 /**
0020    Class, describing value, limits and step size of the parameters
0021    Provides functionality also to set/retrieve values, step sizes, limits and fix the
0022    parameters.
0023 
0024    To be done: add constraints (equality and inequality) as functions of the parameters
0025 
0026    @ingroup FitMain
0027 */
0028 class ParameterSettings {
0029 
0030 public:
0031 
0032    /**
0033       Default constructor
0034    */
0035    ParameterSettings () {}
0036 
0037 
0038   ///constructor for unlimited named Parameter
0039    ParameterSettings(const std::string & name, double val, double err) :
0040     fValue(val), fStepSize(err),
0041     fName(name)
0042    {}
0043 
0044    ///constructor for double limited Parameter. The given value should be within the given limits [min,max]
0045    ParameterSettings(const std::string &  name, double val, double err,
0046                      double min, double max) :
0047       fValue(val), fStepSize(err),
0048       fName(name)
0049    {
0050       SetLimits(min,max);
0051    }
0052 
0053    ///constructor for fixed Parameter
0054    ParameterSettings(const std::string &  name, double val) :
0055     fValue(val), fStepSize(0), fFix(true),
0056     fName(name)
0057    {}
0058 
0059 
0060 
0061 
0062    /// set value and name (unlimited parameter)
0063    void Set(const std::string & name, double value, double step) {
0064       SetName(name);
0065       SetValue(value);
0066       SetStepSize(step);
0067    }
0068 
0069    /// set a limited parameter. The given value should be within the given limits [min,max]
0070    void Set(const std::string & name, double value, double step, double lower, double upper ) {
0071       SetName(name);
0072       SetValue(value);
0073       SetStepSize(step);
0074       SetLimits(lower,upper);
0075    }
0076 
0077    /// set a fixed parameter
0078    void Set(const std::string & name, double value) {
0079       SetName(name);
0080       SetValue(value);
0081       Fix();
0082    }
0083 
0084    /// return parameter value
0085    double Value() const { return fValue; }
0086    /// return step size
0087    double StepSize() const { return fStepSize; }
0088    /// return lower limit value
0089    double LowerLimit() const {return fLowerLimit;}
0090    /// return upper limit value
0091    double UpperLimit() const {return fUpperLimit;}
0092    /// check if is fixed
0093    bool IsFixed() const { return fFix; }
0094    /// check if parameter has lower limit
0095    bool HasLowerLimit() const {return fHasLowerLimit; }
0096    /// check if parameter has upper limit
0097    bool HasUpperLimit() const {return fHasUpperLimit; }
0098    /// check if is bound
0099    bool IsBound() const {   return fHasLowerLimit || fHasUpperLimit;  }
0100    /// check if is double bound (upper AND lower limit)
0101    bool IsDoubleBound() const { return fHasLowerLimit && fHasUpperLimit;  }
0102    /// return name
0103    const std::string & Name() const { return fName; }
0104 
0105    /** interaction **/
0106 
0107    /// set name
0108    void SetName(const std::string & name ) { fName = name; }
0109 
0110    /// fix  the parameter
0111    void Fix() {fFix = true;}
0112    /// release the parameter
0113    void Release() {fFix = false;}
0114    /// set the value
0115    void SetValue(double val) {fValue = val;}
0116    /// set the step size
0117    void SetStepSize(double err) {fStepSize = err;}
0118    void SetLimits(double low, double up);
0119    /// set a single upper limit
0120    void SetUpperLimit(double up) {
0121     fLowerLimit = 0.;
0122     fUpperLimit = up;
0123     fHasLowerLimit = false;
0124     fHasUpperLimit = true;
0125    }
0126    /// set a single lower limit
0127    void SetLowerLimit(double low) {
0128       fLowerLimit = low;
0129       fUpperLimit = 0.;
0130       fHasLowerLimit = true;
0131       fHasUpperLimit = false;
0132    }
0133 
0134    /// remove all limit
0135    void RemoveLimits() {
0136       fLowerLimit = 0.;
0137       fUpperLimit = 0.;
0138       fHasLowerLimit = false;
0139       fHasUpperLimit = false;
0140    }
0141 
0142 private:
0143 
0144    double fValue = 0.0;          ///< parameter value
0145    double fStepSize = 0.1;       ///< parameter step size (used by minimizer)
0146    bool fFix = false;            ///< flag to control if parameter is fixed
0147    double fLowerLimit = 0.0;     ///< lower parameter limit
0148    double fUpperLimit = 0.0;     ///< upper parameter limit
0149    bool fHasLowerLimit = false;  ///< flag to control lower parameter limit
0150    bool fHasUpperLimit = false;  ///< flag to control upper parameter limit
0151 
0152    std::string fName;    ///< parameter name
0153 };
0154 
0155 } // namespace ROOT::Fit
0156 
0157 #endif /* ROOT_Fit_ParameterSettings */