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
18namespace 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
35public:
36
37 //default constructor standard with value/error = 0
39 fNum(0), fValue(0), fError(0.), fConst(false), fFix(false),
40 fLoLimit(0.), fUpLimit(0.), fLoLimValid(false), fUpLimValid(false),
41 fName("")
42 {}
43
44 //constructor for constant Parameter
45 MinuitParameter(unsigned int num, const std::string & name, double val) :
46 fNum(num), fValue(val), fError(0.), fConst(true), fFix(false),
47 fLoLimit(0.), fUpLimit(0.), fLoLimValid(false), fUpLimValid(false),
48 fName(name)
49 {}
50
51 //constructor for standard Parameter
52 MinuitParameter(unsigned int num, const std::string & name, double val, double err) :
53 fNum(num), fValue(val), fError(err), fConst(false), fFix(false),
54 fLoLimit(0.), fUpLimit(0.), fLoLimValid(false), fUpLimValid(false),
55 fName(name)
56 {}
57
58 //constructor for limited Parameter
59 MinuitParameter(unsigned int num, const std::string & name, double val, double err,
60 double min, double max) :
61 fNum(num),fValue(val), fError(err), fConst(false), fFix(false),
62 fLoLimit(min), fUpLimit(max), fLoLimValid(true), fUpLimValid(true),
63 fName(name)
64 {
65 assert(min != max);
66 if(min > max) {
67 fLoLimit = max;
68 fUpLimit = min;
69 }
70 }
71
73
75 fNum(par.fNum), fValue(par.fValue), fError(par.fError),
76 fConst(par.fConst), fFix(par.fFix), fLoLimit(par.fLoLimit),
79 fName(par.fName )
80 {}
81
83 if(this != &par) {
84 fNum = par.fNum;
85 fName = par.fName;
86 fValue = par.fValue;
87 fError = par.fError;
88 fConst = par.fConst;
89 fFix = par.fFix;
90 fLoLimit = par.fLoLimit;
91 fUpLimit = par.fUpLimit;
94 }
95 return *this;
96 }
97
98 //access methods
99 unsigned int Number() const {return fNum;}
100 // new API returning a string
101 const std::string & GetName() const { return fName; }
102 // return const char * for mantaining backward compatibility
103 const char * Name() const {return fName.c_str();}
104
105 double Value() const {return fValue;}
106 double Error() const {return fError;}
107
108 //interaction
109 void SetName(const std::string &name) { fName = name; }
110
111 void SetValue(double val) {fValue = val;}
112 void SetError(double err) {fError = err;}
113 void SetLimits(double low, double up) {
114 assert(low != up);
115 fLoLimit = low;
116 fUpLimit = up;
117 fLoLimValid = true;
118 fUpLimValid = true;
119 if(low > up) {
120 fLoLimit = up;
121 fUpLimit = low;
122 }
123 }
124
125 void SetUpperLimit(double up) {
126 fLoLimit = 0.;
127 fUpLimit = up;
128 fLoLimValid = false;
129 fUpLimValid = true;
130 }
131
132 void SetLowerLimit(double low) {
133 fLoLimit = low;
134 fUpLimit = 0.;
135 fLoLimValid = true;
136 fUpLimValid = false;
137 }
138
140 fLoLimit = 0.;
141 fUpLimit = 0.;
142 fLoLimValid = false;
143 fUpLimValid = false;
144 }
145
146 void Fix() {fFix = true;}
147 void Release() {fFix = false;}
148
149 //state of Parameter (fixed/const/limited)
150 bool IsConst() const {return fConst;}
151 bool IsFixed() const {return fFix;}
152
153 bool HasLimits() const {return fLoLimValid || fUpLimValid; }
154 bool HasLowerLimit() const {return fLoLimValid; }
155 bool HasUpperLimit() const {return fUpLimValid; }
156 double LowerLimit() const {return fLoLimit;}
157 double UpperLimit() const {return fUpLimit;}
158
159private:
160
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
172private:
173
174// void SetName(const std::string & name) {
175// int l = std::min(int(strlen(name)), 11);
176// memset(fName, 0, 11*sizeof(char));
177// memcpy(fName, name, l*sizeof(char));
178// fName[10] = '\0';
179// }
180
181};
182
183 } // namespace Minuit2
184
185} // namespace ROOT
186
187#endif // ROOT_Minuit2_MinuitParameter
char name[80]
Definition: TGX11.cxx:109
class for the individual Minuit Parameter with Name and number; contains the input numbers for the mi...
MinuitParameter(const MinuitParameter &par)
MinuitParameter(unsigned int num, const std::string &name, double val, double err, double min, double max)
void SetName(const std::string &name)
MinuitParameter(unsigned int num, const std::string &name, double val, double err)
const std::string & GetName() const
unsigned int Number() const
MinuitParameter & operator=(const MinuitParameter &par)
void SetLimits(double low, double up)
MinuitParameter(unsigned int num, const std::string &name, double val)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21