Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JGeanz.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3
4#include "TROOT.h"
5#include "TFile.h"
6#include "TH1D.h"
7#include "TGraph.h"
8#include "TRandom3.h"
9
10#include "JPhysics/JGeanz.hh"
12
13#include "Jeep/JParser.hh"
14#include "Jeep/JMessage.hh"
15
16
17/**
18 * \file
19 *
20 * Example program to histogram longitudinal shower profile using JPHYSICS::JGeanz.
21 * \author mdejong
22 */
23int main(int argc, char* argv[])
24{
25 using namespace std;
26 using namespace JPP;
27
28 string outputFile;
29 double E_GeV;
30 int numberOfEvents;
31 int debug;
32
33 try {
34
35 JParser<> zap("Example program to histogram longitudinal shower profile.");
36
37 zap['o'] = make_field(outputFile) = "geanz.root";
38 zap['E'] = make_field(E_GeV);
39 zap['n'] = make_field(numberOfEvents) = 0;
40 zap['d'] = make_field(debug) = 2;
41
42 zap(argc, argv);
43 }
44 catch(const exception &error) {
45 FATAL(error.what() << endl);
46 }
47
48
49 TFile out(outputFile.c_str(), "recreate");
50
51 TH1D h1("Probability", NULL, 1000, 0.0, 25.0);
52 TH1D h2("Integral", NULL, 1000, 0.0, 25.0);
53 TH1D h3("MC", NULL, 200, 0.0, 25.0);
54
55 for(int i = 1; i <= h1.GetNbinsX(); ++i) {
56
57 const double x = h1.GetBinCenter(i);
58
59 h1.SetBinContent(i, geanz.getProbability(E_GeV, x));
60 h2.SetBinContent(i, geanz.getIntegral (E_GeV, x));
61 }
62
63 if (numberOfEvents != 0) {
64
65 for (int i = 0; i != numberOfEvents; ++i) {
66
67 const double x = gRandom->Rndm();
68
69 h3.Fill(geanz.getLength(E_GeV, x));
70 }
71
72 convertToPDF(h3, "NW");
73 }
74
75 const Double_t x = geanz.getMaximum(E_GeV);
76 const Double_t y = geanz.getProbability(E_GeV, x);
77
78 TGraph g1(1, &x, &y);
79
80 g1.SetName("Maximum");
81 g1.Write();
82
83 out.Write();
84 out.Close();
85}
string outputFile
int main(int argc, char *argv[])
Definition JGeanz.cc:23
Longitudinal emission profile EM-shower.
General purpose messaging.
#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
Double_t g1(const Double_t x)
Function.
Definition JQuantiles.cc:25
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).