#include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TGraph.h" #include "TRandom3.h" #include "JPhysics/JGeanz.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram longitudinal shower profile using JPHYSICS::JGeanz. * \author mdejong */ int main(int argc, char* argv[]) { using namespace std; string outputFile; double E_GeV; int numberOfEvents; int debug; try { JParser<> zap("Example program to histogram longitudinal shower profile."); zap['o'] = make_field(outputFile) = "geanz.root"; zap['E'] = make_field(E_GeV); zap['n'] = make_field(numberOfEvents) = 0; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; TFile out(outputFile.c_str(), "recreate"); TH1D h1("Probability", NULL, 1000, 0.0, 25.0); TH1D h2("Integral", NULL, 1000, 0.0, 25.0); TH1D h3("MC", NULL, 100, 0.0, 25.0); for(int i = 1; i <= h1.GetNbinsX(); ++i) { const double x = h1.GetBinCenter(i); h1.SetBinContent(i, geanz.getProbability(E_GeV, x)); h2.SetBinContent(i, geanz.getIntegral (E_GeV, x)); } if (numberOfEvents != 0) { for (int i = 0; i != numberOfEvents; ++i) { const double x = gRandom->Rndm(); h3.Fill(geanz.getLength(E_GeV, x)); } convertToPDF(h3, "NW"); } const Double_t x = geanz.getMaximum(E_GeV); const Double_t y = geanz.getProbability(E_GeV, x); TGraph g1(1, &x, &y); g1.SetName("Maximum"); g1.Write(); out.Write(); out.Close(); }