Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPDF_t.hh
Go to the documentation of this file.
1 #include "JLang/JException.hh"
2 #include "JTools/JCollection.hh"
3 #include "JTools/JMap.hh"
4 #include "JTools/JGridMap.hh"
5 #include "JTools/JMapList.hh"
6 #include "JTools/JSpline.hh"
7 #include "JTools/JPolint.hh"
8 #include "JTools/JElement.hh"
9 #include "JTools/JResult.hh"
10 #include "JPhysics/JPDFTable.hh"
11 #include "JPhysics/JPDFToolkit.hh"
12 #include "JPhysics/JPDFTypes.hh"
13 #include "JMath/JZero.hh"
14 
15 
16 /**
17  * Auxiliary data structure for muon PDF.
18  */
19 struct JMuonPDF_t {
20 
24 
30 
31 
32  /**
33  * Constructor.
34  *
35  * The PDF file descriptor should contain the wild card character JPHYSICS::WILD_CARD.\n
36  * The <tt>TTS</tt> corresponds to the additional time smearing applied to the PDFs.
37  *
38  * \param fileDescriptor PDF file descriptor
39  * \param TTS TTS [ns]
40  * \param numberOfPoints number of points for Gauss-Hermite integration of TTS
41  * \param epsilon precision for Gauss-Hermite integration of TTS
42  */
43  JMuonPDF_t(const std::string& fileDescriptor,
44  const double TTS,
45  const int numberOfPoints = 25,
46  const double epsilon = 1.0e-10)
47  {
48  using namespace std;
49  using namespace JPP;
50 
51  const JPDFType_t pdf_t[] = { DIRECT_LIGHT_FROM_MUON,
57 
58  const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
59 
60  JPDF_t pdf[N];
61 
62  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(zero));
63 
64  for (int i = 0; i != N; ++i) {
65 
66  const string file_name = getFilename(fileDescriptor, pdf_t[i]);
67 
68  cout << "loading input from file " << file_name << "... " << flush;
69 
70  pdf[i].load(file_name.c_str());
71 
72  pdf[i].setExceptionHandler(supervisor);
73 
74  cout << "OK" << endl;
75  }
76 
77  // Add PDFs
78 
79  cout << "adding PDFs... " << flush;
80 
81  pdfA = pdf[1]; pdfA.add(pdf[0]);
82  pdfB = pdf[3]; pdfB.add(pdf[2]);
83  pdfC = pdf[5]; pdfC.add(pdf[4]);
84 
85  cout << "OK" << endl;
86 
87  if (TTS > 0.0) {
88 
89  cout << "bluring PDFs... " << flush;
90 
91  pdfA.blur(TTS, numberOfPoints, epsilon);
92  pdfB.blur(TTS, numberOfPoints, epsilon);
93  pdfC.blur(TTS, numberOfPoints, epsilon);
94 
95  cout << "OK" << endl;
96 
97  } else if (TTS < 0.0) {
98 
99  THROW(JValueOutOfRange, "Illegal value of TTS [ns]: " << TTS);
100  }
101  }
102 
103 
104  /**
105  * Get PDF.
106  *
107  * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
108  * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
109  *
110  * \param E muon energy at minimum distance of approach [GeV]
111  * \param R minimum distance of approach [m]
112  * \param theta PMT zenith angle [rad]
113  * \param phi PMT azimuth angle [rad]
114  * \param t1 arrival time relative to Cherenkov hypothesis [ns]
115  * \return hypothesis value
116  */
117  result_type calculate(const double E,
118  const double R,
119  const double theta,
120  const double phi,
121  const double t1) const
122  {
123  using namespace JPP;
124 
125  result_type h1 = (pdfA(R, theta, phi, t1) +
126  pdfB(R, theta, phi, t1) * E +
127  pdfC(R, theta, phi, t1) * getDeltaRaysFromMuon(E));
128 
129  // safety measures
130 
131  if (h1.f <= 0.0) {
132  h1.f = 0.0;
133  h1.fp = 0.0;
134  }
135 
136  if (h1.v <= 0.0) {
137  h1.v = 0.0;
138  }
139 
140  return h1;
141  }
142 
143  JPDF_t pdfA; //!< PDF for minimum ionisong particle
144  JPDF_t pdfB; //!< PDF for average energy losses
145  JPDF_t pdfC; //!< PDF for delta-rays
146 };
147 
148 
149 /**
150  * Auxiliary data structure for shower PDF.
151  */
152 struct JShowerPDF_t {
153 
157 
164 
165 
166  /**
167  * Constructor.
168  *
169  * The PDF file descriptor should contain the wild card character JPHYSICS::WILD_CARD.\n
170  * The <tt>TTS</tt> corresponds to the additional time smearing applied to the PDFs.
171  *
172  * \param fileDescriptor PDF file descriptor
173  * \param TTS TTS [ns]
174  * \param numberOfPoints number of points for Gauss-Hermite integration of TTS
175  * \param epsilon precision for Gauss-Hermite integration of TTS
176  */
177  JShowerPDF_t(const std::string& fileDescriptor,
178  const double TTS,
179  const int numberOfPoints = 25,
180  const double epsilon = 1.0e-10)
181  {
182  using namespace std;
183  using namespace JPP;
184 
185  const JPDFType_t pdf_t[] = { SCATTERED_LIGHT_FROM_EMSHOWER,
187 
188  const int N = sizeof(pdf_t) / sizeof(pdf_t[0]);
189 
190  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(zero));
191 
192  for (int i = 0; i != N; ++i) {
193 
194  const string file_name = getFilename(fileDescriptor, pdf_t[i]);
195 
196  cout << "loading input from file " << file_name << "... " << flush;
197 
198  JPDF_t pdf;
199 
200  pdf.load(file_name.c_str());
201 
202  pdf.setExceptionHandler(supervisor);
203 
204  if (pdfA.empty())
205  pdfA = pdf;
206  else
207  pdfA.add(pdf);
208 
209  cout << "OK" << endl;
210  }
211 
212  if (TTS > 0.0) {
213 
214  cout << "bluring PDFs... " << flush;
215 
216  pdfA.blur(TTS, numberOfPoints, epsilon);
217 
218  cout << "OK" << endl;
219 
220  } else if (TTS < 0.0) {
221 
222  THROW(JValueOutOfRange, "Illegal value of TTS [ns]: " << TTS);
223  }
224  }
225 
226 
227  /**
228  * Get PDF.
229  *
230  * The orientation of the PMT should be defined according this <a href="https://common.pages.km3net.de/jpp/JPDF.PDF">documentation</a>.\n
231  * In this, the zenith and azimuth angles are limited to \f[\left[0, \pi\right]\f].
232  *
233  * \param E shower energy at minimum distance of approach [GeV]
234  * \param D distance [m]
235  * \param cd cosine emission angle
236  * \param theta PMT zenith angle [rad]
237  * \param phi PMT azimuth angle [rad]
238  * \param t1 arrival time relative to Cherenkov hypothesis [ns]
239  * \return hypothesis value
240  */
241  result_type calculate(const double E,
242  const double D,
243  const double cd,
244  const double theta,
245  const double phi,
246  const double t1) const
247  {
248  using namespace JPP;
249 
250  result_type h1 = pdfA(D, cd, theta, phi, t1) * E;
251 
252  // safety measures
253 
254  if (h1.f <= 0.0) {
255  h1.f = 0.0;
256  h1.fp = 0.0;
257  }
258 
259  if (h1.v <= 0.0) {
260  h1.v = 0.0;
261  }
262 
263  return h1;
264  }
265 
266  JPDF_t pdfA; //!< PDF for shower
267 };
void load(const char *file_name)
Load from input file.
Exceptions.
do echo Generating $dir eval D
Definition: JDrawLED.sh:50
JPP::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
Definition: JPDF_t.hh:28
JPP::JMAPLIST< JPP::JPolint1FunctionalMap, JPP::JPolint1FunctionalMap, JPP::JPolint0FunctionalGridMap, JPP::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
Definition: JPDF_t.hh:161
Auxiliary methods for PDF calculations.
General purpose class for collection of elements, see: &lt;a href=&quot;JTools.PDF&quot;;&gt;Collection of elements...
Definition: JCollection.hh:72
The elements in a collection are sorted according to their abscissa values and a given distance opera...
This include file containes various data structures that can be used as specific return types for the...
scattered light from EM shower
Definition: JPDFTypes.hh:41
JPP::JSplineFunction1D< JPP::JSplineElement2S< double, double >, JPP::JCollection, JPP::JResultPDF< double > > JFunction1D_t
Definition: JPDF_t.hh:23
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
direct light from EM showers
Definition: JPDFTypes.hh:32
void setExceptionHandler(const supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
void blur(const double TTS, const int numberOfPoints=25, const double epsilon=1.0e-10, const double quantile=0.99)
Blur PDF.
Definition: JPDFTable.hh:110
JPDF_t pdfA
PDF for shower.
Definition: JPDF_t.hh:266
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
Definition of zero value for any class.
Auxiliary data structure for shower PDF.
Definition: JPDF_t.hh:152
JPP::JMAPLIST< JPP::JPolint1FunctionalMap, JPP::JPolint0FunctionalGridMap, JPP::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
Definition: JPDF_t.hh:27
direct light from muon
Definition: JPDFTypes.hh:29
JMuonPDF_t(const std::string &fileDescriptor, const double TTS, const int numberOfPoints=25, const double epsilon=1.0e-10)
Constructor.
Definition: JPDF_t.hh:43
Numbering scheme for PDF types.
Template class for spline interpolation in 1D.
Definition: JSpline.hh:657
result_type calculate(const double E, const double R, const double theta, const double phi, const double t1) const
Get PDF.
Definition: JPDF_t.hh:117
scattered light from muon
Definition: JPDFTypes.hh:30
JFunction1D_t::result_type result_type
Definition: JPDF_t.hh:163
JFunction1D_t::result_type result_type
Definition: JPDF_t.hh:29
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
JPDF_t pdfB
PDF for average energy losses.
Definition: JPDF_t.hh:144
Data structure for result including value, first derivative and integrals of function.
Definition: JResult.hh:335
void add(const JMultiFunction_t &input)
Add function.
function_type::result_type result_type
Definition: JSpline.hh:678
result_type calculate(const double E, const double D, const double cd, const double theta, const double phi, const double t1) const
Get PDF.
Definition: JPDF_t.hh:241
scattered light from delta-rays
Definition: JPDFTypes.hh:36
direct light from EM shower
Definition: JPDFTypes.hh:40
scattered light from EM showers
Definition: JPDFTypes.hh:33
General purpose class for a collection of sorted elements.
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:27
Auxiliary class for recursive map list generation.
Definition: JMapList.hh:108
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
Auxiliary data structure for muon PDF.
Definition: JPDF_t.hh:19
JPDF_t pdfC
PDF for delta-rays.
Definition: JPDF_t.hh:145
direct light from delta-rays
Definition: JPDFTypes.hh:35
Type definition of a zero degree polynomial interpolation based on a JGridMap implementation.
int numberOfPoints
Definition: JResultPDF.cc:22
double getDeltaRaysFromMuon(const double E)
Equivalent EM-shower energy due to delta-rays per unit muon track length.
Definition: JPDFToolkit.hh:77
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:88
JShowerPDF_t(const std::string &fileDescriptor, const double TTS, const int numberOfPoints=25, const double epsilon=1.0e-10)
Constructor.
Definition: JPDF_t.hh:177
JPDF_t pdfA
PDF for minimum ionisong particle.
Definition: JPDF_t.hh:143
JPP::JSplineFunction1D< JPP::JSplineElement2S< double, double >, JPP::JCollection, JPP::JResultPDF< double > > JFunction1D_t
Definition: JPDF_t.hh:156
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37
JPP::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
Definition: JPDF_t.hh:162