Jpp
JGeant.hh
Go to the documentation of this file.
1 #ifndef __JPHYSICS__JGEANT__
2 #define __JPHYSICS__JGEANT__
3 
4 #include <cmath>
5 #include <algorithm>
6 
7 #include "JTools/JConstants.hh"
9 #include "JIO/JSerialisable.hh"
10 #include "JPhysics/JGeanx.hh"
11 
12 /**
13  * \file
14  * Photon emission profile EM-shower.
15  * \author mdejong
16  */
17 
18 namespace JPHYSICS {}
19 namespace JPP { using namespace JPHYSICS; }
20 
21 namespace JPHYSICS {
22 
23  using JIO::JReader;
24  using JIO::JWriter;
27 
29 
30 
31  /**
32  * Function object for the probability density function of photon emission from EM-shower
33  * as a function of cosine of the emission angle.
34  *
35  * The implementation of this function is based on a linear interpolation of tabulated values.
36  * In this, a linear approximation of the dependence of the normalisation constant on
37  * the index of refraction is assumed. This assumption is valid to within 10^-3.
38  */
39  class JGeant :
40  public JGeantFunction1D_t
41  {
42  public:
43  /**
44  * Default constructor.
45  */
46  JGeant()
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param geanx PDF of EM-shower
54  * \param dx step size for interpolation of function values
55  */
57  const double dx = 0.0001)
58  {
59  using JTOOLS::PI;
60 
61  const double n0 = geanx.n - 0.02;
62  const double n1 = geanx.n + 0.02;
63 
64  const JGeanx g0(geanx.a, geanx.b, n0);
65  const JGeanx g1(geanx.a, geanx.b, n1);
66 
67  const double y0 = g0.evaluate(-1.0, +1.0);
68  const double y1 = g1.evaluate(-1.0, +1.0);
69 
70  const double c = 1.0 / (y0 * 2*PI);
71 
72  // following range corresponds to n = 1 to n = infinity
73 
74  for (double x = -2.0; x < 1.0; x += dx) {
75  (*this)[x] = c * g0.evaluate(x + 1.0/n0);
76  }
77 
78  compile();
79 
80  // linear approximation of dependence normalisation constant on index of refraction
81 
82  a1 = (y1 - y0) / y0 / (n1 - n0);
83  a0 = 1.0 + a1*n0;
84  }
85 
86 
87  /**
88  * Function compilation.
89  */
90  virtual void compile()
91  {
92  JGeantFunction1D_t::compile();
93 
94  buffer.clear();
95 
96  JTOOLS::integrate(*this, buffer);
97 
98  buffer.compile();
99  }
100 
101 
102  /**
103  * Number of photons from EM-shower as a function of emission angle.
104  * The integral over full solid angle is normalised to one.
105  *
106  * \param n index of refraction
107  * \param ct cosine angle of emmision
108  * \return d^2P/dcos()dphi
109  */
110  double operator()(const double n,
111  const double ct) const
112  {
113  const double y = JGeantFunction1D_t::operator()(ct - 1.0/n);
114 
115  return y * (a0 - a1*n);
116  }
117 
118 
119  /**
120  * Integral number of photons from EM-shower between two emission angles.
121  * The integral over full solid angle is normalised to one.
122  *
123  * \param n index of refraction
124  * \param xmin minimal cosine angle of emmision
125  * \param xmax maximal cosine angle of emmision
126  * \return dnpe/dphi
127  */
128  double operator()(const double n,
129  const double xmin,
130  const double xmax) const
131  {
132  const double x_min = std::max(xmin - 1.0/n, buffer. begin()->getX());
133  const double x_max = std::min(xmax - 1.0/n, buffer.rbegin()->getX());
134 
135  const double y = buffer(x_max) - buffer(x_min);
136 
137  return y * (a0 - a1*n);
138  }
139 
140 
141  /**
142  * Read geant from input.
143  *
144  * \param in reader
145  * \param geant geant
146  * \return reader
147  */
148  friend inline JReader& operator>>(JReader& in, JGeant& geant)
149  {
150  in >> geant.a0;
151  in >> geant.a1;
152  in >> static_cast<JGeantFunction1D_t&>(geant);
153 
154  geant.compile();
155 
156  return in;
157  }
158 
159 
160  /**
161  * Write geant to output.
162  *
163  * \param out writer
164  * \param geant geant
165  * \return writer
166  */
167  friend inline JWriter& operator<<(JWriter& out, const JGeant& geant)
168  {
169  out << geant.a0;
170  out << geant.a1;
171  out << static_cast<const JGeantFunction1D_t&>(geant);
172 
173  return out;
174  }
175 
176 
177  private:
178  double a0; //!< offset of the normalisation dependence
179  double a1; //!< slope of the normalisation dependence
181  };
182 
183 
184  /**
185  * Function object for the number of photons from EM-shower as a function of emission angle.
186  */
187  static const JGeant geant(geanx, 0.0001);
188 }
189 
190 #endif
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
JPHYSICS::JGeant::a1
double a1
slope of the normalisation dependence
Definition: JGeant.hh:179
JTOOLS::getSpeedOfLight
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
JPHYSICS::geanx
static const JGeanx geanx(0.35, -5.40)
Function object for the number of photons from EM-shower as a function of emission angle.
g1
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
JPHYSICS::JGeant::operator()
double operator()(const double n, const double xmin, const double xmax) const
Integral number of photons from EM-shower between two emission angles.
Definition: JGeant.hh:128
JTOOLS::n
const int n
Definition: JPolint.hh:628
JPHYSICS
Auxiliary classes and methods for calculation of PDF and muon energy loss.
Definition: JAbstractMedium.hh:9
JPHYSICS::JGeant::a0
double a0
offset of the normalisation dependence
Definition: JGeant.hh:178
JGeanx.hh
JPHYSICS::JGeanx::a
const double a
power
Definition: JGeanx.hh:136
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JFunction1D_t.hh
JSerialisable.hh
JPHYSICS::JGeant::operator<<
friend JWriter & operator<<(JWriter &out, const JGeant &geant)
Write geant to output.
Definition: JGeant.hh:167
JPHYSICS::JGeant::compile
virtual void compile()
Function compilation.
Definition: JGeant.hh:90
JConstants.hh
JTOOLS::getIndexOfRefraction
double getIndexOfRefraction()
Get average index of refraction of water.
Definition: JConstants.hh:111
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:131
JPHYSICS::JGeantFunction1D_t
JTOOLS::JGridPolint1Function1D_t JGeantFunction1D_t
Definition: JGeant.hh:28
JPHYSICS::JGeant
Function object for the probability density function of photon emission from EM-shower as a function ...
Definition: JGeant.hh:39
JTOOLS::JFunction1D< JElement2D< double, double > ::abscissa_type, double >::operator()
result_type operator()(const argument_type x) const
Function value evaluation.
Definition: JFunctional.hh:333
JPHYSICS::JGeanx::b
const double b
slope
Definition: JGeanx.hh:137
JPHYSICS::JGeanx::n
const double n
index of refraction
Definition: JGeanx.hh:138
JTOOLS::PI
static const double PI
Constants.
Definition: JConstants.hh:20
JPHYSICS::geant
static const JGeant geant(geanx, 0.0001)
Function object for the number of photons from EM-shower as a function of emission angle.
JPHYSICS::JGeant::JGeant
JGeant(const JGeanx &geanx, const double dx=0.0001)
Constructor.
Definition: JGeant.hh:56
JPHYSICS::JGeanx
Probability density function of photon emission from EM-shower as a function of cosine of the emissio...
Definition: JGeanx.hh:35
JTOOLS::JGridPolint1Function1D_t
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
Definition: JFunction1D_t.hh:292
JPHYSICS::JGeant::operator()
double operator()(const double n, const double ct) const
Number of photons from EM-shower as a function of emission angle.
Definition: JGeant.hh:110
JPHYSICS::JGeant::JGeant
JGeant()
Default constructor.
Definition: JGeant.hh:46
JTOOLS::integrate
JElement_t::ordinate_type integrate(const JCollection< JElement_t, JDistance_t > &input, typename JMappable< JElement_t >::map_type &output)
Conversion of data points to integral values.
Definition: JCollection.hh:793
JPHYSICS::JGeant::operator>>
friend JReader & operator>>(JReader &in, JGeant &geant)
Read geant from input.
Definition: JGeant.hh:148
JPHYSICS::JGeant::buffer
JGeantFunction1D_t buffer
Definition: JGeant.hh:180
JPHYSICS::JGeanx::evaluate
double evaluate(const double ct) const
Functional dependence.
Definition: JGeanx.hh:95