Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAstronomyToolkit.hh
Go to the documentation of this file.
1 #ifndef __JASTRONOMYTOOLKIT__
2 #define __JASTRONOMYTOOLKIT__
3 
4 #include <cmath>
5 
7 
8 #include "JTools/JConstants.hh"
9 #include "JTools/JGrid.hh"
10 #include "JTools/JHistogram1D_t.hh"
11 #include "JTools/JFunction1D_t.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JASTRONOMY {}
19 namespace JPP { using namespace JASTRONOMY; }
20 
21 namespace JASTRONOMY {
22 
24 
25 
26  /**
27  * Auxiliary class for source tracking.
28  * This class constitutes a function object corresponding to the normalised probability
29  *
30  * \f$\frac{dP}{d\Omega}(cos\theta)\f$
31  *
32  * for a source to be at an observed zenith angle, \f$\theta\f$, in local coordinates.
33  * A simulation of a diffuse flux of neutrinos can thus be used to determine
34  * the number of detected events from an astrophysical source with the given telescope.
35  */
36  struct JStarTrek :
38  {
39  /**
40  * Constructor.
41  *
42  * \param telescope telescope
43  * \param source astrophysical source
44  * \param number_of_bins number of bins
45  * \param number_of_samples number of samples
46  */
47  JStarTrek(const JAstronomy& telescope,
48  const JSourceLocation& source,
49  const int number_of_bins = 401,
50  const int number_of_samples = 20000)
51  {
52  using namespace JTOOLS;
53 
54  const double epsilon = 0.005;
55  const double W = 1.0 / (double) (number_of_samples * 2*PI); // dP/dphi
56 
57  JGridHistogram1D_t histogram(make_grid(number_of_bins, -1.0 - epsilon, +1.0 + epsilon));
58 
59  for (int i = 0; i != number_of_samples; ++i) {
60 
61  const double t1 = (double) i * NUMBER_OF_SECONDS_PER_SEDERIAL_DAY / (double) number_of_samples;
62  const double ct = cos(telescope.getDirectionOfNeutrino(t1, source).getZenith());
63 
64  histogram.fill(ct, W);
65  }
66 
67  makePDF(histogram, *this); // dP/dOmega
68 
69  this->setExceptionHandler(new JGridPolint1Function1D_t::JDefaultResult(0.0));
70  this->compile();
71  }
72  };
73 }
74 
75 #endif
Auxiliary class for source tracking.
JNeutrinoDirection getDirectionOfNeutrino(const double &t1, const JSourceLocation &pos) const
Get direction pointing to source.
Definition: JAstronomy.hh:299
static const double PI
Constants.
Definition: JConstants.hh:20
Auxiliary class to make coordinate transformations for a specific geographical location of the detect...
Definition: JAstronomy.hh:277
Location of astrophysical source.
Definition: JAstronomy.hh:146
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...
Constants.
const double & getZenith() const
Definition: JAstronomy.hh:206
void makePDF(const JHistogram1D< JElement_t, JContainer_t, JDistance_t > &input, typename JMappable< JElement_t >::map_type &output)
Conversion of histogram to probability density function (PDF).
void setExceptionHandler(const JSupervisor &supervisor)
Set the supervisor for handling of exceptions.
Definition: JFunctional.hh:286
static const double NUMBER_OF_SECONDS_PER_SEDERIAL_DAY
Definition: JAstronomy.hh:86
Interface methods for slalib and auxiliary classes and methods for astronomy.
Histogram in 1D.
JStarTrek(const JAstronomy &telescope, const JSourceLocation &source, const int number_of_bins=401, const int number_of_samples=20000)
Constructor.
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.