Logo ROOT  
Reference Guide
MinuitParameter.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_MinuitParameter
11 #define ROOT_Minuit2_MinuitParameter
12 
13 #include <algorithm>
14 #include <memory>
15 #include <cassert>
16 #include <string>
17 
18 namespace ROOT {
19 
20 namespace Minuit2 {
21 
22 //____________________________________________________________________________
23 /**
24  class for the individual Minuit Parameter with Name and number;
25  contains the input numbers for the minimization or the output result
26  from minimization;
27  possible interactions: Fix/release, set/remove limits, set Value/error;
28 
29  From version 5.20: use string to store the name to avoid limitation of
30  name length of 20 characters
31  */
32 
34 
35 public:
36  // default constructor standard with value/error = 0
38  : fNum(0), fValue(0), fError(0.), fConst(false), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
39  fUpLimValid(false), fName("")
40  {
41  }
42 
43  // constructor for constant Parameter
44  MinuitParameter(unsigned int num, const std::string &name, double val)
45  : fNum(num), fValue(val), fError(0.), fConst(true), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
46  fUpLimValid(false), fName(name)
47  {
48  }
49 
50  // constructor for standard Parameter
51  MinuitParameter(unsigned int num, const std::string &name, double val, double err)
52  : fNum(num), fValue(val), fError(err), fConst(false), fFix(false), fLoLimit(0.), fUpLimit(0.), fLoLimValid(false),
53  fUpLimValid(false), fName(name)
54  {
55  }
56 
57  // constructor for limited Parameter
58  MinuitParameter(unsigned int num, const std::string &name, double val, double err, double min, double max)
59  : fNum(num), fValue(val), fError(err), fConst(false), fFix(false), fLoLimit(min), fUpLimit(max),
60  fLoLimValid(true), fUpLimValid(true), fName(name)
61  {
62  assert(min != max);
63  if (min > max) {
64  fLoLimit = max;
65  fUpLimit = min;
66  }
67  }
68 
70 
72  : fNum(par.fNum), fValue(par.fValue), fError(par.fError), fConst(par.fConst), fFix(par.fFix),
74  fName(par.fName)
75  {
76  }
77 
79  {
80  if (this != &par) {
81  fNum = par.fNum;
82  fName = par.fName;
83  fValue = par.fValue;
84  fError = par.fError;
85  fConst = par.fConst;
86  fFix = par.fFix;
87  fLoLimit = par.fLoLimit;
88  fUpLimit = par.fUpLimit;
91  }
92  return *this;
93  }
94 
95  // access methods
96  unsigned int Number() const { return fNum; }
97  // new API returning a string
98  const std::string &GetName() const { return fName; }
99  // return const char * for mantaining backward compatibility
100  const char *Name() const { return fName.c_str(); }
101 
102  double Value() const { return fValue; }
103  double Error() const { return fError; }
104 
105  // interaction
106  void SetName(const std::string &name) { fName = name; }
107 
108  void SetValue(double val) { fValue = val; }
109  void SetError(double err) { fError = err; }
110  void SetLimits(double low, double up)
111  {
112  assert(low != up);
113  fLoLimit = low;
114  fUpLimit = up;
115  fLoLimValid = true;
116  fUpLimValid = true;
117  if (low > up) {
118  fLoLimit = up;
119  fUpLimit = low;
120  }
121  }
122 
123  void SetUpperLimit(double up)
124  {
125  fLoLimit = 0.;
126  fUpLimit = up;
127  fLoLimValid = false;
128  fUpLimValid = true;
129  }
130 
131  void SetLowerLimit(double low)
132  {
133  fLoLimit = low;
134  fUpLimit = 0.;
135  fLoLimValid = true;
136  fUpLimValid = false;
137  }
138 
140  {
141  fLoLimit = 0.;
142  fUpLimit = 0.;
143  fLoLimValid = false;
144  fUpLimValid = false;
145  }
146 
147  void Fix() { fFix = true; }
148  void Release() { fFix = false; }
149 
150  // state of Parameter (fixed/const/limited)
151  bool IsConst() const { return fConst; }
152  bool IsFixed() const { return fFix; }
153 
154  bool HasLimits() const { return fLoLimValid || fUpLimValid; }
155  bool HasLowerLimit() const { return fLoLimValid; }
156  bool HasUpperLimit() const { return fUpLimValid; }
157  double LowerLimit() const { return fLoLimit; }
158  double UpperLimit() const { return fUpLimit; }
159 
160 private:
161  unsigned int fNum;
162  double fValue;
163  double fError;
164  bool fConst;
165  bool fFix;
166  double fLoLimit;
167  double fUpLimit;
170  std::string fName;
171 
172 private:
173  // void SetName(const std::string & name) {
174  // int l = std::min(int(strlen(name)), 11);
175  // memset(fName, 0, 11*sizeof(char));
176  // memcpy(fName, name, l*sizeof(char));
177  // fName[10] = '\0';
178  // }
179 };
180 
181 } // namespace Minuit2
182 
183 } // namespace ROOT
184 
185 #endif // ROOT_Minuit2_MinuitParameter
ROOT::Minuit2::MinuitParameter
class for the individual Minuit Parameter with Name and number; contains the input numbers for the mi...
Definition: MinuitParameter.h:33
ROOT::Minuit2::MinuitParameter::SetLowerLimit
void SetLowerLimit(double low)
Definition: MinuitParameter.h:131
ROOT::Minuit2::MinuitParameter::UpperLimit
double UpperLimit() const
Definition: MinuitParameter.h:158
ROOT::Minuit2::MinuitParameter::operator=
MinuitParameter & operator=(const MinuitParameter &par)
Definition: MinuitParameter.h:78
ROOT::Minuit2::MinuitParameter::SetError
void SetError(double err)
Definition: MinuitParameter.h:109
ROOT::Minuit2::MinuitParameter::SetLimits
void SetLimits(double low, double up)
Definition: MinuitParameter.h:110
ROOT::Minuit2::MinuitParameter::GetName
const std::string & GetName() const
Definition: MinuitParameter.h:98
ROOT::Minuit2::MinuitParameter::Release
void Release()
Definition: MinuitParameter.h:148
ROOT::Minuit2::MinuitParameter::SetName
void SetName(const std::string &name)
Definition: MinuitParameter.h:106
ROOT::Minuit2::MinuitParameter::HasUpperLimit
bool HasUpperLimit() const
Definition: MinuitParameter.h:156
ROOT::Minuit2::MinuitParameter::Fix
void Fix()
Definition: MinuitParameter.h:147
ROOT::Minuit2::MinuitParameter::~MinuitParameter
~MinuitParameter()
Definition: MinuitParameter.h:69
ROOT::Minuit2::MinuitParameter::fUpLimValid
bool fUpLimValid
Definition: MinuitParameter.h:169
ROOT::Minuit2::MinuitParameter::fConst
bool fConst
Definition: MinuitParameter.h:164
ROOT::Minuit2::MinuitParameter::SetUpperLimit
void SetUpperLimit(double up)
Definition: MinuitParameter.h:123
ROOT::Minuit2::MinuitParameter::IsConst
bool IsConst() const
Definition: MinuitParameter.h:151
ROOT::Minuit2::MinuitParameter::MinuitParameter
MinuitParameter()
Definition: MinuitParameter.h:37
ROOT::Minuit2::MinuitParameter::fLoLimit
double fLoLimit
Definition: MinuitParameter.h:166
ROOT::Minuit2::MinuitParameter::fValue
double fValue
Definition: MinuitParameter.h:162
ROOT::Minuit2::MinuitParameter::fUpLimit
double fUpLimit
Definition: MinuitParameter.h:167
ROOT::Minuit2::MinuitParameter::fError
double fError
Definition: MinuitParameter.h:163
ROOT::Minuit2::MinuitParameter::RemoveLimits
void RemoveLimits()
Definition: MinuitParameter.h:139
ROOT::Minuit2::MinuitParameter::SetValue
void SetValue(double val)
Definition: MinuitParameter.h:108
ROOT::Minuit2::MinuitParameter::IsFixed
bool IsFixed() const
Definition: MinuitParameter.h:152
ROOT::Minuit2::MinuitParameter::Value
double Value() const
Definition: MinuitParameter.h:102
ROOT::Minuit2::MinuitParameter::MinuitParameter
MinuitParameter(unsigned int num, const std::string &name, double val)
Definition: MinuitParameter.h:44
ROOT::Minuit2::MinuitParameter::fFix
bool fFix
Definition: MinuitParameter.h:165
ROOT::Minuit2::MinuitParameter::MinuitParameter
MinuitParameter(const MinuitParameter &par)
Definition: MinuitParameter.h:71
ROOT::Minuit2::MinuitParameter::HasLimits
bool HasLimits() const
Definition: MinuitParameter.h:154
ROOT::Minuit2::MinuitParameter::MinuitParameter
MinuitParameter(unsigned int num, const std::string &name, double val, double err, double min, double max)
Definition: MinuitParameter.h:58
ROOT::Minuit2::MinuitParameter::Error
double Error() const
Definition: MinuitParameter.h:103
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Minuit2::MinuitParameter::LowerLimit
double LowerLimit() const
Definition: MinuitParameter.h:157
ROOT::Minuit2::MinuitParameter::fLoLimValid
bool fLoLimValid
Definition: MinuitParameter.h:168
ROOT::Minuit2::MinuitParameter::fName
std::string fName
Definition: MinuitParameter.h:170
ROOT::Minuit2::MinuitParameter::MinuitParameter
MinuitParameter(unsigned int num, const std::string &name, double val, double err)
Definition: MinuitParameter.h:51
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MinuitParameter::Name
const char * Name() const
Definition: MinuitParameter.h:100
ROOT::Minuit2::MinuitParameter::HasLowerLimit
bool HasLowerLimit() const
Definition: MinuitParameter.h:155
ROOT::Minuit2::MinuitParameter::fNum
unsigned int fNum
Definition: MinuitParameter.h:161
ROOT::Minuit2::MinuitParameter::Number
unsigned int Number() const
Definition: MinuitParameter.h:96