Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPhysics/JShowerNPE.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH2D.h"
9 
11 #include "JPhysics/JNPE_t.hh"
12 #include "JGeometry3D/JAngle3D.hh"
13 #include "Jeep/JPrint.hh"
14 #include "Jeep/JParser.hh"
15 #include "Jeep/JMessage.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.
22  * \author lquinn
23  */
24 int main(int argc, char **argv)
25 {
26  using namespace std;
27  using namespace JPP;
28 
29  typedef JAbstractHistogram<double> JHistogram_t;
30 
31  string pdfFile;
32  string outputFile;
33  JAngle3D dir;
34  JHistogram_t x;
35  JHistogram_t y;
36  double E;
37  int numberOfPoints;
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.");
43 
44  zap['P'] = make_field(pdfFile);
45  zap['o'] = make_field(outputFile) = "";
46  zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
47  zap['x'] = make_field(x, "histogram x-binning") = JHistogram_t();
48  zap['y'] = make_field(y, "histogram y-binning") = JHistogram_t();
49  zap['E'] = make_field(E, "Energy [GeV]") = 0.0;
50  zap['N'] = make_field(numberOfPoints) = 0;
51  zap['d'] = make_field(debug) = 0;
52 
53  zap(argc, argv);
54  }
55  catch(const exception &error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  const JShowerNPE_t npe(pdfFile, numberOfPoints);
61 
62 
63  TFile out(outputFile.c_str(), "recreate");
64 
65  if (!x.is_valid()) { x = JHistogram_t(150, 0.0, 150.0); }
66  if (!y.is_valid()) { y = JHistogram_t(200, -1.0, +1.0); }
67 
68  TH2D h0("h0", "PDF Projection; D [m]; cos #theta_{0}",
69  x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit(),
70  y.getNumberOfBins(), y.getLowerLimit(), y.getUpperLimit());
71 
72  for (int ix = 1; ix <= h0.GetNbinsX(); ++ix) {
73  for (int iy = 1; iy <= h0.GetNbinsY(); ++iy) {
74 
75  const double cd = h0.GetYaxis()->GetBinCenter(iy);
76  const double D = h0.GetXaxis()->GetBinCenter(ix);
77 
78  const double Y = npe.calculate(E, D, cd, dir.getTheta(), dir.getPhi());
79 
80  h0.SetBinContent(ix, iy, Y/E);
81  }
82  }
83 
84  out.Write();
85  out.Close();
86 }
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
then usage E
Definition: JMuonPostfit.sh:35
Auxiliary data structure for shower PDF.
Definition: JNPE_t.hh:175
Auxiliary data structure for muon PDF.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
string outputFile
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
int numberOfPoints
Definition: JResultPDF.cc:22
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
int debug
debug level
double calculate(const double E, const double D, const double cd, const double theta, const double phi) const
Get PDF.
Definition: JNPE_t.hh:249