Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JDrawPDG.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9
10#include "JPhysics/JPDF.hh"
11#include "JPhysics/Antares.hh"
12#include "JPhysics/KM3NeT.hh"
13#include "JTools/JSpline.hh"
14#include "JTools/JQuantiles.hh"
17#include "Jeep/JPrint.hh"
18#include "Jeep/JParser.hh"
19#include "Jeep/JMessage.hh"
20
21
22/**
23 * Scaling of absorption and scattering length.
24 */
27
28inline double getAbsorptionLength(const double lambda)
29{
30 return absorptionLengthFactor * NAMESPACE::getAbsorptionLength(lambda);
31}
32
33
34inline double getScatteringLength(const double lambda)
35{
36 return scatteringLengthFactor * NAMESPACE::getScatteringLength(lambda);
37}
38
39
40/**
41 * \file
42 *
43 * Auxiliary program to draw PDF of Cherenkov light from EM-shower.
44 * \author mdejong
45 */
46int main(int argc, char **argv)
47{
48 using namespace std;
49 using namespace JPP;
50
52
53 string outputFile;
55 double epsilon;
56 double E;
57 double D;
58 double cd;
59 JAngle3D dir;
60 vector<int> function;
61 JHistogram_t histogram;
62 int debug;
63
64 try {
65
66 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from EM-shower.");
67
68 zap['o'] = make_field(outputFile) = "";
69 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
70 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
71 zap['A'] = make_field(absorptionLengthFactor, "scaling factor") = 1.0;
72 zap['S'] = make_field(scatteringLengthFactor, "scaling factor") = 1.0;
73 zap['E'] = make_field(E, "shower energy [GeV]") = 1.0;
74 zap['R'] = make_field(D, "distance [m]");
75 zap['c'] = make_field(cd, "cosine emission angle");
76 zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
77 zap['F'] = make_field(function, "PDF type");
78 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
79 zap['d'] = make_field(debug) = 0;
80
81 zap(argc, argv);
82 }
83 catch(const exception &error) {
84 FATAL(error.what() << endl);
85 }
86
87
88 const JPDF_C
89 pdf(NAMESPACE::getPhotocathodeArea(),
90 NAMESPACE::getQE,
91 NAMESPACE::getAngularAcceptance,
94 NAMESPACE::getScatteringProbability,
95 NAMESPACE::getAmbientPressure(),
96 getMinimalWavelength(),
97 getMaximalWavelength(),
99 epsilon);
100
101
102 if (outputFile == "") {
103
104 cout << "enter time (^C to exit) > " << flush;
105
106 for (double dt; cin >> dt; ) {
107
108 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
109
110 cout << setw(2) << *F << ' '
111 << SCIENTIFIC(7,1) << E << ' '
112 << FIXED(5,1) << D << ' '
113 << FIXED(5,2) << cd << ' '
114 << FIXED(5,2) << dir.getTheta() << ' '
115 << FIXED(5,2) << dir.getPhi() << ' '
116 << FIXED(5,1) << dt << ' '
117 << SCIENTIFIC(9,3) << pdf.getLightFromEMshower(*F, E, D, cd, dir.getTheta(), dir.getPhi(), dt) * E << endl;
118 }
119 }
120
121 return 0;
122 }
123
124
125 TFile out(outputFile.c_str(), "recreate");
126
127 //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
128 const double t0 = 0.0; // time [ns]
129
130 if (!histogram.is_valid()) {
131
132 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_MUON) {
133
134 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
135
136 histogram.setBinWidth(0.1);
137
138 } else {
139
140 histogram = JHistogram_t(t0 - 20.0, t0 + 1000.0);
141
142 histogram.setBinWidth(0.5);
143 }
144 }
145
146 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
147
149
150 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
151
152 const double dt = h0.GetBinCenter(i) - t0;
153
154 double value = 0.0;
155
156 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
157 if (*F == SCATTERED_LIGHT_FROM_MUON_5D)
158 value += pdf.getScatteredLightFromMuon(D, cd, dir.getTheta(), dir.getPhi(), dt);
159 else
160 value += pdf.getLightFromEMshower(*F, D, cd, dir.getTheta(), dir.getPhi(), dt) * E;
161 }
162
163 h0.SetBinContent(i, value);
164
165 f1[dt] = value;
166 }
167
168 f1.setExceptionHandler(new JSplineFunction1S_t::JDefaultResult(JMATH::zero));
169 f1.compile();
170
171 try {
172
173 JQuantiles quantiles(f1);
174
175 DEBUG("int " << quantiles.getIntegral() << endl);
176 DEBUG("x " << quantiles.getX() << endl);
177 DEBUG("y " << quantiles.getY() << endl);
178 DEBUG("FWHM " << quantiles.getFWHM() << endl);
179 }
180 catch(const exception&) {}
181
182 out.Write();
183 out.Close();
184}
Properties of Antares PMT and deep-sea water.
string outputFile
int main(int argc, char **argv)
Definition JDrawPDG.cc:46
double getAbsorptionLength(const double lambda)
Definition JDrawPDG.cc:28
double getScatteringLength(const double lambda)
Definition JDrawPDG.cc:34
double absorptionLengthFactor
Scaling of absorption and scattering length.
Definition JDrawPDG.cc:25
double scatteringLengthFactor
Definition JDrawPDG.cc:26
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
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
Utility class to parse command line options.
Definition JParser.hh:1698
Probability Density Functions of the time response of a PMT with an implementation of the JAbstractPM...
Definition JPDF.hh:2186
double getLightFromEMshower(const int type, const double D_m, const double cd, const double theta, const double phi, const double t_ns) const
Probability density function for light from EM-shower.
Definition JPDF.hh:1821
double getScatteredLightFromMuon(const double R_m, const double theta, const double phi, const double t_ns) const
Probability density function for scattered light from muon.
Definition JPDF.hh:497
Quantile calculator for a given interpolating function.
Definition JQuantiles.hh:34
double getIntegral() const
Get integral of function.
double getY() const
Get value of maximum.
double getX() const
Get position of maximum.
double getFWHM() const
Get Full Width at Half Maximum.
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.
void setExceptionHandler(const JSupervisor &supervisor)
Set the supervisor for handling of exceptions.
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