Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JGeant_t.hh
Go to the documentation of this file.
1 #ifndef __JPHYSICS__JGEANT_T__
2 #define __JPHYSICS__JGEANT_T__
3 
5 #include "JIO/JSerialisable.hh"
6 
7 /**
8  * \file
9  * Base class for photon emission profile EM-shower.
10  * \author mdejong
11  */
12 
13 namespace JPHYSICS {}
14 namespace JPP { using namespace JPHYSICS; }
15 
16 namespace JPHYSICS {
17 
18  using JIO::JReader;
19  using JIO::JWriter;
20 
22 
23 
24  /**
25  * Base class for the probability density function of photon emission from EM-shower
26  * as a function of the index of refraction and the cosine of the emission angle.
27  *
28  * The implementation of this function is based on a linear interpolation of tabulated values.
29  * In this, a linear approximation of the dependence of the normalisation constant on
30  * the index of refraction is assumed. This assumption is valid to within 10^-3.
31  */
32  class JGeant_t :
33  public JGeantFunction1D_t
34  {
35  public:
36  /**
37  * Default constructor.
38  */
40  {}
41 
42 
43  /**
44  * Number of photons from EM-shower as a function of emission angle.
45  * The integral over full solid angle is normalised to one.
46  *
47  * \param n index of refraction
48  * \param ct cosine angle of emmision
49  * \return d^2P/dcos()dphi
50  */
51  double operator()(const double n,
52  const double ct) const
53  {
54  const double y = JGeantFunction1D_t::operator()(ct - 1.0/n);
55 
56  return y * (a0 - a1*n);
57  }
58 
59 
60  /**
61  * Integral number of photons from EM-shower between two emission angles.
62  * The integral over full solid angle is normalised to one.
63  *
64  * \param n index of refraction
65  * \param xmin minimal cosine angle of emmision
66  * \param xmax maximal cosine angle of emmision
67  * \return dnpe/dphi
68  */
69  double operator()(const double n,
70  const double xmin,
71  const double xmax) const
72  {
73  const double x_min = std::max(xmin - 1.0/n, buffer. begin()->getX());
74  const double x_max = std::min(xmax - 1.0/n, buffer.rbegin()->getX());
75 
76  const double y = buffer(x_max) - buffer(x_min);
77 
78  return y * (a0 - a1*n);
79  }
80 
81 
82  /**
83  * Read geant from input.
84  *
85  * \param in reader
86  * \param geant geant
87  * \return reader
88  */
90  {
91  in >> geant.a0;
92  in >> geant.a1;
93  in >> static_cast<JGeantFunction1D_t&>(geant);
94 
95  geant.compile();
96 
97  return in;
98  }
99 
100 
101  /**
102  * Write geant to output.
103  *
104  * \param out writer
105  * \param geant geant
106  * \return writer
107  */
108  friend inline JWriter& operator<<(JWriter& out, const JGeant_t& geant)
109  {
110  out << geant.a0;
111  out << geant.a1;
112  out << static_cast<const JGeantFunction1D_t&>(geant);
113 
114  return out;
115  }
116 
117 
118  protected:
119  /**
120  * Function compilation.
121  */
122  virtual void do_compile() override
123  {
125 
126  buffer.clear();
127 
128  JTOOLS::integrate(*this, buffer);
129 
130  buffer.compile();
131  }
132 
133 
134  double a0; //!< offset of the normalisation dependence
135  double a1; //!< slope of the normalisation dependence
137  };
138 }
139 
140 #endif
friend JWriter & operator<<(JWriter &out, const JGeant_t &geant)
Write geant to output.
Definition: JGeant_t.hh:108
Interface for binary output.
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_t.hh:69
result_type operator()(const argument_type x) const
Function value evaluation.
Definition: JFunctional.hh:333
double a1
slope of the normalisation dependence
Definition: JGeant_t.hh:135
virtual void do_compile() override
Function compilation.
Definition: JGeant_t.hh:122
virtual void do_compile() override
Function compilation.
Definition: JPolint.hh:750
friend JReader & operator>>(JReader &in, JGeant_t &geant)
Read geant from input.
Definition: JGeant_t.hh:89
static const JGeant geant(geanx, 0.0001)
Function object for the number of photons from EM-shower as a function of emission angle...
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
const int n
Definition: JPolint.hh:676
double operator()(const double n, const double ct) const
Number of photons from EM-shower as a function of emission angle.
Definition: JGeant_t.hh:51
double a0
offset of the normalisation dependence
Definition: JGeant_t.hh:134
Interface for binary input.
Base class for the probability density function of photon emission from EM-shower as a function of th...
Definition: JGeant_t.hh:32
JGeant_t()
Default constructor.
Definition: JGeant_t.hh:39
JGeantFunction1D_t buffer
Definition: JGeant_t.hh:136
JTOOLS::JGridPolint1Function1D_t JGeantFunction1D_t
Definition: JGeant_t.hh:21
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
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:813