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  Acoeff*/
120  Acoeff.configure(make_grid(number_of_bins, xmin, xmax));
121  for (JFunction1D_t::iterator i = Acoeff.begin(); i != Acoeff.end(); ++i) {
122 
123  const double E = exp(i->getX());
124  const double y = JRadiation::CalculateACoeff(E);
125 
126  i->getY() = y;
127  }
128 
129  Acoeff.compile();
130 
131  }
132 
133 
134  /**
135  * Pair production cross section.
136  *
137  * \param E muon energy [GeV]
138  * \return cross section [m^2/g]
139  */
140  virtual double TotalCrossSectionEErad(const double E) const override
141  {
142  const double x = log(E);
143 
144  if (x >= sigmaEE. begin()->getX() &&
145  x <= sigmaEE.rbegin()->getX()) {
146 
147  try {
148  return sigmaEE(x);
149  }
150  catch(std::exception& error) {
151  std::cerr << "JRadiation::TotalCrossSectionEErad() " << E << ' ' << error.what() << std::endl;
152  }
153  }
154 
156  }
157  /**
158  * A Coefficient.
159  *
160  * \param E muon energy [GeV]
161  * \return Ionization A parameter [GeV/m]
162  */
163  virtual double CalculateACoeff(const double E) const override
164  {
165  const double x = log(E);
166 
167  if (x >= Acoeff. begin()->getX() &&
168  x <= Acoeff.rbegin()->getX()) {
169 
170  try {
171  return Acoeff(x);
172  }
173  catch(std::exception& error) {
174  std::cerr << "JRadiation::ACoeff() " << E << ' ' << error.what() << std::endl;
175  }
176  }
177  return JRadiation::CalculateACoeff(E);
178  }
179 
180 
181  /**
182  * Photo-nuclear cross section.
183  *
184  * \param E muon energy [GeV]
185  * \return cross section [m^2/g]
186  */
187  virtual double TotalCrossSectionGNrad(const double E) const override
188  {
189  const double x = log(E);
190 
191  if (x >= sigmaGN. begin()->getX() &&
192  x <= sigmaGN.rbegin()->getX()) {
193 
194  try {
195  return sigmaGN(x);
196  }
197  catch(std::exception& error) {
198  std::cerr << "JRadiation::TotalCrossSectionGNrad() " << E << ' ' << error.what() << std::endl;
199  }
200  }
201 
203  }
204 
205  protected:
206  virtual double IntegralofG(const double E,
207  const double eps) const
208  {
209  try {
210 
211  const double x = log(E);
212  const double y = log(eps/E);
213  const double z = integral(x, y);
214 
215  return z;
216  }
217  catch(std::exception& error) {
218  std::cerr << "JRadiation::IntegralofG() " << E << ' ' << eps << ' ' << error.what() << std::endl;
219  }
220 
221  return JRadiation::IntegralofG(E, eps);
222  }
223 
228  };
229 
230 
231  /**
232  * Interface for calculation of inverse interaction length and shower energy.
233  */
235  public:
236 
237  /**
238  * Virtual destructor.
239  */
241  {}
242 
243 
244  /**
245  * Get inverse interaction length.
246  *
247  * \param E muon energy [GeV]
248  * \return inverse interaction length [m^-1]
249  */
250  virtual double getInverseInteractionLength(const double E) const = 0;
251 
252  /**
253  * Get Ionization A value
254  *
255  * \param E muon energy [GeV]
256  * \return Ionization "A" value [GeV/m]
257  */
258  virtual double getA(const double E) const = 0;
259 
260  /**
261  * Get energy of shower.
262  *
263  * \param E muon energy [GeV]
264  * \return shower energy [GeV]
265  */
266  virtual double getEnergyOfShower(const double E) const = 0;
267  };
268 
269 
270  /**
271  * Source of radiation.
272  * This class implements the JRadiationInterface interface.
273  * N.B: This class owns the object pointed to using JSharedPointer<>.
274  */
276  public JRadiationInterface
277  {
278  public:
279 
280  typedef double (JRadiation::*sigma_type)(const double) const; // total cross section method
281  typedef double (JRadiation::*eloss_type)(const double) const; // energy loss method
282 
284 
285 
286  /**
287  * Constructor.
288  *
289  * \param radiation pointer to valid JRadition object
290  * \param density Mass density of radiation material [gr/cm³]
291  * \param source pointers to total cross section and energy loss methods
292  */
294  const double density,
295  const source_type source) :
296  rad (radiation),
297  rho (density),
298  sigma(source.first),
299  eloss(source.second)
300  {}
301 
302 
303  /**
304  * Get inverse interaction length.
305  *
306  * \param E muon energy [GeV]
307  * \return inverse interaction length [m^-1]
308  */
309  virtual double getInverseInteractionLength(const double E) const override
310  {
311  return (*rad.*sigma)(E) * rho * 1.0e6;
312  }
313 
314  /**
315  * Get A value.
316  *
317  * \param E muon energy [GeV]
318  * \return ionization A value [GeV/m]
319  */
320  virtual double getA(const double E) const override
321  {
322  return (*rad.*sigma)(E) * rho * 1.0e6;
323  }
324 
325  /**
326  * Get energy of shower.
327  *
328  * \param E muon energy [GeV]
329  * \return shower energy [GeV]
330  */
331  virtual double getEnergyOfShower(const double E) const override
332  {
333  return (*rad.*eloss)(E);
334  }
335 
336  protected:
338  const double rho;
339  sigma_type sigma;
340  eloss_type eloss;
341  };
342 }
343 
344 #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
virtual double getEnergyOfShower(const double E) const override
Get energy of shower.
JRadiationSource(const JLANG::JSharedPointer< JRadiation > &radiation, const double density, const source_type source)
Constructor.
Interface for calculation of inverse interaction length and shower energy.
virtual double CalculateACoeff(const double E) const override
A Coefficient.
const double EminEErad
Definition: JRadiation.hh:390
void setExceptionHandler(const supervisor_type &supervisor)
Set the supervisor for handling of exceptions.
virtual double getInverseInteractionLength(const double E) const override
Get inverse interaction length.
Muon radiative cross sections.
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))*exp(-0.5 *(y-[1])*(y-[1])/([2]*[2]))" JF2 -o $WORKDIR/f2.root -F "$FORMULA" -@ "p0
virtual ~JRadiationInterface()
Virtual destructor.
Fast implementation of class JRadiation.
Source of radiation.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Various implementations of functional maps.
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
virtual double getA(const double E) const override
Get A value.
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:31
Multidimensional interpolation method.
virtual double IntegralofG(const double E, const double eps) const
Map list.
Definition: JMapList.hh:24
virtual double TotalCrossSectionEErad(const double E) const override
Pair production cross section.
virtual double TotalCrossSectionGNrad(const double E) const override
Photo-nuclear cross section.
JTOOLS::JMultiFunction< JFunction1D_t, JTOOLS::JMapList< JTOOLS::JPolint1FunctionalGridMap > > JFunction2D_t
virtual double TotalCrossSectionEErad(const double E) const
Pair production cross section.
Definition: JRadiation.hh:113
JTOOLS::JGridPolint1Function1D_t JFunction1D_t
int j
Definition: JPolint.hh:666
virtual double CalculateACoeff(double Energy) const
Ionization a parameter.
Definition: JRadiation.hh:289
virtual double IntegralofG(const double E, const double eps) const
Definition: JRadiation.hh:339
virtual double TotalCrossSectionGNrad(const double E) const
Photo-nuclear cross section.
Definition: JRadiation.hh:194
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37