60         result = dynamic_cast<T&>(
object).Fit(tuple.first, tuple.second.first.c_str(), 
"same", tuple.second.second.first, tuple.second.second.second);
 
   62       catch(
const std::exception&) {}
 
   92 int main(
int argc, 
char **argv)
 
  113     JParser<> zap(
"General purpose fit program using ROOT.");
 
  115     zap[
'f'] = 
make_field(inputFile,   
"<input file>:<object name>");
 
  117     zap[
'F'] = 
make_field(formula,     
"fit formula, e.g: \"[0]+[1]*x\"");
 
  118     zap[
'@'] = 
make_field(startValues, 
"start values, e.g: \"p0 = GetMaximum;\"");
 
  119     zap[
'='] = 
make_field(fixedValues, 
"fixed values, e.g: \"p0 = GetMaximum;\"");
 
  120     zap[
'x'] = 
make_field(X,           
"abscissa range")                     = JRange_t();
 
  121     zap[
'y'] = 
make_field(Y,           
"ordinate range")                     = JRange_t();
 
  122     zap[
'P'] = 
make_field(project,     
"projection")                         = 
'\0', 
'x', 
'X', 
'y', 
'Y';
 
  123     zap[
'O'] = 
make_field(option,      
"Fit option")                         = 
"";
 
  130   catch(
const exception &error) {
 
  131     FATAL(error.what() << endl);
 
  135   if (option.find(
'O') == string::npos) { option += 
"O"; }
 
  137   if (
debug ==  0 && option.find(
'Q') == string::npos) { option += 
"Q"; }
 
  139   bool px = (project == 
'x' || project == 
'X');  
 
  140   bool py = (project == 
'y' || project == 
'Y');  
 
  150   TF1* fcn = 
new TF1(
"user", formula.c_str());
 
  154   if (fcn->IsZombie()) {
 
  155     FATAL(
"Function: " << formula << 
" is zombie." << endl);
 
  160     DEBUG(
"Input: " << *input << endl);
 
  165       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  169     const TRegexp regexp(input->getObjectName());
 
  171     TIter iter(dir->GetListOfKeys());
 
  173     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  175       const TString tag(key->GetName());
 
  177       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  181       if (tag.Contains(regexp)) {
 
  183         TObject* 
object = key->ReadObj();
 
  187           TProfile& h1 = dynamic_cast<TProfile&>(*
object);
 
  189           object = h1.ProjectionX();
 
  195           TH2& h2 = dynamic_cast<TH2&>(*
object);
 
  199             object = h2.ProjectionX(
"_px", 
 
  200                                     h2.GetYaxis()->FindBin(Y.getLowerLimit()),
 
  201                                     h2.GetYaxis()->FindBin(Y.getUpperLimit()));
 
  205             object = h2.ProjectionY(
"_py", 
 
  206                                     h2.GetXaxis()->FindBin(Y.getLowerLimit()),
 
  207                                     h2.GetXaxis()->FindBin(Y.getUpperLimit()));
 
  211             ERROR(
"For 2D histograms, use option option -P for projections." << endl);
 
  232           FATAL(error << endl);
 
  235         DEBUG(
"Start values " << object->GetName() << endl);
 
  237         for (
int j = 0; 
j != fcn->GetNpar(); ++
j) {
 
  238           DEBUG(left << setw(12) << fcn->GetParName  (
j) << 
' ' << 
 
  242         Double_t xmin = +numeric_limits<Double_t>::max();
 
  243         Double_t xmax = -numeric_limits<Double_t>::max();
 
  246           TH1* h1 = dynamic_cast<TH1*>(
object);
 
  249             xmin = min(xmin, h1->GetXaxis()->GetXmin());
 
  250             xmax = max(xmax, h1->GetXaxis()->GetXmax());
 
  255           TGraph* 
g1 = dynamic_cast<TGraph*>(
object);
 
  258             for (Int_t i = 0; i != 
g1->GetN(); ++i) {
 
  259               xmin = min(xmin, 
g1->GetX()[i]);
 
  260               xmax = max(xmax, 
g1->GetX()[i]);
 
  265         if (X != JRange_t()) {
 
  266           xmin = X.getLowerLimit();
 
  267           xmax = X.getUpperLimit();
 
  278         if (fit.result != -1) {
 
  282           NOTICE(
"Fit values  " << object->GetName() << endl);
 
  283           NOTICE(
"Fit formula " << formula           << endl);
 
  285           for (
int j = 0; 
j != fcn->GetNpar(); ++
j) {
 
  286             NOTICE(left << setw(12) << fcn->GetParName  (
j) << 
' '     << 
 
  287                    SCIENTIFIC(12,5) << fcn->GetParameter(
j) << 
" +/- " << 
 
  293           WARNING(
"Object: not compatible with ROOT Fit." << endl);