Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JDrawPD0.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"
15#include "JTools/JQuantiles.hh"
17#include "Jeep/JProperties.hh"
18#include "Jeep/JPrint.hh"
19#include "Jeep/JParser.hh"
20#include "Jeep/JMessage.hh"
21
22
23/**
24 * \file
25 *
26 * Auxiliary program to draw PDF of Cherenkov light from bright point.
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33
35
36 string outputFile;
38 double epsilon;
39 JAbsorptionLength absorptionLength;
40 JScatteringLength scatteringLength;
41 JScatteringProbability scatteringProbability;
42 double E;
43 double D;
44 double ct;
45 vector<int> function;
46 JHistogram_t histogram;
47 int debug;
48
49 try {
50
51 JProperties properties;
52
53 properties.insert(gmake_property(absorptionLength));
54 properties.insert(gmake_property(scatteringLength));
55 properties.insert(gmake_property(scatteringProbability));
56
57 JParser<> zap("Auxiliary program to draw PDF of Cherenkov light from bright point.");
58
59 zap['@'] = make_field(properties, endl
60 << "possible options absorptionLength: " << get_keys(absorptionLength) << endl
61 << "possible options scatteringLength: " << get_keys(scatteringLength) << endl
62 << "possible options scatteringProbability: " << get_keys(scatteringProbability) << endl) = JPARSER::initialised();
63 zap['o'] = make_field(outputFile) = "";
64 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
65 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
66 zap['E'] = make_field(E, "shower energy [GeV]");
67 zap['R'] = make_field(D, "distance [m]");
68 zap['c'] = make_field(ct, "cosine PMT angle");
69 zap['F'] = make_field(function, "PDF type");
70 zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
71 zap['d'] = make_field(debug) = 0;
72
73 zap(argc, argv);
74 }
75 catch(const exception &error) {
76 FATAL(error.what() << endl);
77 }
78
79
80 const JPDF_C
81 pdf(NAMESPACE::getPhotocathodeArea(),
82 NAMESPACE::getQE,
83 NAMESPACE::getAngularAcceptance,
84 JAbsorptionLength::getAbsorptionLength,
85 JScatteringLength::getScatteringLength,
86 JScatteringProbability::getScatteringProbability,
87 NAMESPACE::getAmbientPressure(),
88 getMinimalWavelength(),
89 getMaximalWavelength(),
91 epsilon);
92
93
94 if (outputFile == "") {
95
96 cout << "enter time (^C to exit) > " << flush;
97
98 for (double dt; cin >> dt; ) {
99
100 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
101
102 cout << setw(2) << *F << ' '
103 << SCIENTIFIC(7,1) << E << ' '
104 << FIXED(5,1) << D << ' '
105 << FIXED(5,2) << ct << ' '
106 << FIXED(5,1) << dt << ' '
107 << SCIENTIFIC(9,3) << pdf.getLightFromBrightPoint(*F, D, ct, dt) * E << endl;
108 }
109 }
110
111 return 0;
112 }
113
114
115 TFile out(outputFile.c_str(), "recreate");
116
117 //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
118 const double t0 = 0.0; // time [ns]
119
120 if (!histogram.is_valid()) {
121
122 if (function.size() == 1 && function[0] == DIRECT_LIGHT_FROM_BRIGHT_POINT) {
123
124 histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
125
126 histogram.setBinWidth(0.1);
127
128 } else {
129
130 histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
131
132 histogram.setBinWidth(0.5);
133 }
134 }
135
136 TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
137
139
140 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
141
142 const double dt = h0.GetBinCenter(i) - t0;
143
144 double value = 0.0;
145
146 for (vector<int>::const_iterator F = function.begin(); F != function.end(); ++F) {
147 value += pdf.getLightFromBrightPoint(*F, D, ct, dt) * E;
148 }
149
150 h0.SetBinContent(i, value);
151
152 f1[dt] = value;
153 }
154
155 f1.compile();
156
157 try {
158
159 JQuantiles quantiles(f1);
160
161 DEBUG("int " << quantiles.getIntegral() << endl);
162 DEBUG("x " << quantiles.getX() << endl);
163 DEBUG("y " << quantiles.getY() << endl);
164 DEBUG("FWHM " << quantiles.getFWHM() << endl);
165 }
166 catch(const exception&) {}
167
168 out.Write();
169 out.Close();
170}
Properties of Antares PMT and deep-sea water.
string outputFile
int main(int argc, char **argv)
Definition JDrawPD0.cc:29
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:74
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.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse parameter values.
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 getLightFromBrightPoint(const int type, const double D_m, const double ct, const double t_ns) const
Probability density function for direct light from isotropic light source.
Definition JPDF.hh:1929
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
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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary data structure to customize absorption length.
Auxiliary data structure to customize scattering length.
Auxiliary data structure to customize scattering probability.
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.
Type definition of a spline interpolation method based on a JCollection with double result type.
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488