Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPlotPDF.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <fstream>
5#include <iomanip>
6#include <vector>
7
8#include "TROOT.h"
9#include "TFile.h"
10#include "TH1D.h"
11
16#include "JPhysics/JPDFTable.hh"
17#include "JPhysics/JPDFTypes.hh"
20#include "Jeep/JPrint.hh"
21#include "Jeep/JParser.hh"
22#include "Jeep/JMessage.hh"
23#include "JPhysics/JGeane.hh"
24
25/**
26 * \file
27 *
28 * Program to plot PDF of Cherenkov light from muon using interpolation tables.
29 * \author mdejong, bofearraigh
30 */
31int main(int argc, char **argv)
32{
33 using namespace std;
34 using namespace JPP;
35
37
38 vector<string> inputFile;
39 string outputFile;
40 double E;
41 double R;
42 double z;
43 JAngle3D dir;
44 double TTS_ns;
45 JHistogram_t histogram;
46 int debug;
47
48 try {
49
50 JParser<> zap("Program to plot PDF of Cherenkov light from muon using interpolation tables.");
51
52 zap['f'] = make_field(inputFile);
53 zap['o'] = make_field(outputFile) = "";
54 zap['E'] = make_field(E, "muon energy at vertex [GeV]") = 1.0;
55 zap['R'] = make_field(R, "distance of approach [m]");
56 zap['z'] = make_field(z, "PMT z-position [m]");
57 zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
58 zap['T'] = make_field(TTS_ns, "PMT time smearing [ns]") = 0.0;
59 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
60 zap['d'] = make_field(debug) = 0;
61
62 zap(argc, argv);
63 }
64 catch(const exception &error) {
65 FATAL(error.what() << endl);
66 }
67
68
69 typedef JSplineFunction1S_t JFunction1D_t;
72 JPolint1FunctionalGridMap>::maplist JMapList_t;
74
75 const int N = inputFile.size();
76
77 int type[N];
78 JPDF_t pdf [N];
79
80 try {
81
82 for (int i = 0; i != N; ++i) {
83
84 NOTICE("loading input from file " << inputFile[i] << "... " << flush);
85
86 type[i] = getPDFType(inputFile[i]);
87
88 pdf [i].load(inputFile[i].c_str());
89
90 pdf [i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
91
92 if (TTS_ns > 0.0) {
93 pdf[i].blur(TTS_ns);
94 }
95
96 NOTICE("OK" << endl);
97 }
98 }
99 catch(const JException& error) {
100 FATAL(error.what() << endl);
101 }
102
103 const double z_emission = z - R/getTanThetaC(); // emission point z-position
104 const double E_emission = gWater.getE(E, z_emission ); // Get energy of muon at emission point
105
106 if (outputFile == "") {
107
108 for (double dt; cin >> dt; ) {
109
110 for (int i = 0; i != N; ++i) {
111
112 JFunction1D_t::result_type y = pdf[i](R, dir.getTheta(), dir.getPhi(), dt);
113
114 if (is_bremsstrahlung(type[i])) {
115 y *= E_emission;
116 } else if (is_deltarays(type[i])) {
117 y *= getDeltaRaysFromMuon(E_emission);
118 }
119
120 cout << setw(2) << type[i] << ' '
121 << SCIENTIFIC(7,1) << E << ' '
122 << FIXED(5,1) << R << ' '
123 << FIXED(5,1) << z << ' '
124 << FIXED(5,2) << dir.getTheta() << ' '
125 << FIXED(5,2) << dir.getPhi() << ' '
126 << FIXED(5,1) << dt << ' '
127 << SCIENTIFIC(9,3) << get_value(y) << endl;
128 }
129 }
130
131 return 0;
132 }
133
134 TFile out(outputFile.c_str(), "recreate");
135
136 int function = 0;
137
138 if (inputFile.size() == 1 && getPDFType(inputFile[0]) == DIRECT_LIGHT_FROM_MUON) {
139 function = 1;
140 }
141
142 const double t0 = 0.0; // time [ns]
143
144 if (!histogram.is_valid()) {
145
146 if (function == 1) {
147
148 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
149
150 histogram.setBinWidth(0.1);
151
152 } else {
153
154 histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
155
156 histogram.setBinWidth(0.5);
157 }
158 }
159
160 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
161 TH1D h1("h1", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
162 TH1D h2("h2", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
163
164 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
165
166 const double dt = h0.GetBinCenter(i) - t0;
167
168 JFunction1D_t::result_type Y = JMATH::zero;
169
170 for (int j = 0; j != N; ++j) {
171
172 if ( E_emission > MASS_MUON* (1/COS_THETA_C_WATER) ) { // muon emission energy has to be above Cherenkov threshold
173
174 if (z_emission >= 0 && z_emission <= gWater(E)) { // emission point is between start and end point of muon
175
176 JFunction1D_t::result_type y = pdf[j](R, dir.getTheta(), dir.getPhi(), dt);
177
178 if (is_bremsstrahlung(type[j])) {
179 y *= E_emission;
180 } else if (is_deltarays(type[j])) {
181 y *= getDeltaRaysFromMuon(E_emission);
182 }
183 Y += y;
184 }
185 }
186 }
187
188
189 h0.SetBinContent(i, get_value (Y));
190 h1.SetBinContent(i, get_derivative(Y));
191 h2.SetBinContent(i, get_integral (Y));
192 }
193
194 out.Write();
195 out.Close();
196}
string outputFile
Various implementations of functional maps.
Energy loss of muon.
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Auxiliary methods for PDF calculations.
Numbering scheme for PDF types.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Definition JPlotPDF.cc:31
I/O formatting auxiliaries.
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
Utility class to parse command line options.
Definition JParser.hh:1698
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
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).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Simple data structure for histogram binning.
void setBinWidth(const abscissa_type dx, int option=0)
Set bin width.
bool is_valid() const
Check validity of histogram binning.
int getNumberOfBins() const
Get number of bins.
Auxiliary class for recursive map list generation.
Definition JMapList.hh:109
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