Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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;
28 
29  /**
30  * Function object for the probability density function of photon emission from EM-shower
31  * as a function of cosine of the emission angle.
32  *
33  * The implementation of this function is based on a linear interpolation of tabulated values.
34  * In this, a linear approximation of the dependence of the normalisation constant on
35  * the index of refraction is assumed. This assumption is valid to within 10^-3.
36  */
37  class JGeant :
39  {
40  public:
41  /**
42  * Default constructor.
43  */
44  JGeant()
45  {}
46 
47 
48  /**
49  * Constructor.
50  *
51  * \param geanx PDF of EM-shower
52  * \param dx step size for interpolation of function values
53  */
55  const double dx = 0.0001)
56  {
57  using JTOOLS::PI;
58 
59  const double n0 = geanx.n - 0.02;
60  const double n1 = geanx.n + 0.02;
61 
62  const JGeanx g0(geanx.a, geanx.b, n0);
63  const JGeanx g1(geanx.a, geanx.b, n1);
64 
65  const double y0 = g0.evaluate(-1.0, +1.0);
66  const double y1 = g1.evaluate(-1.0, +1.0);
67 
68  const double c = 1.0 / (y0 * 2*PI);
69 
70  // following range corresponds to n = 1 to n = infty
71 
72  for (double x = -2.0; x < 1.0; x += dx) {
73  (*this)[x] = c * g0.evaluate(x + 1.0/n0);
74  }
75 
76  compile();
77 
78  // linear approximation of dependence normalisation constant on index of refraction
79 
80  u = (y1 - y0) / y0 / (n1 - n0);
81  z = 1.0 + u*n0;
82  }
83 
84 
85  /**
86  * Function compilation.
87  */
88  virtual void compile()
89  {
90  JTOOLS::JGridPolint0Function1D_t::compile();
91 
92  buffer.clear();
93 
94  JTOOLS::integrate(*this, buffer);
95 
96  buffer.compile();
97  }
98 
99 
100  /**
101  * Number of photons from EM-shower as a function of emission angle.
102  * The integral over full solid angle is normalised to one.
103  *
104  * \param n index of refraction
105  * \param ct cosine angle of emmision
106  * \return d^2P/dcos()dphi
107  */
108  double operator()(const double n,
109  const double ct) const
110  {
111  const double y = JTOOLS::JGridPolint0Function1D_t::operator()(ct - 1.0/n);
112 
113  return y * (z - u*n);
114  }
115 
116 
117  /**
118  * Integral number of photons from EM-shower between two emission angles.
119  * The integral over full solid angle is normalised to one.
120  *
121  * \param n index of refraction
122  * \param xmin minimal cosine angle of emmision
123  * \param xmax maximal cosine angle of emmision
124  * \return dnpe/dphi
125  */
126  double operator()(const double n,
127  const double xmin,
128  const double xmax) const
129  {
130  const double x_max = std::min(xmax - 1.0/n, buffer.rbegin()->getX());
131  const double x_min = std::max(xmin - 1.0/n, buffer. begin()->getX());
132 
133  double y = 0.0;
134 
135  y += buffer(x_max);
136  y -= buffer(x_min);
137 
138  return y * (z - u*n);
139  }
140 
141 
142  /**
143  * Read geant from input.
144  *
145  * \param in reader
146  * \param geant geant
147  * \return reader
148  */
149  friend inline JReader& operator>>(JReader& in, JGeant& geant)
150  {
151  in >> geant.z;
152  in >> geant.u;
153  in >> static_cast<JTOOLS::JGridPolint0Function1D_t&>(geant);
154 
155  geant.compile();
156 
157  return in;
158  }
159 
160 
161  /**
162  * Write geant to output.
163  *
164  * \param out writer
165  * \param geant geant
166  * \return writer
167  */
168  friend inline JWriter& operator<<(JWriter& out, const JGeant& geant)
169  {
170  out << geant.z;
171  out << geant.u;
172  out << static_cast<const JTOOLS::JGridPolint0Function1D_t&>(geant);
173 
174  return out;
175  }
176 
177 
178  private:
179  double z; //!< offset of the normalisation dependence
180  double u; //!< slope of the normalisation dependence
182  };
183 
184 
185  /**
186  * Function object for the number of photons from EM-shower as a function of emission angle.
187  */
188  static const JGeant geant(geanx, 0.0001);
189 }
190 
191 #endif
Type definition of a zero degree polynomial interpolation based on a JGridCollection with result type...
double u
slope of the normalisation dependence
Definition: JGeant.hh:180
Interface for binary output.
double getIndexOfRefraction()
Get average index of refraction of water.
Definition: JConstants.hh:111
result_type operator()(const argument_type x) const
Function value evaluation.
Definition: JFunctional.hh:333
const double getSpeedOfLight()
Number of bytes in a gigabyte.
Definition: JConstants.hh:89
static const double PI
Constants.
Definition: JConstants.hh:20
const double b
slope
Definition: JGeanx.hh:137
JTOOLS::JGridPolint0Function1D_t buffer
Definition: JGeant.hh:181
static const JGeant geant(geanx, 0.0001)
Function object for the number of photons from EM-shower as a function of emission angle...
friend JReader & operator>>(JReader &in, JGeant &geant)
Read geant from input.
Definition: JGeant.hh:149
JGeant(const JGeanx &geanx, const double dx=0.0001)
Constructor.
Definition: JGeant.hh:54
double z
offset of the normalisation dependence
Definition: JGeant.hh:179
Constants.
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:126
const double n
index of refraction
Definition: JGeanx.hh:138
Interface for binary input.
virtual void compile()
Function compilation.
Definition: JGeant.hh:88
JGeant()
Default constructor.
Definition: JGeant.hh:44
Photon emission profile EM-shower.
Probability density function of photon emission from EM-shower as a function of cosine of the emissio...
Definition: JGeanx.hh:35
static const JGeanx geanx(0.35,-5.40)
Function object for the number of photons from EM-shower as a function of emission angle...
Function object for the probability density function of photon emission from EM-shower as a function ...
Definition: JGeant.hh:37
const double a
power
Definition: JGeanx.hh:136
double operator()(const double n, const double ct) const
Number of photons from EM-shower as a function of emission angle.
Definition: JGeant.hh:108
double evaluate(const double ct) const
Functional dependence.
Definition: JGeanx.hh:95
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
friend JWriter & operator<<(JWriter &out, const JGeant &geant)
Write geant to output.
Definition: JGeant.hh:168
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25