Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Typedefs | Functions
JPlotNPE-PDG.cc File Reference

Program to compare integrals of PDF of Cherenkov light from EM-shower using interpolation tables. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.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/JCDFTable.hh"
#include "JPhysics/JNPETable.hh"
#include "JPhysics/JPDFTypes.hh"
#include "JROOT/JRootToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Typedefs

typedef std::pair< double, double > orientation
 

Functions

std::istream & operator>> (std::istream &in, orientation &x)
 
std::ostream & operator<< (std::ostream &out, const orientation &x)
 
int main (int argc, char **argv)
 

Detailed Description

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

Author
lquinn

Definition in file JPlotNPE-PDG.cc.

Typedef Documentation

◆ orientation

typedef std::pair<double,double> orientation

Definition at line 27 of file JPlotNPE-PDG.cc.

Function Documentation

◆ operator>>()

std::istream& operator>> ( std::istream &  in,
orientation x 
)

Definition at line 29 of file JPlotNPE-PDG.cc.

29 { return in >> x.first >> x.second; }

◆ operator<<()

std::ostream& operator<< ( std::ostream &  out,
const orientation x 
)

Definition at line 30 of file JPlotNPE-PDG.cc.

30 { return out << x.first << ' ' << x.second; }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file JPlotNPE-PDG.cc.

40 {
41  using namespace std;
42  using namespace JPP;
43 
45 
46  string pdfFile;
47  string cdfFile;
48  string outputFile;
49  orientation dir;
52  double E;
53  int numberOfPoints;
54  int debug;
55 
56  try {
57 
58  JParser<> zap("Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.");
59 
60  zap['P'] = make_field(pdfFile);
61  zap['C'] = make_field(cdfFile);
62  zap['o'] = make_field(outputFile);
63  zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
64  zap['x'] = make_field(x, "histogram x-binning") = JHistogram_t();
65  zap['y'] = make_field(y, "histogram y-binning") = JHistogram_t();
66  zap['E'] = make_field(E, "Energy [GeV]") = 1.0;
67  zap['N'] = make_field(numberOfPoints) = 10;
68  zap['d'] = make_field(debug) = 0;
69 
70  zap(argc, argv);
71  }
72  catch(const exception &error) {
73  FATAL(error.what() << endl);
74  }
75 
76 
77  const double theta = dir.first;
78  const double phi = dir.second;
79 
80  typedef JSplineFunction1S_t JFunction1D_t;
81  typedef
85  JMapList<JPolint1FunctionalGridMap> > > > JMapList_t;
89 
91 
92  JPDF_t pdf;
93  JNPE_t npe;
94  JCDF_t cdf;
95 
96  try {
97 
98  NOTICE("loading input from file " << pdfFile << "... " << flush);
99 
100  pdf.load(pdfFile.c_str());
101 
102  pdf.setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
103 
104  npe = JNPE_t(pdf);
105 
106  NOTICE("OK" << endl);
107 
108  NOTICE("loading input from file " << cdfFile << "... " << flush);
109 
110  cdf.load(cdfFile.c_str());
111 
112  NOTICE("OK" << endl);
113  }
114  catch(const JException& error) {
115  FATAL(error.what() << endl);
116  }
117 
118  if (!x.is_valid()) { x = JHistogram_t(250, 0.0, 250.0); }
119  if (!y.is_valid()) { y = JHistogram_t(200, -1.0, +1.0); }
120 
121  TH2D h0("pdf", NULL, x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit(), y.getNumberOfBins(), y.getLowerLimit(), y.getUpperLimit());
122  TH2D h1("npe", NULL, x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit(), y.getNumberOfBins(), y.getLowerLimit(), y.getUpperLimit());
123  TH2D h2("cdf", NULL, x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit(), y.getNumberOfBins(), y.getLowerLimit(), y.getUpperLimit());
124 
125  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
126  for (int j = 1; j <= h0.GetNbinsY(); ++j) {
127 
128  const double D = h0.GetXaxis()->GetBinCenter(i);
129  const double cd = h0.GetYaxis()->GetBinCenter(j);
130 
131  try {
132 
133  const double y0 = get_integral(pdf(D, cd, theta, phi, 1.0e3));
134  const double y1 = npe (D, cd, theta, phi);
135  const double y2 = cdf.getNPE (D, cd, theta, phi);
136 
137  DEBUG("npe "
138  << FIXED(5,1) << D << ' '
139  << FIXED(5,1) << cd << ' '
140  << SCIENTIFIC(12,3) << y0 << ' '
141  << SCIENTIFIC(12,3) << y1 << ' '
142  << SCIENTIFIC(12,3) << y2 << endl);
143 
144  h0.SetBinContent(i, j, E * y0);
145  h1.SetBinContent(i, j, E * y1);
146  h2.SetBinContent(i, j, E * y2);
147  }
148  catch(const exception& error) {
149  ERROR(error.what());
150  }
151  }
152  }
153 
154  if (outputFile != "") {
155 
156  TFile out(outputFile.c_str(), "recreate");
157 
158  out << h0 << h1 << h2;
159 
160  out.Write();
161  out.Close();
162  }
163 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define ERROR(A)
Definition: JMessage.hh:66
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
int numberOfPoints
Definition: JResultPDF.cc:22
General exception.
Definition: JException.hh:24
virtual const char * what() const override
Get error message.
Definition: JException.hh:64
Utility class to parse command line options.
Definition: JParser.hh:1698
Multi-dimensional CDF table for arrival time of Cherenkov light.
Definition: JCDFTable.hh:57
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition: JNPETable.hh:43
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition: JPDFTable.hh:44
JAbstractHistogram< double > JHistogram_t
Type definition for scan along axis.
Definition: JBillabong.cc:61
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JResultEvaluator< JResult_t >::result_type get_integral(const JResult_t &value)
Helper method to convert function value to partial integral value.
Definition: JResult.hh:1024
int j
Definition: JPolint.hh:792
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Simple data structure for histogram binning.
Template class for distance evaluation.
Definition: JDistance.hh:24
Map list.
Definition: JMapList.hh:25
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488