25int main(
int argc, 
char **argv)
 
   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);
 
  129      ASSERT(isParameterFixed(f1, 0) == 
true);
 
  130      ASSERT(isParameterFixed(f1, 1) == 
false);
 
  134      ASSERT(fixParameter(f1, parameter));
 
  135      ASSERT(fixParameter(f1, parameter));
 
  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);
 
  160      ASSERT(isParameterFixed(f1, 0) == 
true);
 
  161      ASSERT(isParameterFixed(f1, 1) == 
false);
 
  165      ASSERT(fixParameter(f1, parameter));
 
  166      ASSERT(fixParameter(f1, parameter));
 
  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);
 
  191      ASSERT(isParameterFixed(f1, 0) == 
true);
 
  193      ASSERT(releaseParameter(f1, 0) == 
true);
 
  194      ASSERT(releaseParameter(f1, 1) == 
false);
 
  196      ASSERT(!isParameterFixed(f1, 0));
 
  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));