Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JNPE_t.hh
Go to the documentation of this file.
1
2#include "JLang/JException.hh"
4#include "JTools/JMap.hh"
5#include "JTools/JGridMap.hh"
6#include "JTools/JMapList.hh"
7#include "JTools/JSpline.hh"
8#include "JTools/JPolint.hh"
9#include "JTools/JElement.hh"
10#include "JPhysics/JNPETable.hh"
11#include "JPhysics/JPDFTable.hh"
13#include "JPhysics/JPDFTypes.hh"
14#include "JPhysics/JGeanz.hh"
15#include "JMath/JZero.hh"
16
17
18/**
19 * \file
20 *
21 * Auxiliary data structure for muon PDF.
22 * \author mdejong
23 */
24struct JMuonNPE_t {
25
30
31
32 /**
33 * Constructor.
34 *
35 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD.\n
36 *
37 * \param fileDescriptor PDF file descriptor
38 */
39 JMuonNPE_t(const std::string& fileDescriptor)
40 {
41 using namespace std;
42 using namespace JPP;
43
44 const JPDFType_t pdf_t[] = { DIRECT_LIGHT_FROM_MUON,
45 SCATTERED_LIGHT_FROM_MUON,
46 DIRECT_LIGHT_FROM_DELTARAYS,
47 SCATTERED_LIGHT_FROM_DELTARAYS,
48 DIRECT_LIGHT_FROM_EMSHOWERS,
49 SCATTERED_LIGHT_FROM_EMSHOWERS };
50
51 const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
52
55 double> JFunction1D_t;
57
58
59 const JNPE_t::JSupervisor supervisor(new JNPE_t::JDefaultResult(zero));
60
61 for (int i = 0; i != N; ++i) {
62
63 JPDF_t pdf;
64
65 const JPDFType_t type = pdf_t[i];
66 const string file_name = getFilename(fileDescriptor, type);
67
68 cout << "loading PDF from file " << file_name << "... " << flush;
69
70 pdf.load(file_name.c_str());
71
72 cout << "OK" << endl;
73
74 pdf.setExceptionHandler(supervisor);
75
76 if (is_bremsstrahlung(type))
77 YB.push_back(JNPE_t(pdf));
78 else if (is_deltarays(type))
79 YA.push_back(JNPE_t(pdf));
80 else
81 Y1.push_back(JNPE_t(pdf));
82 }
83
84 // Add PDFs
85
86 cout << "adding PDFs... " << flush;
87
88 Y1[1].add(Y1[0]); Y1.erase(Y1.begin());
89 YA[1].add(YA[0]); YA.erase(YA.begin());
90 YB[1].add(YB[0]); YB.erase(YB.begin());
91
92 cout << "OK" << endl;
93 }
94
95
96 /**
97 * Get PDF.
98 *
99 * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
100 * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
101 *
102 * \param E muon energy at minimum distance of approach [GeV]
103 * \param R minimum distance of approach [m]
104 * \param theta PMT zenith angle [rad]
105 * \param phi PMT azimuth angle [rad]
106 * \return number of photo-electrons
107 */
108 double calculate(const double E,
109 const double R,
110 const double theta,
111 const double phi) const
112 {
113 using namespace JPP;
114
115 const double y1 = getNPE(Y1, R, theta, phi);
116 const double yA = getNPE(YA, R, theta, phi);
117 const double yB = getNPE(YB, R, theta, phi);
118
119 if (E >= MASS_MUON * INDEX_OF_REFRACTION_WATER)
120 return y1 + getDeltaRaysFromMuon(E) * yA + E * yB;
121 else
122 return 0.0;
123 }
124
125private:
126 std::vector<JNPE_t> Y1; //!< light from muon
127 std::vector<JNPE_t> YA; //!< light from delta-rays
128 std::vector<JNPE_t> YB; //!< light from EM showers
129
130 /**
131 * Get number of photo-electrons.
132 *
133 * \param NPE NPE tables
134 * \param R distance between muon and PMT [m]
135 * \param theta zenith angle orientation PMT [rad]
136 * \param phi azimuth angle orientation PMT [rad]
137 * \return number of photo-electrons
138 */
139 static inline double getNPE(const std::vector<JNPE_t>& NPE,
140 const double R,
141 const double theta,
142 const double phi)
143 {
144 using namespace std;
145 using namespace JPP;
146
147 double npe = 0.0;
148
149 for (vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
150
151 if (R <= i->getXmax()) {
152
153 try {
154
155 const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
156
157 if (y > 0.0) {
158 npe += y;
159 }
160 }
161 catch(const exception& error) {
162 cerr << error.what() << endl;
163 }
164 }
165 }
166
167 return npe;
168 }
169};
170
171
172/**
173 * Auxiliary data structure for shower PDF.
174 */
176
182
183
184 /**
185 * Constructor.
186 *
187 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD.\n
188 *
189 * \param fileDescriptor PDF file descriptor
190 * \param numberOfPoints number of points for shower elongation
191 */
192 JShowerNPE_t(const std::string& fileDescriptor,
193 const int numberOfPoints = 0) :
195 {
196 using namespace std;
197 using namespace JPP;
198
199 const JPDFType_t pdf_t[] = { SCATTERED_LIGHT_FROM_EMSHOWER,
200 DIRECT_LIGHT_FROM_EMSHOWER };
201
202 const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
203
206 double> JFunction1D_t;
208
209
210 const JNPE_t::JSupervisor supervisor(new JNPE_t::JDefaultResult(zero));
211
212 for (int i = 0; i != N; ++i) {
213
214 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
215
216 cout << "loading input from file " << file_name << "... " << flush;
217
218 JPDF_t pdf;
219
220 pdf.load(file_name.c_str());
221
222 pdf.setExceptionHandler(supervisor);
223
224 if (npe.empty())
225 npe = JNPE_t(pdf);
226 else
227 npe.add(JNPE_t(pdf));
228
229 F[i] = JNPE_t(pdf);
230
231 cout << "OK" << endl;
232 }
233 }
234
235
236 /**
237 * Get PDF.
238 *
239 * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
240 * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
241 *
242 * \param E shower energy at minimum distance of approach [GeV]
243 * \param D distance [m]
244 * \param cd cosine emission angle
245 * \param theta PMT zenith angle [rad]
246 * \param phi PMT azimuth angle [rad]
247 * \return hypothesis value
248 */
249 double calculate(const double E,
250 const double D,
251 const double cd,
252 const double theta,
253 const double phi) const
254 {
255 using namespace std;
256 using namespace JPP;
257
258 double Y = 0.0;
259
260 if (numberOfPoints > 0) {
261
262 const double W = 1.0 / (double) numberOfPoints;
263
264 for (int i = 0; i != numberOfPoints; ++i) {
265
266 const double z = geanz.getLength(E, (i + 0.5) / (double) numberOfPoints);
267
268 const double __D = sqrt(D*D - 2.0*(D*cd)*z + z*z);
269 const double __cd = (D * cd - z) / __D;
270
271 try {
272 Y += W * npe (__D, __cd, theta, phi);
273 }
274 catch(const exception& error) {
275 //cerr << error.what() << endl;
276 }
277 }
278
279 } else {
280
281 try {
282 Y = npe(D, cd, theta, phi);
283 }
284 catch(const exception& error) {
285 //cerr << error.what() << endl;
286 }
287 }
288
289 return E * Y;
290 }
291
292private:
294 JNPE_t npe; //!< PDF for shower
295 JNPE_t F[2]; //!< PDF for shower
296};
General purpose class for a collection of sorted elements.
The elements in a collection are sorted according to their abscissa values and a given distance opera...
Exceptions.
Longitudinal emission profile EM-shower.
Auxiliary methods for PDF calculations.
Numbering scheme for PDF types.
Definition of zero value for any class.
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:46
void add(const JNPETable &input)
Add NPE table.
Definition JNPETable.hh:130
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
General purpose class for collection of elements, see: <a href="JTools.PDF";>Collection of elements....
Definition JSet.hh:22
Template class for spline interpolation in 1D.
Definition JSpline.hh:734
JPDFType_t
PDF types.
Definition JPDFTypes.hh:24
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JNPE_t > YA
light from delta-rays
Definition JNPE_t.hh:127
std::vector< JNPE_t > YB
light from EM showers
Definition JNPE_t.hh:128
JPP::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Definition JNPE_t.hh:29
double calculate(const double E, const double R, const double theta, const double phi) const
Get PDF.
Definition JNPE_t.hh:108
JPP::JMAPLIST< JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalGridMap, JPP::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
Definition JNPE_t.hh:28
static double getNPE(const std::vector< JNPE_t > &NPE, const double R, const double theta, const double phi)
Get number of photo-electrons.
Definition JNPE_t.hh:139
JMuonNPE_t(const std::string &fileDescriptor)
Constructor.
Definition JNPE_t.hh:39
std::vector< JNPE_t > Y1
light from muon
Definition JNPE_t.hh:126
Auxiliary data structure for shower PDF.
Definition JNPE_t.hh:175
JNPE_t npe
PDF for shower.
Definition JNPE_t.hh:294
JNPE_t F[2]
PDF for shower.
Definition JNPE_t.hh:295
JShowerNPE_t(const std::string &fileDescriptor, const int numberOfPoints=0)
Constructor.
Definition JNPE_t.hh:192
JPP::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Definition JNPE_t.hh:181
JPP::JMAPLIST< JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalGridMap, JPP::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
Definition JNPE_t.hh:180
int numberOfPoints
Definition JNPE_t.hh:293
double calculate(const double E, const double D, const double cd, const double theta, const double phi) const
Get PDF.
Definition JNPE_t.hh:249
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.