Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSireneToolkit.hh
Go to the documentation of this file.
1 #ifndef __JSIRENE__JSIRENETOOLKIT__
2 #define __JSIRENE__JSIRENETOOLKIT__
3 
4 #include <vector>
5 #include <cmath>
6 
7 #include "TRandom3.h"
8 
9 #include "JPhysics/JConstants.hh"
10 #include "JPhysics/JPDFTypes.hh"
11 #include "JPhysics/JGeane.hh"
12 #include "JAAnet/JAAnetToolkit.hh"
13 #include "JLang/JComparator.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 
21 /**
22  * Detector simulations.
23  */
24 namespace JSIRENE {}
25 namespace JPP { using namespace JSIRENE; }
26 
27 namespace JSIRENE {
28 
30  using JPHYSICS::MASS_MUON;
32  using JPHYSICS::JGeane;
33  using JPHYSICS::gWater;
35  using JAANET::JHitType_t;
36 
37 
38  /**
39  * Get number of photo-electrons of a hit given the expectation
40  * values of the number of photo-electrons on a module and PMT.
41  *
42  * The return value is evaluated by pick-and-drop statistics from
43  * the generated number of photo-electrons when the expectation
44  * value of the number of photo-electrons on a module deviates
45  * less than 5 sigmas from 0 (i.e.\ when it is less than 25).
46  * Otherwise, the return value is evaluated by Poisson statistics
47  * from the expectation value of the number of photo-electrons on PMT.
48  *
49  * \param NPE expectation value of npe on module
50  * \param N generated value of npe on module
51  * \param npe expectation value of npe on PMT
52  * \return number of photo-electrons on PMT
53  */
54  inline int getNumberOfPhotoElectrons(const double NPE,
55  const int N,
56  const double npe)
57  {
58  if (NPE < 25.0) {
59 
60  int n = 0;
61 
62  for (int i = N; i != 0; --i) {
63  if (gRandom->Rndm() * NPE < npe) {
64  ++n;
65  }
66  }
67 
68  return n;
69 
70  } else {
71 
72  return gRandom->Poisson(npe);
73  }
74  }
75 
76 
77  /**
78  * Get number of photo-electrons of a hit given number of photo-electrons on PMT.
79  *
80  * The number of photo-electrons of a hit may be larger than unity
81  * to limit the overall number of hits and consequently the memory coonsumption as well as
82  * the number of times the arrival time needs to be evaluated which is CPU intensive.
83  *
84  * \param npe number of photo-electrons on PMT
85  * \return number of photo-electrons of hit
86  */
87  inline int getNumberOfPhotoElectrons(const int npe)
88  {
89  static const int NPE = 20;
90 
91  if (npe > NPE) {
92 
93  const int n = (int) (NPE * log10((double) npe / (double) NPE));
94 
95  if (n == 0)
96  return 1;
97  else
98  return n;
99  }
100 
101  return 1;
102  }
103 
104 
105  /**
106  * Get hit type corresponding to given PDF type.
107  *
108  * \param pdf PDF type
109  * \param shower force origin from neutrino interaction shower
110  * \return hit type
111  */
112  inline JHitType_t getHitType(const JPDFType_t pdf, const bool shower = false)
113  {
114  using namespace JAANET;
115  using namespace JPHYSICS;
116 
117  switch (pdf) {
118 
120  return HIT_TYPE_MUON_DIRECT;
121 
124 
127 
130 
133 
136 
137  default:
138  return HIT_TYPE_UNKNOWN;
139  }
140  }
141 
142 
143  /**
144  * Vertex of energy loss of muon.
145  */
146  struct JVertex {
147  /**
148  * Default constructor.
149  */
151  z (0.0),
152  t (0.0),
153  E (0.0),
154  Es(0.0)
155  {}
156 
157 
158  /**
159  * Constructor.
160  *
161  * \param z position [m]
162  * \param t time [ns]
163  * \param E energy [GeV]
164  */
165  JVertex(const double z,
166  const double t,
167  const double E)
168  {
169  this->z = z;
170  this->t = t;
171  this->E = E;
172  this->Es = 0.0;
173  }
174 
175 
176  /**
177  * Get position.
178  *
179  * \return position [m]
180  */
181  double getZ() const
182  {
183  return z;
184  }
185 
186 
187  /**
188  * Get time.
189  *
190  * \return time [ns]
191  */
192  double getT() const
193  {
194  return t;
195  }
196 
197 
198  /**
199  * Get muon energy.
200  *
201  * \return energy [GeV]
202  */
203  double getE() const
204  {
205  return E;
206  }
207 
208 
209  /**
210  * Get shower energy.
211  *
212  * \return energy [GeV]
213  */
214  double getEs() const
215  {
216  return Es;
217  }
218 
219 
220  /**
221  * Get range of muon.
222  * This method applies only ionisation energy loss.
223  *
224  * \return range [m]
225  */
226  double getRange() const
227  {
228  if (E > MASS_MUON * getIndexOfRefraction())
229  return (E - MASS_MUON * getIndexOfRefraction()) / gWater.getA();
230  else
231  return 0.0;
232  }
233  /**
234  * Get range of muon using precalculated a parameter
235  * This method applies only ionisation energy loss.
236  * \param a ionization a parameter[GeV/m]
237  * \return range [m]
238  */
239  double getRange(double a) const {
240  if (E > MASS_MUON * getIndexOfRefraction())
241  return (E - MASS_MUON * getIndexOfRefraction()) / a;
242  else
243  return 0.0; }
244 
245 
246  /**
247  * Get range of muon.
248  *
249  * \param geane energy loss
250  * \return range [m]
251  */
252  double getRange(const JGeane& geane) const
253  {
254  return geane(E);
255  }
256 
257 
258  /**
259  * Apply energy loss energy.
260  *
261  * \param Es energy [GeV]
262  */
263  void applyEloss(const double Es)
264  {
265  this->E -= Es;
266  this->Es = Es;
267  }
268 
269 
270  /**
271  * Step.
272  * This method applies only ionisation energy loss.
273  *
274  * \param ds step [m]
275  * \return this vertex
276  */
277  JVertex& step(const double ds)
278  {
279  z += ds;
280  t += ds / getSpeedOfLight();
281  E -= ds * gWater.getA();
282 
283  return *this;
284  }
285  /* This method applies only ionisation energy loss given a value of a.
286  *
287  * \param ds step [m]
288  * \param a a ionization parameter [GeV/m]
289  * \return this vertex
290  */
291  JVertex& step( const double ds, const double a)
292  {
293  z += ds;
294  t += ds / getSpeedOfLight();
295  E -= ds * a;
296 
297  return *this;
298  }
299  /**
300  * Step.
301  *
302  * \param geane energy loss
303  * \param ds step [m]
304  * \return this vertex
305  */
306  JVertex& step(const JGeane& geane, const double ds)
307  {
308  z += ds;
309  t += ds / getSpeedOfLight();
310  E = geane(E, ds);
311 
312  return *this;
313  }
314 
315  protected:
316  double z;
317  double t;
318  double E;
319  double Es;
320  };
321 
322 
323  /**
324  * Muon trajectory.
325  */
326  struct JTrack :
327  public std::vector<JVertex>
328  {
329  /**
330  * Constructor.
331  *
332  * \param vertex muon starting point
333  */
334  JTrack(const JVertex& vertex) :
335  std::vector<JVertex>(1, vertex)
336  {}
337 
338 
339  /**
340  * Get muon energy at given position.
341  *
342  * \param z position [m]
343  * \return energy [GeV]
344  */
345  double getE(const double z) const
346  {
347  if (!this->empty()) {
348 
349  const_iterator pos = lower_bound(this->begin(), this->end(), z, JLANG::make_comparator(&JVertex::getZ));
350 
351  if (pos != this->end() && pos != this->begin()) {
352 
353  --pos;
354 
355  return pos->getE() - (z - pos->getZ()) * gWater.getA();
356  }
357  }
358 
359  return MASS_MUON;
360  }
361  };
362 
363 
364  /**
365  * Get kinetic energy of particle with given mass.
366  *
367  * \param E energy [GeV]
368  * \param m mass [GeV]
369  * \return energy [GeV]
370  */
371  inline double getKineticEnergy(const double E, const double m)
372  {
373  if (E > m)
374  return sqrt((E - m) * (E + m));
375  else
376  return 0.0;
377  }
378 }
379 
380 #endif
JHitType_t
Enumeration of hit types based on km3 codes.
double getEs() const
Get shower energy.
JTrack(const JVertex &vertex)
Constructor.
Scattered light from primary shower.
double getT() const
Get time.
JVertex & step(const double ds)
Step.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
Definition: JComparator.hh:185
double getRange(double a) const
Get range of muon using precalculated a parameter This method applies only ionisation energy loss...
void applyEloss(const double Es)
Apply energy loss energy.
Direct light from delta-rays.
Scattered light from muon.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
Energy loss of muon.
scattered light from EM shower
Definition: JPDFTypes.hh:41
JHitType_t getHitType(const JPDFType_t pdf, const bool shower=false)
Get hit type corresponding to given PDF type.
static const double MASS_MUON
muon mass [GeV]
double getE() const
Get muon energy.
Scattered light from Bremsstrahlung.
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:323
Direct light from Bremsstrahlung.
Direct light from primary shower.
direct light from muon
Definition: JPDFTypes.hh:29
JVertex()
Default constructor.
JVertex(const double z, const double t, const double E)
Constructor.
Numbering scheme for PDF types.
JVertex & step(const JGeane &geane, const double ds)
Step.
scattered light from muon
Definition: JPDFTypes.hh:30
double getZ() const
Get position.
double getE(const double z) const
Get muon energy at given position.
scattered light from delta-rays
Definition: JPDFTypes.hh:36
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
Physics constants.
direct light from EM shower
Definition: JPDFTypes.hh:40
Muon trajectory.
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:27
Interface for muon energy loss.
Definition: JGeane.hh:37
double getKineticEnergy(const double E, const double m)
Get kinetic energy of particle with given mass.
double getRange(const JGeane &geane) const
Get range of muon.
Vertex of energy loss of muon.
direct light from delta-rays
Definition: JPDFTypes.hh:35
int getNumberOfPhotoElectrons(const double NPE, const int N, const double npe)
Get number of photo-electrons of a hit given the expectation values of the number of photo-electrons ...
const double getSpeedOfLight()
Get speed of light.
Direct light from muon.
then $JPP_DIR software JCalibrate JCalibrateToT a
Definition: JTuneHV.sh:108
Scattered light from delta-rays.
alias put_queue eval echo n
Definition: qlib.csh:19
double getRange() const
Get range of muon.
JVertex & step(const double ds, const double a)
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
virtual double getA() const override
Get energy loss constant.
Definition: JGeane.hh:229