#include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1.h" #include "TGraph.h" #include "TGraph2D.h" #include "TF1.h" #include "JTools/JRange.hh" #include "JGizmo/JRootObjectID.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to test ROOT fit results. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JRange JRange_t; typedef map JTest_t; JRootObjectID inputFile; string fcn; JTest_t test; int debug; try { JParser<> zap("Auxiliary program to test ROOT fit results."); zap['f'] = make_field(inputFile, "histogram, e.g: :"); zap['='] = make_field(fcn, "function name") = ".*"; zap['@'] = make_field(test, " "); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } TObject* p = getObject(inputFile); if (p == NULL) { FATAL("No object at " << inputFile << endl); }; TF1* f1 = NULL; if (f1 == NULL && dynamic_cast (p) != NULL) { f1 = dynamic_cast(p); } if (f1 == NULL && dynamic_cast (p) != NULL) { f1 = getFunction(dynamic_cast (p), fcn.c_str()); }; if (f1 == NULL && dynamic_cast (p) != NULL) { f1 = getFunction(dynamic_cast (p), fcn.c_str()); }; if (f1 == NULL && dynamic_cast(p) != NULL) { f1 = getFunction(dynamic_cast(p), fcn.c_str()); }; if (f1 == NULL) { FATAL("No function at " << inputFile << " " << fcn << endl); }; for (int i = 0; i != f1->GetNpar(); ++i) { DEBUG(left << setw(12) << f1->GetParName(i) << ' '); DEBUG(SCIENTIFIC(12,5) << f1->GetParameter(i) << " +/- " << SCIENTIFIC(12,5) << f1->GetParError(i)); JTest_t::const_iterator p = test.find(f1->GetParName(i)); if (p != test.end()) { DEBUG(" [" << SCIENTIFIC(12,5) << p->second.getLowerLimit() << "," << SCIENTIFIC(12,5) << p->second.getLowerLimit() << "] "); DEBUG((p->second(f1->GetParameter(i)) ? "passed" : "failed")); } else { DEBUG("untested"); } DEBUG(endl); } for (int i = 0; i != f1->GetNpar(); ++i) { JTest_t::const_iterator p = test.find(f1->GetParName(i)); if (p != test.end()) { ASSERT(p->second(f1->GetParameter(i)), p->first << ' ' << p->second); } } return 0; }