Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
20namespace 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 // default constructor standard with value/error = 0
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),
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),
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),
61 {
62 assert(min != max);
63 if (min > max) {
64 fLoLimit = max;
65 fUpLimit = min;
66 }
67 }
68
70 : fNum(par.fNum), fValue(par.fValue), fError(par.fError), fConst(par.fConst), fFix(par.fFix),
72 fName(par.fName)
73 {
74 }
75
77 {
78 if (this != &par) {
79 fNum = par.fNum;
80 fName = par.fName;
81 fValue = par.fValue;
82 fError = par.fError;
83 fConst = par.fConst;
84 fFix = par.fFix;
85 fLoLimit = par.fLoLimit;
86 fUpLimit = par.fUpLimit;
89 }
90 return *this;
91 }
92
93 // access methods
94 unsigned int Number() const { return fNum; }
95 // new API returning a string
96 const std::string &GetName() const { return fName; }
97 // return const char * for maintaining backward compatibility
98 const char *Name() const { return fName.c_str(); }
99
100 double Value() const { return fValue; }
101 double Error() const { return fError; }
102
103 // interaction
104 void SetName(const std::string &name) { fName = name; }
105
106 void SetValue(double val) {
107 fValue = val;
108 if (fLoLimValid && val < fLoLimit)
110 else if (fUpLimValid && val > fUpLimit)
112 }
113 void SetError(double err) { fError = err; }
114 void SetLimits(double low, double up)
115 {
116 assert(low != up);
117 fLoLimit = low;
118 fUpLimit = up;
119 fLoLimValid = true;
120 fUpLimValid = true;
121 if (low > up) {
122 fLoLimit = up;
123 fUpLimit = low;
124 }
125 }
126
127 void SetUpperLimit(double up)
128 {
129 fLoLimit = 0.;
130 fUpLimit = up;
131 fLoLimValid = false;
132 fUpLimValid = true;
133 }
134
135 void SetLowerLimit(double low)
136 {
137 fLoLimit = low;
138 fUpLimit = 0.;
139 fLoLimValid = true;
140 fUpLimValid = false;
141 }
142
144 {
145 fLoLimit = 0.;
146 fUpLimit = 0.;
147 fLoLimValid = false;
148 fUpLimValid = false;
149 }
150
151 void Fix() { fFix = true; }
152 void Release() { fFix = false; }
153
154 // state of Parameter (fixed/const/limited)
155 bool IsConst() const { return fConst; }
156 bool IsFixed() const { return fFix; }
157
158 bool HasLimits() const { return fLoLimValid || fUpLimValid; }
159 bool HasLowerLimit() const { return fLoLimValid; }
160 bool HasUpperLimit() const { return fUpLimValid; }
161 double LowerLimit() const { return fLoLimit; }
162 double UpperLimit() const { return fUpLimit; }
163
164private:
165 unsigned int fNum;
166 double fValue;
167 double fError;
168 bool fConst;
169 bool fFix;
170 double fLoLimit;
171 double fUpLimit;
174 std::string fName;
175
176private:
177 // void SetName(const std::string & name) {
178 // int l = std::min(int(strlen(name)), 11);
179 // memset(fName, 0, 11*sizeof(char));
180 // memcpy(fName, name, l*sizeof(char));
181 // fName[10] = '\0';
182 // }
183};
184
185} // namespace Minuit2
186
187} // namespace ROOT
188
189#endif // ROOT_Minuit2_MinuitParameter
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
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
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...