34 JParser<> zap(
"Program to test ROOT fit.");
36 zap[
'e'] =
make_field(precision) = numeric_limits<double>::min();
41 catch(
const exception& error) {
42 FATAL(error.what() << endl);
47 if (option.find(
'S') == string::npos) {
51 if (
debug <
debug_t && option.find(
'Q') == string::npos) {
56 TH1D
h1(
"h1", NULL, 1, -0.5, +0.5);
68 for (
int i = 0; i !=
sizeof(data)/
sizeof(data[0]); ++i) {
70 const double y = data[i].y;
71 const double z = data[i].z;
73 h1.SetBinContent(1, y);
74 h1.SetBinError (1, z);
77 NOTICE(
"ROOT fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
83 f1.SetParLimits(0, 0.0, 0.0);
84 f1.GetParLimits(0, ymin, ymax);
86 const TFitResultPtr
result =
h1.Fit(&f1, option.c_str());
89 <<
FIXED(7,3) << f1.GetParameter(0) <<
" +/- "
90 <<
FIXED(7,3) << f1.GetParError (0) <<
" "
91 <<
"[" <<
FIXED(7,3) << ymin <<
"," <<
FIXED(7,3) << ymax <<
"]" <<
" "
92 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
93 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
97 NOTICE(
"Normal fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
104 const TFitResultPtr result =
h1.Fit(&f1, option.c_str());
107 <<
FIXED(7,3) << f1.GetParameter(0) <<
" +/- "
108 <<
FIXED(7,3) << f1.GetParError (0) <<
" "
109 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
110 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
113 ASSERT(result->IsValid());
114 ASSERT(!result->IsParameterBound(0));
115 ASSERT(!result->IsParameterFixed(0));
116 ASSERT(fabs(f1.GetParameter(0) - y) < f1.GetParError(0));
119 NOTICE(
"Fixed parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
127 const JFitParameter_t parameter(0, 0.0);
132 const TFitResultPtr result =
h1.Fit(&f1, option.c_str());
135 <<
FIXED(7,3) << f1.GetParameter(0) <<
" +/- "
136 <<
FIXED(7,3) << f1.GetParError (0) <<
" "
137 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
138 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
141 ASSERT(result->IsValid());
142 ASSERT(!result->IsParameterBound(0));
143 ASSERT(result->IsParameterFixed(0));
144 ASSERT(fabs(f1.GetParameter(0) - parameter.value) < precision);
145 ASSERT(fabs(f1.GetParError (0)) < precision);
148 NOTICE(
"Fixed parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
156 const JFitParameter_t parameter(0, 0.0);
161 const TFitResultPtr result =
h1.Fit(&f1, option.c_str());
164 <<
FIXED(7,3) << f1.GetParameter(0) <<
" +/- "
165 <<
FIXED(7,3) << f1.GetParError (0) <<
" "
166 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
167 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
170 ASSERT(result->IsValid());
171 ASSERT(!result->IsParameterBound(0));
172 ASSERT(result->IsParameterFixed(0));
173 ASSERT(fabs(f1.GetParameter(0) - parameter.value) < precision);
174 ASSERT(fabs(f1.GetParError (0)) < precision);
177 NOTICE(
"Released parameters fit " <<
FIXED(7,3) << y <<
" +/- " <<
FIXED(7,3) << z << endl);
189 const TFitResultPtr result =
h1.Fit(&f1, option.c_str());
192 <<
FIXED(7,3) << f1.GetParameter(0) <<
" +/- "
193 <<
FIXED(7,3) << f1.GetParError (0) <<
" "
194 << (result->IsParameterBound(0) ?
" *** bound *** " :
"")
195 << (result->IsParameterFixed(0) ?
" *** fixed *** " :
"")
198 ASSERT(result->IsValid());
199 ASSERT(!result->IsParameterBound(0));
200 ASSERT(!result->IsParameterFixed(0));
201 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.
then for HISTOGRAM in h0 h1
Auxiliary data structure for floating point format specification.
bool isParameterFixed(const TF1 &f1, const Int_t index)
Check if fit parameter is fixed.
#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.