Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

typedef std::pair<double,double> orientation

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

Function Documentation

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

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

29 { return in >> x.first >> x.second; }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
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; }
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 
44  typedef JAbstractHistogram<Double_t> JHistogram_t;
45 
46  string pdfFile;
47  string cdfFile;
48  string outputFile;
49  orientation dir;
50  JHistogram_t x;
51  JHistogram_t y;
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
82  JMapList<JPolint1FunctionalMap,
83  JMapList<JPolint1FunctionalMap,
84  JMapList<JPolint1FunctionalGridMap,
85  JMapList<JPolint1FunctionalGridMap> > > > JMapList_t;
86  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_t;
87  typedef JNPETable<double, double, JMapList_t> JNPE_t;
88  typedef JCDFTable<JFunction1D_t, JMapList_t> JCDF_t;
89 
90  JDistance<double>::precision = 1.0e-10;
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 }
Utility class to parse command line options.
Definition: JParser.hh:1514
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
#define FATAL(A)
Definition: JMessage.hh:67
then for FUNCTION in pdf npe cdf
Definition: JPlotNPE-PDG.sh:73
int numberOfPoints
Definition: JResultPDF.cc:22
int j
Definition: JPolint.hh:792
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
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62