Logo ROOT  
Reference Guide
 
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
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
160private:
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 // 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
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)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.