Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JMakePD0.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <fstream>
4#include <iomanip>
5#include <set>
6#include <map>
7#include <cmath>
8
11#include "JTools/JQuadrature.hh"
12
13#include "JPhysics/JPDF.hh"
14#include "JPhysics/JPDFTable.hh"
15#include "JPhysics/Antares.hh"
16#include "JPhysics/KM3NeT.hh"
18
19#include "Jeep/JProperties.hh"
20#include "Jeep/JParser.hh"
21#include "Jeep/JMessage.hh"
22
23
24/**
25 * \file
26 *
27 * Program to create interpolation tables of the PDF of the arrival time of the Cherenkov light from a bright point.
28 *
29 * The PDFs are tabulated as a function of <tt>(D, cos(theta), t)</tt>, where:
30 * - <tt>D</tt> is the distance between the bright point and the PMT;
31 * - <tt>cos(theta)</tt> the cosine of the PMT angle;
32 * - <tt>t</tt> the arrival time of the light with respect to the Cherenkov hypothesis.
33 *
34 * The orientation of the PMT is defined in the coordinate system in which
35 * the position of the bright point and that of the PMT are along the x-axis and the PMT is oriented in the x-y plane.
36 * \author mdejong
37 */
38int main(int argc, char **argv)
39{
40 using namespace std;
41 using namespace JPP;
42
43 string outputFile;
45 double epsilon;
46 JAbsorptionLength absorptionLength;
47 JScatteringLength scatteringLength;
48 JScatteringProbability scatteringProbability;
49 int function;
50 set<double> D; // distance [m]
51 int debug;
52
53 try {
54
55 JProperties properties;
56
57 properties.insert(gmake_property(absorptionLength));
58 properties.insert(gmake_property(scatteringLength));
59 properties.insert(gmake_property(scatteringProbability));
60
61 JParser<> zap("Program to create interpolation tables of the PDF of the arrival time of the Cherenkov light from a bright point.");
62
63 zap['@'] = make_field(properties, endl
64 << "possible options absorptionLength: " << get_keys(absorptionLength) << endl
65 << "possible options scatteringLength: " << get_keys(scatteringLength) << endl
66 << "possible options scatteringProbability: " << get_keys(scatteringProbability) << endl) = JPARSER::initialised();
67 zap['o'] = make_field(outputFile);
68 zap['n'] = make_field(numberOfPoints, "points for integration") = 25;
69 zap['e'] = make_field(epsilon, "precision for integration") = 1.0e-10;
70 zap['F'] = make_field(function, "PDF type") =
71 DIRECT_LIGHT_FROM_BRIGHT_POINT,
72 SCATTERED_LIGHT_FROM_BRIGHT_POINT;
73 zap['D'] = make_field(D, "distance [m]") = JPARSER::initialised();
74 zap['d'] = make_field(debug) = 0;
75
76 zap['F'] = JPARSER::not_initialised();
77
78 zap(argc, argv);
79 }
80 catch(const exception &error) {
81 FATAL(error.what() << endl);
82 }
83
84
85 typedef double (JPDF::*fcn)(const double,
86 const double,
87 const double) const;
88
89
90 // set global parameters
91
92 const double P_atm = NAMESPACE::getAmbientPressure();
93 const double wmin = getMinimalWavelength();
94 const double wmax = getMaximalWavelength();
95
96
97 const JPDF_C
98 pdf_c(NAMESPACE::getPhotocathodeArea(),
99 NAMESPACE::getQE,
100 NAMESPACE::getAngularAcceptance,
101 JAbsorptionLength::getAbsorptionLength,
102 JScatteringLength::getScatteringLength,
103 JScatteringProbability::getScatteringProbability,
104 P_atm,
105 wmin,
106 wmax,
108 epsilon);
109
110
111 typedef JSplineFunction1D_t JFunction1D_t;
113 JPolint1FunctionalGridMap>::maplist JMapList_t;
115
116 typedef JPDFTransformer<2, JFunction1D_t::argument_type> JFunction2DTransformer_t;
118
119 JPDF_t pdf;
120
121
122 NOTICE("building multi-dimensional function object <" << function << ">... " << flush);
123
124 const double ng[] = {
125 pdf_c.getIndexOfRefractionGroup(wmax),
126 pdf_c.getIndexOfRefractionGroup(wmin)
127 };
128
130
131 zmap[DIRECT_LIGHT_FROM_BRIGHT_POINT] = make_pair((fcn) &JPDF::getDirectLightFromBrightPoint, JFunction2DTransformer_t(21.5, 2, ng[0], ng[1]));
132 zmap[SCATTERED_LIGHT_FROM_BRIGHT_POINT] = make_pair((fcn) &JPDF::getScatteredLightFromBrightPoint, JFunction2DTransformer_t(21.5, 2, ng[0], 0.0));
133
134 if (zmap.find(function) == zmap.end()) {
135 FATAL("illegal function specifier" << endl);
136 }
137
138 fcn f = zmap[function].first; // PDF
139 JFunction2DTransformer_t transformer = zmap[function].second; // transformer
140
141
142 if (D.empty()) {
143 D.insert( 0.10);
144 D.insert( 0.50);
145 D.insert( 1.00);
146 D.insert( 5.00);
147 D.insert( 10.00);
148 D.insert( 20.00);
149 D.insert( 30.00);
150 D.insert( 40.00);
151 D.insert( 50.00);
152 D.insert( 60.00);
153 D.insert( 70.00);
154 D.insert( 80.00);
155 D.insert( 90.00);
156 D.insert(100.00);
157 }
158
159 set<double> X; // time [ns]
160
161 if (function == DIRECT_LIGHT_FROM_BRIGHT_POINT) {
162
163 for (double buffer[] = { 0.0, 0.005, 0.01, 0.015, -1 }, *x = buffer; *x >= 0; ++x) {
164 X.insert(0.0 + *x);
165 X.insert(1.0 - *x);
166 }
167
168 for (double x = 0.02; x < 0.99; x += 0.01)
169 X.insert(x);
170
171 } else {
172
173 X.insert( 0.00);
174 X.insert( 0.10);
175 X.insert( 0.20);
176 X.insert( 0.30);
177 X.insert( 0.40);
178 X.insert( 0.50);
179 X.insert( 0.60);
180 X.insert( 0.70);
181 X.insert( 0.80);
182 X.insert( 0.90);
183 X.insert( 1.00);
184 X.insert( 1.00);
185 X.insert( 1.10);
186 X.insert( 1.20);
187 X.insert( 1.30);
188 X.insert( 1.40);
189 X.insert( 1.50);
190 X.insert( 1.60);
191 X.insert( 1.70);
192 X.insert( 1.80);
193 X.insert( 1.90);
194 X.insert( 2.00);
195 X.insert( 2.20);
196 X.insert( 2.40);
197 X.insert( 2.60);
198 X.insert( 2.80);
199 X.insert( 3.00);
200 X.insert( 3.25);
201 X.insert( 3.50);
202 X.insert( 3.75);
203 X.insert( 4.00);
204 X.insert( 4.25);
205 X.insert( 4.50);
206 X.insert( 4.75);
207 X.insert( 5.0);
208 X.insert( 6.0);
209 X.insert( 7.0);
210 X.insert( 8.0);
211 X.insert( 9.0);
212 X.insert( 10.0);
213 X.insert( 15.0);
214 X.insert( 20.0);
215 X.insert( 25.0);
216 X.insert( 30.0);
217 X.insert( 40.0);
218 X.insert( 50.0);
219 X.insert( 60.0);
220 X.insert( 70.0);
221 X.insert( 80.0);
222 X.insert( 90.0);
223 X.insert(100.0);
224 X.insert(120.0);
225 X.insert(140.0);
226 X.insert(160.0);
227 X.insert(180.0);
228 X.insert(200.0);
229 }
230
231
232 for (set<double>::const_iterator d = D.begin(); d != D.end(); ++d) {
233
234 const double D_m = *d;
235
236 for (double dc = 0.1, ct = -1.0; ct < +1.0 + 0.5*dc; ct += dc) {
237
238 JFunction1D_t& f1 = pdf[D_m][ct];
239
240 const JArray_t array(D_m, ct);
241
242 double t_old = transformer.getXn(array, *X.begin());
243 double y_old = 0.0;
244
245 for (set<double>::const_iterator x = X.begin(); x != X.end(); ++x) {
246
247 const double t = transformer.getXn(array, *x);
248 const double y = (pdf_c.*f)(D_m, ct, t);
249
250 if (y != 0.0) {
251
252 if (*x < 0.0) {
253 WARNING("dt < 0 " << *x << ' ' << D_m << ' ' << t << ' ' << y << endl);
254 }
255
256 if (y_old == 0.0) {
257 f1[t_old] = y_old;
258 }
259
260 f1[t] = y;
261
262 } else {
263
264 if (y_old != 0.0) {
265 f1[t] = y;
266 }
267 }
268
269 t_old = t;
270 y_old = y;
271 }
272 }
273 }
274
275 pdf.transform(transformer);
276 pdf.compile();
277
278 NOTICE("OK" << endl);
279
280 try {
281
282 NOTICE("storing output to file " << outputFile << "... " << flush);
283
284 pdf.store(outputFile.c_str());
285
286 NOTICE("OK" << endl);
287 }
288 catch(const JException& error) {
289 FATAL(error.what() << endl);
290 }
291}
Properties of Antares PMT and deep-sea water.
string outputFile
Various implementations of functional maps.
int main(int argc, char **argv)
Definition JMakePD0.cc:38
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
#define WARNING(A)
Definition JMessage.hh:65
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary classes for numerical integration.
int numberOfPoints
Definition JResultPDF.cc:22
Properties of KM3NeT PMT and deep-sea water.
Utility class to parse parameter values.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
virtual double getIndexOfRefractionGroup(const double lambda) const
Index of refraction for group velocity.
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
Template definition of transformer of the probability density function (PDF) of the time response of ...
Probability Density Functions of the time response of a PMT with an implementation of the JAbstractPM...
Definition JPDF.hh:2186
One dimensional array of template objects with fixed length.
Definition JArray.hh:43
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Empty structure for specification of parser element that is not initialised (i.e. does require input)...
Definition JParser.hh:74
Auxiliary data structure for muon PDF.
Definition JPDF_t.hh:26
Auxiliary data structure to customize absorption length.
Auxiliary data structure to customize scattering length.
Auxiliary data structure to customize scattering probability.
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 double result type.