Jpp
Functions
JPlotNPE1D.cc File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JFunctionalMap_t.hh"
#include "JTools/JAbstractHistogram.hh"
#include "JPhysics/JPDFTransformer.hh"
#include "JPhysics/JPDFTable.hh"
#include "JPhysics/JPDFTypes.hh"
#include "JPhysics/JNPETable.hh"
#include "JPhysics/JGeanz.hh"
#include "JGeometry3D/JAngle3D.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.

Author
jseneca

Definition in file JPlotNPE1D.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JPlotNPE1D.cc.

32 {
33  using namespace std;
34  using namespace JPP;
35 
36  typedef JAbstractHistogram<double> JHistogram_t;
37 
38  vector<string> inputFile;
39  string outputFile;
40  JAngle3D dir;
41  double D;
42  JHistogram_t x;
43  double E;
44  int numberOfPoints;
45  int debug;
46 
47  try {
48 
49  JParser<> zap("Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.");
50 
51  zap['f'] = make_field(inputFile);
52  zap['o'] = make_field(outputFile) = "";
53  zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
54  zap['R'] = make_field(D, "distance from vertex to PMT [m]");
55  zap['x'] = make_field(x, "histogram x-binning") = JHistogram_t();
56  zap['E'] = make_field(E, "Energy [GeV]") = 0.0;
57  zap['N'] = make_field(numberOfPoints) = 10;
58  zap['d'] = make_field(debug) = 0;
59 
60  zap(argc, argv);
61  }
62  catch(const exception &error) {
63  FATAL(error.what() << endl);
64  }
65 
66 
68 
69  if (E > 0.0) {
70  for (int i = 0; i != numberOfPoints; ++i) {
71  Z.push_back(geanz.getLength(E, (i + 0.5) / (double) numberOfPoints));
72  }
73  }
74 
75 
76  typedef JPolint0Function1D_t JFunction1D_t;
77  typedef
78  JMapList<JPolint1FunctionalMap,
79  JMapList<JPolint1FunctionalMap,
80  JMapList<JPolint1FunctionalGridMap,
81  JMapList<JPolint1FunctionalGridMap> > > > JMapList_t;
82  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_t;
83  typedef JNPETable<double, double, JMapList_t> JNPE_t;
84 
85  JDistance<double>::precision = 1.0e-10;
86 
87  const int N = inputFile.size();
88 
89  JPDF_t pdf[N];
90  JNPE_t npe[N];
91 
92  try {
93 
94  for (int i = 0; i != N; ++i) {
95 
96  NOTICE("loading input from file " << inputFile[i] << "... " << flush);
97 
98  pdf[i].load(inputFile[i].c_str());
99 
100  pdf[i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
101 
102  npe[i] = JNPE_t(pdf[i]);
103 
104  NOTICE("OK" << endl);
105  }
106  }
107  catch(const JException& error) {
108  FATAL(error.what() << endl);
109  }
110 
111 
112  TFile out(outputFile.c_str(), "recreate");
113 
114  if (!x.is_valid()) { x = JHistogram_t(100000, -1.0, +1.0); }
115 
116  TH1D h0("h0", "PDF Projection; D [m]; P [npe]", x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit());
117 
118 
119  for (int ix = 1; ix <= h0.GetNbinsX(); ++ix) {
120 
121  const double cd = h0.GetBinCenter(ix);
122 
123  double Y = 0.0;
124 
125  if (!Z.empty()) {
126 
127  const double W = 1.0 / (double) Z.size();
128 
129  for (vector<double>::const_iterator z = Z.begin(); z != Z.end(); ++z) {
130 
131  const double __D = sqrt(D*D - 2.0*(D*cd)*(*z) + (*z)*(*z));
132  const double __cd = (D * cd - (*z)) / __D;
133 
134  for (int i = 0; i != N; ++i) {
135  try {
136  Y += W * npe[i](__D, __cd, dir.getTheta(), dir.getPhi());
137  }
138  catch(const exception& error) {}
139  }
140  }
141 
142  } else {
143 
144  for (int i = 0; i != N; ++i) {
145  Y += npe[i](D, cd, dir.getTheta(), dir.getPhi());
146  }
147  }
148 
149  h0.SetBinContent(ix, Y);
150  }
151 
152  out.Write();
153  out.Close();
154 }
numberOfPoints
int numberOfPoints
Definition: JResultPDF.cc:22
std::vector
Definition: JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JPHYSICS::JGeanz::getLength
double getLength(const double E, const double P, const double eps=1.0e-3) const
Get shower length for a given integrated probability.
Definition: JGeanz.hh:122
std
Definition: jaanetDictionary.h:36
JMATH::zero
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:94
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JPHYSICS::geanz
static const JGeanz geanz(1.85, 0.62, 0.54)
Function object for longitudinal EM-shower profile.