Jpp test-rotations-old-533-g2bdbdb559
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"
12#include "JPhysics/JPDFTypes.hh"
13#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[] = {
45 DIRECT_LIGHT_FROM_MUON,
46 SCATTERED_LIGHT_FROM_MUON,
47 DIRECT_LIGHT_FROM_DELTARAYS,
48 SCATTERED_LIGHT_FROM_DELTARAYS,
49 DIRECT_LIGHT_FROM_EMSHOWERS,
50 SCATTERED_LIGHT_FROM_EMSHOWERS
51 };
52
53 const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
54
57 double> JFunction1D_t;
59
60
61 const JNPE_t::JSupervisor supervisor(new JNPE_t::JDefaultResult(zero));
62
63 for (int i = 0; i != N; ++i) {
64
65 JPDF_t pdf;
66
67 const JPDFType_t type = pdf_t[i];
68 const string file_name = getFilename(fileDescriptor, type);
69
70 cout << "loading PDF from file " << file_name << "... " << flush;
71
72 pdf.load(file_name.c_str());
73
74 cout << "OK" << endl;
75
76 pdf.setExceptionHandler(supervisor);
77
78 if (is_bremsstrahlung(type))
79 YB.push_back(JNPE_t(pdf));
80 else if (is_deltarays(type))
81 YA.push_back(JNPE_t(pdf));
82 else
83 Y1.push_back(JNPE_t(pdf));
84 }
85
86 // Add PDFs
87
88 cout << "adding PDFs... " << flush;
89
90 Y1[1].add(Y1[0]); Y1.erase(Y1.begin());
91 YA[1].add(YA[0]); YA.erase(YA.begin());
92 YB[1].add(YB[0]); YB.erase(YB.begin());
93
94 cout << "OK" << endl;
95 }
96
97
98 /**
99 * Get PDF.
100 *
101 * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
102 * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
103 *
104 * \param E muon energy at minimum distance of approach [GeV]
105 * \param R minimum distance of approach [m]
106 * \param theta PMT zenith angle [rad]
107 * \param phi PMT azimuth angle [rad]
108 * \return number of photo-electrons
109 */
110 double calculate(const double E,
111 const double R,
112 const double theta,
113 const double phi) const
114 {
115 using namespace JPP;
116
117 const double y1 = getNPE(Y1, R, theta, phi);
118 const double yA = getNPE(YA, R, theta, phi);
119 const double yB = getNPE(YB, R, theta, phi);
120
121 if (E >= MASS_MUON * INDEX_OF_REFRACTION_WATER)
122 return y1 + JDeltaRays::getEnergyLossFromMuon(E) * yA + E * yB;
123 else
124 return 0.0;
125 }
126
127private:
128 std::vector<JNPE_t> Y1; //!< light from muon
129 std::vector<JNPE_t> YA; //!< light from delta-rays
130 std::vector<JNPE_t> YB; //!< light from EM showers
131
132 /**
133 * Get number of photo-electrons.
134 *
135 * \param NPE NPE tables
136 * \param R distance between muon and PMT [m]
137 * \param theta zenith angle orientation PMT [rad]
138 * \param phi azimuth angle orientation PMT [rad]
139 * \return number of photo-electrons
140 */
141 static inline double getNPE(const std::vector<JNPE_t>& NPE,
142 const double R,
143 const double theta,
144 const double phi)
145 {
146 using namespace std;
147 using namespace JPP;
148
149 double npe = 0.0;
150
151 for (vector<JNPE_t>::const_iterator i = NPE.begin(); i != NPE.end(); ++i) {
152
153 if (R <= i->getXmax()) {
154
155 try {
156
157 const double y = get_value((*i)(std::max(R, i->getXmin()), theta, phi));
158
159 if (y > 0.0) {
160 npe += y;
161 }
162 }
163 catch(const exception& error) {
164 cerr << error.what() << endl;
165 }
166 }
167 }
168
169 return npe;
170 }
171};
172
173
174/**
175 * Auxiliary data structure for shower PDF.
176 */
178
184
185
186 /**
187 * Constructor.
188 *
189 * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD.\n
190 *
191 * \param fileDescriptor PDF file descriptor
192 * \param numberOfPoints number of points for shower elongation
193 */
194 JShowerNPE_t(const std::string& fileDescriptor,
195 const int numberOfPoints = 0) :
197 {
198 using namespace std;
199 using namespace JPP;
200
201 const JPDFType_t pdf_t[] = {
202 SCATTERED_LIGHT_FROM_EMSHOWER,
203 DIRECT_LIGHT_FROM_EMSHOWER
204 };
205
206 const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
207
210 double> JFunction1D_t;
212
213
214 const JNPE_t::JSupervisor supervisor(new JNPE_t::JDefaultResult(zero));
215
216 for (int i = 0; i != N; ++i) {
217
218 const string file_name = getFilename(fileDescriptor, pdf_t[i]);
219
220 cout << "loading input from file " << file_name << "... " << flush;
221
222 JPDF_t pdf;
223
224 pdf.load(file_name.c_str());
225
226 pdf.setExceptionHandler(supervisor);
227
228 if (npe.empty())
229 npe = JNPE_t(pdf);
230 else
231 npe.add(JNPE_t(pdf));
232
233 F[i] = JNPE_t(pdf);
234
235 cout << "OK" << endl;
236 }
237 }
238
239
240 /**
241 * Get PDF.
242 *
243 * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
244 * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
245 *
246 * \param E shower energy at minimum distance of approach [GeV]
247 * \param D distance [m]
248 * \param cd cosine emission angle
249 * \param theta PMT zenith angle [rad]
250 * \param phi PMT azimuth angle [rad]
251 * \return hypothesis value
252 */
253 double calculate(const double E,
254 const double D,
255 const double cd,
256 const double theta,
257 const double phi) const
258 {
259 using namespace std;
260 using namespace JPP;
261
262 double Y = 0.0;
263
264 if (numberOfPoints > 0) {
265
266 const double W = 1.0 / (double) numberOfPoints;
267
268 for (int i = 0; i != numberOfPoints; ++i) {
269
270 const double z = geanz.getLength(E, (i + 0.5) / (double) numberOfPoints);
271
272 const double __D = sqrt(D*D - 2.0*(D*cd)*z + z*z);
273 const double __cd = (D * cd - z) / __D;
274
275 try {
276 Y += W * npe (__D, __cd, theta, phi);
277 }
278 catch(const exception& error) {
279 //cerr << error.what() << endl;
280 }
281 }
282
283 } else {
284
285 try {
286 Y = npe(D, cd, theta, phi);
287 }
288 catch(const exception& error) {
289 //cerr << error.what() << endl;
290 }
291 }
292
293 return E * Y;
294 }
295
296private:
298 JNPE_t npe; //!< PDF for shower
299 JNPE_t F[2]; //!< PDF for shower
300};
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.
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:129
std::vector< JNPE_t > YB
light from EM showers
Definition JNPE_t.hh:130
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:110
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:141
JMuonNPE_t(const std::string &fileDescriptor)
Constructor.
Definition JNPE_t.hh:39
std::vector< JNPE_t > Y1
light from muon
Definition JNPE_t.hh:128
Auxiliary data structure for shower PDF.
Definition JNPE_t.hh:177
JNPE_t npe
PDF for shower.
Definition JNPE_t.hh:298
JNPE_t F[2]
PDF for shower.
Definition JNPE_t.hh:299
JShowerNPE_t(const std::string &fileDescriptor, const int numberOfPoints=0)
Constructor.
Definition JNPE_t.hh:194
JPP::JNPETable< double, double, JNPEMaplist_t > JNPE_t
Definition JNPE_t.hh:183
JPP::JMAPLIST< JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalGridMap, JPP::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
Definition JNPE_t.hh:182
int numberOfPoints
Definition JNPE_t.hh:297
double calculate(const double E, const double D, const double cd, const double theta, const double phi) const
Get PDF.
Definition JNPE_t.hh:253
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.