Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JF1.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TF1.h"
8 
9 #include "JTools/JRange.hh"
10 
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  * Auxiliary program to write ROOT function.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23 
24  typedef JTOOLS::JRange<double> JRange_t;
25 
26  string formula;
27  string name;
28  string outputFile;
29  JRange_t x;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to write ROOT function.");
35 
36  zap['F'] = make_field(formula, "function, e.g: \"[0]+[1]*x\"");
37  zap['T'] = make_field(name, "name of ROOT function") = "user";
38  zap['o'] = make_field(outputFile, "ROOT file with formula") = "f1.root";
39  zap['x'] = make_field(x, "abscissa range");
40  zap['d'] = make_field(debug) = 1;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48  TF1 f1(name.c_str(), formula.c_str(), x.getLowerLimit(), x.getUpperLimit());
49 
50  TFile out(outputFile.c_str(), "recreate");
51 
52  out.WriteTObject(&f1);
53 
54  out.Write();
55  out.Close();
56 }
Utility class to parse command line options.
Definition: JParser.hh:1410
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Auxiliary class to define a range between two values.
Utility class to parse command line options.
int main(int argc, char *argv[])
Definition: Main.cpp:15