Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMathSupportkit.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 "TH1D.h"
8 
10 
11 #include "JROOT/JManager.hh"
12 
13 #include "Jeep/JParser.hh"
14 #include "Jeep/JMessage.hh"
15 
16 
17 /**
18  * \file
19  *
20  * Example program to plot mathematical functions.
21  * \author mdejong
22  */
23 int main(int argc, char**argv)
24 {
25  using namespace std;
26  using namespace JPP;
27 
28  string outputFile;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Example program to plot mathematical functions.");
34 
35  zap['o'] = make_field(outputFile) = "math.root";
36  zap['d'] = make_field(debug) = 3;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44 
45  JManager<int, TH1D> H1(new TH1D("[%]", NULL, 1000, -1.0, +1.0));
46 
47 
48  for (int ix = 1; ix <= H1->GetXaxis()->GetNbins(); ++ix) {
49 
50  const Double_t x = H1->GetXaxis()->GetBinCenter(ix);
51 
52  for (unsigned int n = 0; n <= 5; ++ n) {
53 
54  H1[n]->SetBinContent(ix, legendre(n,x));
55  }
56  }
57 
58 
59  TFile out(outputFile.c_str(), "recreate");
60 
61  out << H1;
62 
63  out.Write();
64  out.Close();
65 
66  return 0;
67 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary methods for mathematics.
do rm f tmp H1
Dynamic ROOT object management.
string outputFile
const int n
Definition: JPolint.hh:660
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
double legendre(const unsigned int n, const double x)
Legendre polynome.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.