Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParameterSettings.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Thu Sep 21 16:21:48 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11#ifndef ROOT_Fit_ParameterSettings
12#define ROOT_Fit_ParameterSettings
13
14#include <string>
15
16namespace ROOT::Fit {
17
18//___________________________________________________________________________________
19/**
20 Class, describing value, limits and step size of the parameters
21 Provides functionality also to set/retrieve values, step sizes, limits and fix the
22 parameters.
23
24 To be done: add constraints (equality and inequality) as functions of the parameters
25
26 @ingroup FitMain
27*/
29
30public:
31
32 /**
33 Default constructor
34 */
36
37
38 ///constructor for unlimited named Parameter
39 ParameterSettings(const std::string & name, double val, double err) :
40 fValue(val), fStepSize(err),
41 fName(name)
42 {}
43
44 ///constructor for double limited Parameter. The given value should be within the given limits [min,max]
45 ParameterSettings(const std::string & name, double val, double err,
46 double min, double max) :
47 fValue(val), fStepSize(err),
48 fName(name)
49 {
50 SetLimits(min,max);
51 }
52
53 ///constructor for fixed Parameter
54 ParameterSettings(const std::string & name, double val) :
55 fValue(val), fStepSize(0), fFix(true),
56 fName(name)
57 {}
58
59
60
61
62 /// set value and name (unlimited parameter)
63 void Set(const std::string & name, double value, double step) {
66 SetStepSize(step);
67 }
68
69 /// set a limited parameter. The given value should be within the given limits [min,max]
70 void Set(const std::string & name, double value, double step, double lower, double upper ) {
73 SetStepSize(step);
75 }
76
77 /// set a fixed parameter
78 void Set(const std::string & name, double value) {
81 Fix();
82 }
83
84 /// return parameter value
85 double Value() const { return fValue; }
86 /// return step size
87 double StepSize() const { return fStepSize; }
88 /// return lower limit value
89 double LowerLimit() const {return fLowerLimit;}
90 /// return upper limit value
91 double UpperLimit() const {return fUpperLimit;}
92 /// check if is fixed
93 bool IsFixed() const { return fFix; }
94 /// check if parameter has lower limit
95 bool HasLowerLimit() const {return fHasLowerLimit; }
96 /// check if parameter has upper limit
97 bool HasUpperLimit() const {return fHasUpperLimit; }
98 /// check if is bound
99 bool IsBound() const { return fHasLowerLimit || fHasUpperLimit; }
100 /// check if is double bound (upper AND lower limit)
101 bool IsDoubleBound() const { return fHasLowerLimit && fHasUpperLimit; }
102 /// return name
103 const std::string & Name() const { return fName; }
104
105 /** interaction **/
106
107 /// set name
108 void SetName(const std::string & name ) { fName = name; }
109
110 /// fix the parameter
111 void Fix() {fFix = true;}
112 /// release the parameter
113 void Release() {fFix = false;}
114 /// set the value
115 void SetValue(double val) {fValue = val;}
116 /// set the step size
117 void SetStepSize(double err) {fStepSize = err;}
118 void SetLimits(double low, double up);
119 /// set a single upper limit
120 void SetUpperLimit(double up) {
121 fLowerLimit = 0.;
122 fUpperLimit = up;
123 fHasLowerLimit = false;
124 fHasUpperLimit = true;
125 }
126 /// set a single lower limit
127 void SetLowerLimit(double low) {
128 fLowerLimit = low;
129 fUpperLimit = 0.;
130 fHasLowerLimit = true;
131 fHasUpperLimit = false;
132 }
133
134 /// remove all limit
136 fLowerLimit = 0.;
137 fUpperLimit = 0.;
138 fHasLowerLimit = false;
139 fHasUpperLimit = false;
140 }
141
142private:
143
144 double fValue = 0.0; ///< parameter value
145 double fStepSize = 0.1; ///< parameter step size (used by minimizer)
146 bool fFix = false; ///< flag to control if parameter is fixed
147 double fLowerLimit = 0.0; ///< lower parameter limit
148 double fUpperLimit = 0.0; ///< upper parameter limit
149 bool fHasLowerLimit = false; ///< flag to control lower parameter limit
150 bool fHasUpperLimit = false; ///< flag to control upper parameter limit
151
152 std::string fName; ///< parameter name
153};
154
155} // namespace ROOT::Fit
156
157#endif /* ROOT_Fit_ParameterSettings */
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
void Release()
release the parameter
bool IsFixed() const
check if is fixed
bool HasUpperLimit() const
check if parameter has upper limit
bool fFix
flag to control if parameter is fixed
ParameterSettings(const std::string &name, double val, double err)
constructor for unlimited named Parameter
ParameterSettings()
Default constructor.
void RemoveLimits()
remove all limit
void SetValue(double val)
set the value
double LowerLimit() const
return lower limit value
void SetName(const std::string &name)
interaction
const std::string & Name() const
return name
bool HasLowerLimit() const
check if parameter has lower limit
double fLowerLimit
lower parameter limit
double fUpperLimit
upper parameter limit
bool fHasUpperLimit
flag to control upper parameter limit
void SetStepSize(double err)
set the step size
void Set(const std::string &name, double value, double step)
set value and name (unlimited parameter)
double fStepSize
parameter step size (used by minimizer)
bool fHasLowerLimit
flag to control lower parameter limit
void SetLimits(double low, double up)
set a double side limit, if low == up the parameter is fixed if low > up the limits are removed The c...
ParameterSettings(const std::string &name, double val)
constructor for fixed Parameter
double Value() const
return parameter value
void Set(const std::string &name, double value)
set a fixed parameter
void Set(const std::string &name, double value, double step, double lower, double upper)
set a limited parameter. The given value should be within the given limits [min,max]
ParameterSettings(const std::string &name, double val, double err, double min, double max)
constructor for double limited Parameter. The given value should be within the given limits [min,...
double StepSize() const
return step size
void SetUpperLimit(double up)
set a single upper limit
std::string fName
parameter name
void Fix()
fix the parameter
double UpperLimit() const
return upper limit value
bool IsDoubleBound() const
check if is double bound (upper AND lower limit)
bool IsBound() const
check if is bound
void SetLowerLimit(double low)
set a single lower limit
Namespace for the fitting classes.