File indexing completed on 2025-01-18 10:10:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ROOT_Minuit2_MinuitParameter
0011 #define ROOT_Minuit2_MinuitParameter
0012
0013 #include <algorithm>
0014 #include <memory>
0015 #include <cassert>
0016 #include <string>
0017
0018 namespace ROOT {
0019
0020 namespace Minuit2 {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class MinuitParameter {
0034
0035 public:
0036
0037 MinuitParameter()
0038 : fNum(0), fValue(0), fError(0.), fConst(false), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
0039 fUpLimValid(false), fName("")
0040 {
0041 }
0042
0043
0044 MinuitParameter(unsigned int num, const std::string &name, double val)
0045 : fNum(num), fValue(val), fError(0.), fConst(true), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
0046 fUpLimValid(false), fName(name)
0047 {
0048 }
0049
0050
0051 MinuitParameter(unsigned int num, const std::string &name, double val, double err)
0052 : fNum(num), fValue(val), fError(err), fConst(false), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
0053 fUpLimValid(false), fName(name)
0054 {
0055 }
0056
0057
0058 MinuitParameter(unsigned int num, const std::string &name, double val, double err, double min, double max)
0059 : fNum(num), fValue(val), fError(err), fConst(false), fFix(false), fLoLimit(min), fUpLimit(max),
0060 fLoLimValid(true), fUpLimValid(true), fName(name)
0061 {
0062 assert(min != max);
0063 if (min > max) {
0064 fLoLimit = max;
0065 fUpLimit = min;
0066 }
0067 }
0068
0069 ~MinuitParameter() {}
0070
0071 MinuitParameter(const MinuitParameter &par)
0072 : fNum(par.fNum), fValue(par.fValue), fError(par.fError), fConst(par.fConst), fFix(par.fFix),
0073 fLoLimit(par.fLoLimit), fUpLimit(par.fUpLimit), fLoLimValid(par.fLoLimValid), fUpLimValid(par.fUpLimValid),
0074 fName(par.fName)
0075 {
0076 }
0077
0078 MinuitParameter &operator=(const MinuitParameter &par)
0079 {
0080 if (this != &par) {
0081 fNum = par.fNum;
0082 fName = par.fName;
0083 fValue = par.fValue;
0084 fError = par.fError;
0085 fConst = par.fConst;
0086 fFix = par.fFix;
0087 fLoLimit = par.fLoLimit;
0088 fUpLimit = par.fUpLimit;
0089 fLoLimValid = par.fLoLimValid;
0090 fUpLimValid = par.fUpLimValid;
0091 }
0092 return *this;
0093 }
0094
0095
0096 unsigned int Number() const { return fNum; }
0097
0098 const std::string &GetName() const { return fName; }
0099
0100 const char *Name() const { return fName.c_str(); }
0101
0102 double Value() const { return fValue; }
0103 double Error() const { return fError; }
0104
0105
0106 void SetName(const std::string &name) { fName = name; }
0107
0108 void SetValue(double val) { fValue = val; }
0109 void SetError(double err) { fError = err; }
0110 void SetLimits(double low, double up)
0111 {
0112 assert(low != up);
0113 fLoLimit = low;
0114 fUpLimit = up;
0115 fLoLimValid = true;
0116 fUpLimValid = true;
0117 if (low > up) {
0118 fLoLimit = up;
0119 fUpLimit = low;
0120 }
0121 }
0122
0123 void SetUpperLimit(double up)
0124 {
0125 fLoLimit = 0.;
0126 fUpLimit = up;
0127 fLoLimValid = false;
0128 fUpLimValid = true;
0129 }
0130
0131 void SetLowerLimit(double low)
0132 {
0133 fLoLimit = low;
0134 fUpLimit = 0.;
0135 fLoLimValid = true;
0136 fUpLimValid = false;
0137 }
0138
0139 void RemoveLimits()
0140 {
0141 fLoLimit = 0.;
0142 fUpLimit = 0.;
0143 fLoLimValid = false;
0144 fUpLimValid = false;
0145 }
0146
0147 void Fix() { fFix = true; }
0148 void Release() { fFix = false; }
0149
0150
0151 bool IsConst() const { return fConst; }
0152 bool IsFixed() const { return fFix; }
0153
0154 bool HasLimits() const { return fLoLimValid || fUpLimValid; }
0155 bool HasLowerLimit() const { return fLoLimValid; }
0156 bool HasUpperLimit() const { return fUpLimValid; }
0157 double LowerLimit() const { return fLoLimit; }
0158 double UpperLimit() const { return fUpLimit; }
0159
0160 private:
0161 unsigned int fNum;
0162 double fValue;
0163 double fError;
0164 bool fConst;
0165 bool fFix;
0166 double fLoLimit;
0167 double fUpLimit;
0168 bool fLoLimValid;
0169 bool fUpLimValid;
0170 std::string fName;
0171
0172 private:
0173
0174
0175
0176
0177
0178
0179 };
0180
0181 }
0182
0183 }
0184
0185 #endif