35 JParser<> zap(
"Program to test ROOT fit.");
37 zap[
'e'] =
make_field(precision) = numeric_limits<double>::min();
42 catch(
const exception& error) {
43 FATAL(error.what() << endl);
48 if (option.find(
'S') == string::npos) {
52 if (
debug <
debug_t && option.find(
'Q') == string::npos) {
57 TH1D h1(
"h1", NULL, 1, -0.5, +0.5);
69 for (
int i = 0;
i !=
sizeof(
data)/
sizeof(
data[0]); ++
i) {
71 const double y =
data[
i].y;
72 const double z =
data[
i].z;
74 h1.SetBinContent(1, y);
75 h1.SetBinError (1, z);
78 NOTICE(
"ROOT fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
84 f1.SetParLimits(0, 0.0, 0.0);
85 f1.GetParLimits(0, ymin, ymax);
87 const TFitResultPtr
result = h1.Fit(&
f1, option.c_str());
89 ASSERT(result.Get() != NULL,
"TFitResultPtr");
92 <<
FIXED(7,3) <<
f1.GetParameter(0) <<
" +/- "
93 <<
FIXED(7,3) <<
f1.GetParError (0) <<
" "
94 <<
"[" <<
FIXED(7,3) << ymin <<
"," <<
FIXED(7,3) << ymax <<
"]" <<
" "
95 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
96 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
100 NOTICE(
"Normal fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
107 const TFitResultPtr result = h1.Fit(&
f1, option.c_str());
109 ASSERT(result.Get() != NULL,
"TFitResultPtr");
112 <<
FIXED(7,3) <<
f1.GetParameter(0) <<
" +/- "
113 <<
FIXED(7,3) <<
f1.GetParError (0) <<
" "
114 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
115 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
118 ASSERT(result->IsValid());
119 ASSERT(!result->IsParameterBound(0));
120 ASSERT(!result->IsParameterFixed(0));
121 ASSERT(fabs(
f1.GetParameter(0) -
y) <
f1.GetParError(0));
124 NOTICE(
"Fixed parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
132 const JFitParameter_t parameter(0, 0.0);
137 const TFitResultPtr result = h1.Fit(&
f1, option.c_str());
139 ASSERT(result.Get() != NULL,
"TFitResultPtr");
142 <<
FIXED(7,3) <<
f1.GetParameter(0) <<
" +/- "
143 <<
FIXED(7,3) <<
f1.GetParError (0) <<
" "
144 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
145 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
148 ASSERT(result->IsValid());
149 ASSERT(!result->IsParameterBound(0));
150 ASSERT(result->IsParameterFixed(0));
151 ASSERT(fabs(
f1.GetParameter(0) - parameter.value) < precision);
152 ASSERT(fabs(
f1.GetParError (0)) < precision);
155 NOTICE(
"Fixed parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
163 const JFitParameter_t parameter(0, 0.0);
168 const TFitResultPtr result = h1.Fit(&
f1, option.c_str());
170 ASSERT(result.Get() != NULL,
"TFitResultPtr");
173 <<
FIXED(7,3) <<
f1.GetParameter(0) <<
" +/- "
174 <<
FIXED(7,3) <<
f1.GetParError (0) <<
" "
175 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
176 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
179 ASSERT(result->IsValid());
180 ASSERT(!result->IsParameterBound(0));
181 ASSERT(result->IsParameterFixed(0));
182 ASSERT(fabs(
f1.GetParameter(0) - parameter.value) < precision);
183 ASSERT(fabs(
f1.GetParError (0)) < precision);
186 NOTICE(
"Released parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
198 const TFitResultPtr result = h1.Fit(&
f1, option.c_str());
200 ASSERT(result.Get() != NULL,
"TFitResultPtr");
203 <<
FIXED(7,3) <<
f1.GetParameter(0) <<
" +/- "
204 <<
FIXED(7,3) <<
f1.GetParError (0) <<
" "
205 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
206 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
209 ASSERT(result->IsValid());
210 ASSERT(!result->IsParameterBound(0));
211 ASSERT(!result->IsParameterFixed(0));
212 ASSERT(fabs(
f1.GetParameter(0) -
y) <
f1.GetParError(0));
Utility class to parse command line options.
bool releaseParameter(TF1 &f1, const Int_t index)
Release fit parameter.
Auxiliary data structure for floating point format specification.
bool isParameterFixed(const TF1 &f1, const Int_t index)
Check if fit parameter is fixed.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
bool setParameter(TF1 &f1, const JFitParameter_t ¶meter)
Set fit parameter.
bool fixParameter(TF1 &f1, const JFitParameter_t ¶meter)
Fix fit parameter.
#define DEBUG(A)
Message macros.