#include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TF2.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 2D 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; JRange_t y; vector parameters; int N; int debug; try { JParser<> zap("Auxiliary program to write 2D 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") = "f2.root"; zap['x'] = make_field(x, "abscissa range") = JRange_t(); zap['y'] = make_field(y, "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); } TF2 f2(name.c_str(), formula.c_str(), x.getLowerLimit(), x.getUpperLimit(), y.getLowerLimit(), y.getUpperLimit()); if (N > 0) { f2.SetNpx(N); f2.SetNpy(N); } for (vector::const_iterator i = parameters.begin(); i != parameters.end(); ++i) { f2.SetParameter(getParameter(*i), getValue(*i,&f2)); } TFile out(outputFile.c_str(), "recreate"); out.WriteTObject(&f2); out.Write(); out.Close(); }