Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPlotNPE.cc File Reference

Program to plot 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/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
lquinn

Definition in file JPlotNPE.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 32 of file JPlotNPE.cc.

33{
34 using namespace std;
35 using namespace JPP;
36
38
39 vector<string> inputFile;
40 string outputFile;
41 JAngle3D dir;
44 double E;
46 int debug;
47
48 try {
49
50 JParser<> zap("Program to plot PDF of Cherenkov light from EM-shower using interpolation tables.");
51
52 zap['f'] = make_field(inputFile);
53 zap['o'] = make_field(outputFile) = "";
54 zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
55 zap['x'] = make_field(x, "histogram x-binning") = JHistogram_t();
56 zap['y'] = make_field(y, "histogram y-binning") = JHistogram_t();
57 zap['E'] = make_field(E, "Energy [GeV]") = 0.0;
58 zap['N'] = make_field(numberOfPoints) = 10;
59 zap['d'] = make_field(debug) = 0;
60
61 zap(argc, argv);
62 }
63 catch(const exception &error) {
64 FATAL(error.what() << endl);
65 }
66
67
69
70 if (E > 0.0) {
71 for (int i = 0; i != numberOfPoints; ++i) {
72 Z.push_back(geanz.getLength(E, (i + 0.5) / (double) numberOfPoints));
73 }
74 }
75
76
77 typedef JPolint0Function1D_t JFunction1D_t;
78 typedef
85
87
88 const int N = inputFile.size();
89
90 JPDF_t pdf[N];
91 JNPE_t npe[N];
92
93 try {
94
95 for (int i = 0; i != N; ++i) {
96
97 NOTICE("loading input from file " << inputFile[i] << "... " << flush);
98
99 pdf[i].load(inputFile[i].c_str());
100
101 pdf[i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
102
103 npe[i] = JNPE_t(pdf[i]);
104
105 NOTICE("OK" << endl);
106 }
107 }
108 catch(const JException& error) {
109 FATAL(error.what() << endl);
110 }
111
112
113 TFile out(outputFile.c_str(), "recreate");
114
115 if (!x.is_valid()) { x = JHistogram_t(150, 0.0, 150.0); }
116 if (!y.is_valid()) { y = JHistogram_t(200, -1.0, +1.0); }
117
118 TH2D h0("h0", "PDF Projection; D [m]; cos #theta_{0}",
119 x.getNumberOfBins(), x.getLowerLimit(), x.getUpperLimit(),
120 y.getNumberOfBins(), y.getLowerLimit(), y.getUpperLimit());
121
122 for (int ix = 1; ix <= h0.GetNbinsX(); ++ix) {
123 for (int iy = 1; iy <= h0.GetNbinsY(); ++iy) {
124
125 const double cd = h0.GetYaxis()->GetBinCenter(iy);
126 const double D = h0.GetXaxis()->GetBinCenter(ix);
127
128 double Y = 0.0;
129
130 if (!Z.empty()) {
131
132 const double W = 1.0 / (double) Z.size();
133
134 for (vector<double>::const_iterator z = Z.begin(); z != Z.end(); ++z) {
135
136 const double __D = sqrt(D*D - 2.0*(D*cd)*(*z) + (*z)*(*z));
137 const double __cd = (D * cd - (*z)) / __D;
138
139 for (int i = 0; i != N; ++i) {
140 try {
141 Y += W * npe[i](__D, __cd, dir.getTheta(), dir.getPhi());
142 }
143 catch(const exception& error) {}
144 }
145 }
146
147 } else {
148
149 for (int i = 0; i != N; ++i) {
150 Y += npe[i](D, cd, dir.getTheta(), dir.getPhi());
151 }
152 }
153
154 h0.SetBinContent(ix, iy, Y);
155 }
156 }
157
158 out.Write();
159 out.Close();
160}
string outputFile
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfPoints
Definition JResultPDF.cc:22
Data structure for angles in three dimensions.
Definition JAngle3D.hh:35
double getTheta() const
Get theta angle.
Definition JAngle3D.hh:86
double getPhi() const
Get phi angle.
Definition JAngle3D.hh:97
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
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:46
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
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).
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 zero degree polynomial interpolation with result type double.
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 2nd degree polynomial interpolation based on a JMap implementation.