#include #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" /** * Read formula from input stream. * * \param in input stream * \param object formula * \return input stream */ inline std::istream& operator>>(std::istream& in, TString& object) { return object.ReadLine(in); } /** * Write formula to output stream. * * \param out output stream * \param object formula * \return output stream */ inline std::ostream& operator<<(std::ostream& out, const TString& object) { return out << object.Data(); } /** * \file * Auxiliary program to print ROOT fit results. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JRootObjectID inputFile; string fcn; vector x; set parameter; TString formula; int debug; try { JParser<> zap("Auxiliary program to print ROOT fit results."); zap['f'] = make_field(inputFile, "histogram, e.g: :"); zap['='] = make_field(fcn, "function name") = ".*"; zap['x'] = make_field(x, "(x)+, evaluate function at given point") = JPARSER::initialised(); zap['@'] = make_field(parameter, "(parameter)+, e.g. \"p0\"") = JPARSER::initialised(); zap['F'] = make_field(formula, "ROOT TFormula (may contain method names of TF1)") = JPARSER::initialised(); 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) { if (parameter.count(f1->GetParName(i)) != 0) { cout << FIXED(20,10) << f1->GetParameter(i) << ' ' << FIXED(20,10) << f1->GetParError (i) << endl; } } if (!x.empty()) { cout << f1->EvalPar(x.data()) << endl; } if (formula != "") { cout << SCIENTIFIC(15,5) << getResult(formula, f1) << endl; } }