Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRadiationSource.hh
Go to the documentation of this file.
1 #ifndef __JPHYSICS__JRADIATIONSOURCE__
2 #define __JPHYSICS__JRADIATIONSOURCE__
3 
4 #include <utility>
5 
10 #include "JTools/JGrid.hh"
11 #include "JPhysics/JRadiation.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JPHYSICS {}
19 namespace JPP { using namespace JPHYSICS; }
20 
21 namespace JPHYSICS {
22 
23 
24  /**
25  * Fast implementation of class JRadiation.
26  *
27  * In this, the methods
28  *
29  * JRadiation::TotalCrossSectionEErad(...),
30  * JRadiation::TotalCrossSectionGNrad(...) and
31  * JRadiation::IntegralofG(...)
32  *
33  * are replaced by lookup tables.
34  */
36  public JRadiation
37  {
38  //typedef JTOOLS::JGridSplineFunction1D_t JFunction1D_t;
42 
43  public:
44  /**
45  * Constructor.
46  *
47  * \param radiation JRadiation object
48  * \param number_of_bins number of bins
49  * \param Emin minimal muon energy [GeV]
50  * \param Emax maximal muon energy [GeV]
51  */
52  explicit JRadiationFunction(const JRadiation& radiation,
53  const unsigned int number_of_bins,
54  const double Emin,
55  const double Emax) :
56  JRadiation(radiation)
57  {
58  using namespace JTOOLS;
59 
60  const double xmin = log(Emin);
61  const double xmax = log(Emax);
62 
63 
64  integral.configure(make_grid(number_of_bins, xmin, xmax));
65 
66  for (JFunction2D_t::iterator i = integral.begin(); i != integral.end(); ++i) {
67 
68  const double x = i->getX();
69  const double E = exp(x);
70 
71  const double ymin = log(EminEErad/E);
72  const double ymax = 0.0;
73 
74  if (ymax > ymin) {
75 
76  i->getY().configure(make_grid(number_of_bins, ymin, ymax));
77 
78  for (JFunction1D_t::iterator j = i->getY().begin(); j != i->getY().end(); ++j) {
79 
80  const double y = j->getX();
81  const double eps = exp(y) * E;
82  const double z = JRadiation::IntegralofG(E, eps);
83 
84  j->getY() = z;
85  }
86  }
87  }
88 
89  integral.compile();
90  integral.setExceptionHandler(new JFunction1D_t::JDefaultResult(0.0));
91 
92 
93  sigmaEE.configure(make_grid(number_of_bins, xmin, xmax));
94 
95  for (JFunction1D_t::iterator i = sigmaEE.begin(); i != sigmaEE.end(); ++i) {
96 
97  const double E = exp(i->getX());
98  const double y = JRadiation::TotalCrossSectionEErad(E);
99 
100  i->getY() = y;
101  }
102 
103  sigmaEE.compile();
104 
105 
106  sigmaGN.configure(make_grid(number_of_bins, xmin, xmax));
107 
108  for (JFunction1D_t::iterator i = sigmaGN.begin(); i != sigmaGN.end(); ++i) {
109 
110  const double E = exp(i->getX());
111  const double y = JRadiation::TotalCrossSectionGNrad(E);
112 
113  i->getY() = y;
114  }
115 
116  sigmaGN.compile();
117  }
118 
119 
120  /**
121  * Pair production cross section.
122  *
123  * \param E muon energy [GeV]
124  * \return cross section [m^2/g]
125  */
126  virtual double TotalCrossSectionEErad(const double E) const
127  {
128  const double x = log(E);
129 
130  if (x >= sigmaEE. begin()->getX() &&
131  x <= sigmaEE.rbegin()->getX()) {
132 
133  try {
134  return sigmaEE(x);
135  }
136  catch(std::exception& error) {
137  std::cerr << "JRadiation::TotalCrossSectionEErad() " << E << ' ' << error.what() << std::endl;
138  }
139  }
140 
142  }
143 
144 
145  /**
146  * Photo-nuclear cross section.
147  *
148  * \param E muon energy [GeV]
149  * \return cross section [m^2/g]
150  */
151  virtual double TotalCrossSectionGNrad(const double E) const
152  {
153  const double x = log(E);
154 
155  if (x >= sigmaGN. begin()->getX() &&
156  x <= sigmaGN.rbegin()->getX()) {
157 
158  try {
159  return sigmaGN(x);
160  }
161  catch(std::exception& error) {
162  std::cerr << "JRadiation::TotalCrossSectionGNrad() " << E << ' ' << error.what() << std::endl;
163  }
164  }
165 
167  }
168 
169  protected:
170  virtual double IntegralofG(const double E,
171  const double eps) const
172  {
173  try {
174 
175  const double x = log(E);
176  const double y = log(eps/E);
177  const double z = integral(x, y);
178 
179  return z;
180  }
181  catch(std::exception& error) {
182  std::cerr << "JRadiation::IntegralofG() " << E << ' ' << eps << ' ' << error.what() << std::endl;
183  }
184 
185  return JRadiation::IntegralofG(E, eps);
186  }
187 
191  };
192 
193 
194  /**
195  * Interface for calculation of inverse interaction length and shower energy.
196  */
198  public:
199 
200  /**
201  * Virtual destructor.
202  */
204  {}
205 
206 
207  /**
208  * Get inverse interaction length.
209  *
210  * \param E muon energy [GeV]
211  * \return inverse interaction length [m^-1]
212  */
213  virtual double getInverseInteractionLength(const double E) const = 0;
214 
215 
216  /**
217  * Get energy of shower.
218  *
219  * \param E muon energy [GeV]
220  * \return shower energy [GeV]
221  */
222  virtual double getEnergyOfShower(const double E) const = 0;
223  };
224 
225 
226  /**
227  * Source of radiation.
228  * This class implements the JRadiationInterface interface.
229  * N.B: This class owns the object pointed to using JSharedPointer<>.
230  */
232  public JRadiationInterface
233  {
234  public:
235 
236  typedef double (JRadiation::*sigma_type)(const double) const; // total cross section method
237  typedef double (JRadiation::*eloss_type)(const double) const; // energy loss method
238 
240 
241 
242  /**
243  * Constructor.
244  *
245  * \param radiation pointer to valid JRadition object
246  * \param density Mass density of radiation material [gr/cm³]
247  * \param source pointers to total cross section and energy loss methods
248  */
250  const double density,
251  const source_type source) :
252  rad (radiation),
253  rho (density),
254  sigma(source.first),
255  eloss(source.second)
256  {}
257 
258 
259  /**
260  * Get inverse interaction length.
261  *
262  * \param E muon energy [GeV]
263  * \return inverse interaction length [m^-1]
264  */
265  virtual double getInverseInteractionLength(const double E) const
266  {
267  return (*rad.*sigma)(E) * rho * 1.0e6;
268  }
269 
270 
271  /**
272  * Get energy of shower.
273  *
274  * \param E muon energy [GeV]
275  * \return shower energy [GeV]
276  */
277  virtual double getEnergyOfShower(const double E) const
278  {
279  return (*rad.*eloss)(E);
280  }
281 
282  protected:
284  const double rho;
285  sigma_type sigma;
286  eloss_type eloss;
287  };
288 }
289 
290 #endif
JRadiationFunction(const JRadiation &radiation, const unsigned int number_of_bins, const double Emin, const double Emax)
Constructor.
void compile()
Compilation.
JLANG::JSharedPointer< JRadiation > rad
JRadiationSource(const JLANG::JSharedPointer< JRadiation > &radiation, const double density, const source_type source)
Constructor.
Interface for calculation of inverse interaction length and shower energy.
const double EminEErad
Definition: JRadiation.hh:357
void setExceptionHandler(const supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
virtual double getInverseInteractionLength(const double E) const
Get inverse interaction length.
Muon radiative cross sections.
virtual double TotalCrossSectionEErad(const double E) const
Pair production cross section.
virtual ~JRadiationInterface()
Virtual destructor.
Fast implementation of class JRadiation.
Source of radiation.
Various implementations of functional maps.
virtual double TotalCrossSectionGNrad(const double E) const
Photo-nuclear cross section.
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
std::pair< sigma_type, eloss_type > source_type
The template JSharedPointer class can be used to share a pointer to an object.
Auxiliary class for the calculation of the muon radiative cross sections.
Definition: JRadiation.hh:39
Multidimensional interpolation method.
virtual double IntegralofG(const double E, const double eps) const
Map list.
Definition: JMapList.hh:24
virtual double getEnergyOfShower(const double E) const
Get energy of shower.
JTOOLS::JMultiFunction< JFunction1D_t, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > > JFunction2D_t
virtual double TotalCrossSectionEErad(const double E) const
Pair production cross section.
Definition: JRadiation.hh:118
JTOOLS::JGridPolint1Function1D_t JFunction1D_t
virtual double IntegralofG(const double E, const double eps) const
Definition: JRadiation.hh:307
virtual double TotalCrossSectionGNrad(const double E) const
Photo-nuclear cross section.
Definition: JRadiation.hh:197
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177