#include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TF1.h" #include "JTools/JRange.hh" #include "JLang/JToken.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to write 1D ROOT function. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JToken<';'> JToken_t; typedef JRange JRange_t; string formula; string name; string outputFile; JRange_t x; vector parameters; int N; int debug; try { JParser<> zap("Auxiliary program to write 1D ROOT function."); zap['F'] = make_field(formula, "function, e.g: \"[0]+[1]*x\""); zap['T'] = make_field(name, "name of ROOT function") = "user"; zap['o'] = make_field(outputFile, "ROOT file with formula") = "f1.root"; zap['x'] = make_field(x, "abscissa range") = JRange_t(); zap['@'] = make_field(parameters, "parameter values, e.g: \"p0 = 1.0;\"") = JPARSER::initialised(); zap['N'] = make_field(N, "number of points (for drawing)") = 0; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } TF1 f1(name.c_str(), formula.c_str(), x.getLowerLimit(), x.getUpperLimit()); if (N > 0) { f1.SetNpx(N); } for (vector::const_iterator i = parameters.begin(); i != parameters.end(); ++i) { f1.SetParameter(getParameter(*i), getValue(*i,&f1)); } TFile out(outputFile.c_str(), "recreate"); out.WriteTObject(&f1); out.Write(); out.Close(); }