Jpp  debug
the software that should make you happy
JAstronomyToolkit.hh
Go to the documentation of this file.
1 #ifndef __JASTRONOMYTOOLKIT__
2 #define __JASTRONOMYTOOLKIT__
3 
4 #include <cmath>
5 
7 
8 #include "JMath/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 JPP;
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 
70  this->compile();
71  }
72  };
73 }
74 
75 #endif
Interface methods for slalib and auxiliary classes and methods for astronomy.
Mathematical constants.
Auxiliary class to make coordinate transformations for a specific geographical location of the detect...
Definition: JAstronomy.hh:487
JNeutrinoDirection getDirectionOfNeutrino(const double &t1, const JSourceLocation &pos) const
Get direction pointing to source.
Definition: JAstronomy.hh:507
const double & getZenith() const
Definition: JAstronomy.hh:414
Location of astrophysical source.
Definition: JAstronomy.hh:289
void setExceptionHandler(const JSupervisor &supervisor)
Set the supervisor for handling of exceptions.
Definition: JFunctional.hh:303
Histogram in 1D.
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
const double epsilon
Definition: JQuadrature.cc:21
static const double NUMBER_OF_SECONDS_PER_SEDERIAL_DAY
Definition: JAstronomy.hh:97
static const double PI
Mathematical constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
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).
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:209
Auxiliary class for source tracking.
JStarTrek(const JAstronomy &telescope, const JSourceLocation &source, const int number_of_bins=401, const int number_of_samples=20000)
Constructor.
Exception handler for functional object using default result.
Definition: JFunctional.hh:180
Type definition of a 1st degree polynomial interpolation based on a JGridCollection with result type ...