Jpp in_tag_pdf_generation
the software that should make you happy
Loading...
Searching...
No Matches
JBell.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
9#include "JMath/JBell.hh"
10
11#include "Jeep/JParser.hh"
12
13
14/**
15 * Example program to plot Bell function.
16 *
17 * \author mdejong
18 */
19int main(int argc, char **argv)
20{
21 using namespace std;
22 using namespace JPP;
23
24 string outputFile;
25 double sigma;
26 double alpha;
27 int debug;
28
29 try {
30
31 JParser<> zap("Example program to plot Bell function.");
32
33 zap['o'] = make_field(outputFile) = "";
34 zap['s'] = make_field(sigma) = 1.0;
35 zap['a'] = make_field(alpha);
36 zap['d'] = make_field(debug) = 1;
37
38 zap(argc, argv);
39 }
40 catch(const exception& error) {
41 FATAL(error.what() << endl);
42 }
43
44
45 const JBell bell(0.0, sigma, 1.0, 0.0, alpha);
46
47 TFile out(outputFile.c_str(), "recreate");
48
49 const double xmin = -7.0 * sigma;
50 const double xmax = +7.0 * sigma;
51 const double dx = 1.0e-4 * sigma;
52 const int nx = (int) ((xmax - xmin) / dx);
53
54 TH1D h0("h0", "", nx, xmin, xmax);
55
56 for (Int_t i = 1; i != h0.GetXaxis()->GetNbins(); ++i) {
57
58 const Double_t x = h0.GetXaxis()->GetBinCenter(i);
59 const Double_t y = bell(x);
60
61 h0.SetBinContent(i, y);
62 }
63
64 out.Write();
65 out.Close();
66}
int main(int argc, char **argv)
Example program to plot Bell function.
Definition JBell.cc:19
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Bell function object.
Definition JBell.hh:32