Jpp
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
JPHYSICS::JRadiationSource::eloss
eloss_type eloss
Definition: JRadiationSource.hh:286
JPHYSICS::JRadiationInterface
Interface for calculation of inverse interaction length and shower energy.
Definition: JRadiationSource.hh:197
JPHYSICS::JRadiationSource::source_type
std::pair< sigma_type, eloss_type > source_type
Definition: JRadiationSource.hh:239
JPHYSICS::JRadiationFunction
Fast implementation of class JRadiation.
Definition: JRadiationSource.hh:35
JPHYSICS::JRadiationFunction::sigmaGN
JFunction1D_t sigmaGN
Definition: JRadiationSource.hh:189
JRadiation.hh
JPHYSICS::JRadiation::IntegralofG
virtual double IntegralofG(const double E, const double eps) const
Definition: JRadiation.hh:307
JGrid.hh
JPHYSICS::JRadiationInterface::~JRadiationInterface
virtual ~JRadiationInterface()
Virtual destructor.
Definition: JRadiationSource.hh:203
JPHYSICS::JRadiationSource::sigma
sigma_type sigma
Definition: JRadiationSource.hh:285
JSharedPointer.hh
JPHYSICS
Auxiliary classes and methods for calculation of PDF and muon energy loss.
Definition: JAbstractMedium.hh:9
JTOOLS::JMultiFunction::setExceptionHandler
void setExceptionHandler(const supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
Definition: JMultiFunction.hh:158
JTOOLS::j
int j
Definition: JPolint.hh:634
JPHYSICS::JRadiationFunction::TotalCrossSectionEErad
virtual double TotalCrossSectionEErad(const double E) const
Pair production cross section.
Definition: JRadiationSource.hh:126
JTOOLS::JMapList
Map list.
Definition: JMapList.hh:24
JPHYSICS::JRadiationSource::getInverseInteractionLength
virtual double getInverseInteractionLength(const double E) const
Get inverse interaction length.
Definition: JRadiationSource.hh:265
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JPHYSICS::JRadiationFunction::TotalCrossSectionGNrad
virtual double TotalCrossSectionGNrad(const double E) const
Photo-nuclear cross section.
Definition: JRadiationSource.hh:151
JFunction1D_t.hh
JPHYSICS::JRadiationSource::rad
JLANG::JSharedPointer< JRadiation > rad
Definition: JRadiationSource.hh:283
JPHYSICS::JRadiationFunction::integral
JFunction2D_t integral
Definition: JRadiationSource.hh:190
JFunctionalMap_t.hh
JPHYSICS::JRadiationSource::rho
const double rho
Definition: JRadiationSource.hh:284
JPHYSICS::JRadiationFunction::JRadiationFunction
JRadiationFunction(const JRadiation &radiation, const unsigned int number_of_bins, const double Emin, const double Emax)
Constructor.
Definition: JRadiationSource.hh:52
std::pair
Definition: JSTDTypes.hh:15
JTOOLS::JMultiFunction< JFunction1D_t, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > >::iterator
multimap_type::iterator iterator
Definition: JMultiFunction.hh:64
JPHYSICS::JRadiationFunction::sigmaEE
JFunction1D_t sigmaEE
Definition: JRadiationSource.hh:188
JTOOLS::make_grid
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
JMultiFunction.hh
JTOOLS::JMultiFunction::compile
void compile()
Compilation.
Definition: JMultiFunction.hh:143
JPHYSICS::JRadiation::TotalCrossSectionEErad
virtual double TotalCrossSectionEErad(const double E) const
Pair production cross section.
Definition: JRadiation.hh:118
JPHYSICS::JRadiationSource::getEnergyOfShower
virtual double getEnergyOfShower(const double E) const
Get energy of shower.
Definition: JRadiationSource.hh:277
JPHYSICS::JRadiationSource::JRadiationSource
JRadiationSource(const JLANG::JSharedPointer< JRadiation > &radiation, const double density, const source_type source)
Constructor.
Definition: JRadiationSource.hh:249
JTOOLS::JGridPolint1Function1D_t
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
Definition: JFunction1D_t.hh:292
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JMultiFunction
Multidimensional interpolation method.
Definition: JMultiFunction.hh:40
JPHYSICS::JRadiationFunction::JFunction2D_t
JTOOLS::JMultiFunction< JFunction1D_t, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > > JFunction2D_t
Definition: JRadiationSource.hh:41
JPHYSICS::JRadiationSource
Source of radiation.
Definition: JRadiationSource.hh:231
JPHYSICS::JRadiation
Auxiliary class for the calculation of the muon radiative cross sections.
Definition: JRadiation.hh:39
JPHYSICS::JRadiationFunction::JFunction1D_t
JTOOLS::JGridPolint1Function1D_t JFunction1D_t
Definition: JRadiationSource.hh:39
JPHYSICS::JRadiation::EminEErad
const double EminEErad
Definition: JRadiation.hh:357
JLANG::JSharedPointer
The template JSharedPointer class can be used to share a pointer to an object.
Definition: JSharedPointer.hh:28
JPHYSICS::JRadiationFunction::IntegralofG
virtual double IntegralofG(const double E, const double eps) const
Definition: JRadiationSource.hh:170
JTOOLS::JPolintFunction1D< N, JElement2D< double, double >, JGridCollection, double >::iterator
collection_type::iterator iterator
Definition: JPolint.hh:948
JPHYSICS::JRadiation::TotalCrossSectionGNrad
virtual double TotalCrossSectionGNrad(const double E) const
Photo-nuclear cross section.
Definition: JRadiation.hh:197