Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCDFTable2D.hh
Go to the documentation of this file.
1 #ifndef __JSIRENE__JCDFTABLE2D__
2 #define __JSIRENE__JCDFTABLE2D__
3 
4 #include <cmath>
5 
6 #include "JPhysics/JConstants.hh"
7 #include "JPhysics/JCDFTable.hh"
9 #include "JTools/JPolint.hh"
12 #include "JTools/JMultiGrid.hh"
13 #include "JGeometry3D/JOmega3D.hh"
14 #include "JLang/JSharedPointer.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JPHYSICS {}
22 namespace JPP { using namespace JPHYSICS; }
23 
24 namespace JPHYSICS {
25 
26  using JTOOLS::JMapList;
27  using JTOOLS::JElement2D;
32 
33 
34  /**
35  * Custom class for CDF table in 2 dimensions.
36  * This class provides an upper limit for the average number of photo-electrons
37  * as a function of the distance and the cosine of the emission angle.
38  */
39  template<class JArgument_t, class JResult_t>
40  class JCDFTable2D :
41  public JMultiFunction<JPolintFunction1D<1, JElement2D<JArgument_t,JResult_t>, JGridCollection>,
42  JMapList<JPolint1FunctionalGridMap> >
43  {
44  public:
45 
46  typedef JArgument_t argument_type;
47  typedef JResult_t result_type;
48 
53 
55 
56 
57  /**
58  * Default constructor.
59  */
61  {}
62 
63 
64  /**
65  * Constructor.
66  *
67  * \param cdf CDF (5D table)
68  * \param number_of_bins number of bins (2D table)
69  * \param safety_factor safety factor
70  */
71  template<class JCDF_t, class JCDFMaplist_t, class JCDFDistance_t>
73  const int number_of_bins,
74  const double safety_factor = 2.0) :
76  {
77  using namespace JPP;
78 
79  // extract the weight function
80 
81  try {
82 
84 
85  const JPDFTransformer_t& object = dynamic_cast<const JPDFTransformer_t&>(*(cdf.transformer));
86 
87  transformer.reset(object.transformer.clone());
88  }
89  catch(const std::exception& error) {
91  }
92 
93 
94  // build the 2D table
95 
96  this->configure(make_grid(number_of_bins, cdf.intensity.begin()->getX(), cdf.intensity.rbegin()->getX()));
97 
98  const JOmega3D omega(JDirection3D(0,1,0), JOmega3D::range_type(0.0,0.501*PI), 0.07*PI);
99 
100  for (typename JFunction2D_t::iterator i = this->begin(); i != this->end(); ++i) {
101 
102  i->getY().configure(make_grid(number_of_bins, -1.0, +1.0));
103 
104  for (typename JFunction1D_t::iterator j = i->getY().begin(); j != i->getY().end(); ++j) {
105 
106  const double D = i->getX();
107  const double cd = j->getX();
108  const double W = transformer->getWeight(D, cd);
109 
110  double y = 0.0;
111 
112  for (JOmega3D::const_iterator dir = omega.begin(); dir != omega.end(); ++dir) {
113  y += cdf.getNPE(D, cd, dir->getTheta(), fabs(dir->getPhi()));
114  }
115 
116  y /= omega.size();
117 
118  j->getY() = safety_factor * y / W;
119  }
120  }
121 
122  this->compile();
123  }
124 
125 
126  /**
127  * Get number of photo-electrons.
128  *
129  * \param D distance between EM shower and PMT [m]
130  * \param cd cosine angle EM shower direction and EM shower - PMT position
131  * \return number of photo-electrons
132  */
133  double getNPE(const double D,
134  const double cd) const
135  {
136  const double buffer[] = { D, cd };
137 
138  const double y = this->evaluate(buffer);
139  const double W = this->transformer->getWeight(D, cd);
140 
141  return y * W;
142  }
143 
144 
146  };
147 }
148 
149 #endif
void compile()
Compilation.
Custom class for CDF table in 2 dimensions.
Definition: JCDFTable2D.hh:40
multimap_type::iterator iterator
Multi-dimensional CDF table for arrival time of Cherenkov light.
Definition: JCDFTable.hh:53
double getNPE(const Args &...args) const
Get number of photo-electrons.
Definition: JCDFTable.hh:159
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable2D.hh:145
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable.hh:231
JMultiFunction< JFunction1D_t, JMaplist_t > JFunction2D_t
Definition: JCDFTable2D.hh:52
Template definition of transformer of the probability density function (PDF) of the time response of ...
std::pair< double, double > range_type
Definition: JOmega3D.hh:32
Various implementations of functional maps.
Transformer for the 1D probability density function (PDF) of the time response of a PMT to a muon...
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
JPolintFunction1D< 1, JElement2D_t, JGridCollection > JFunction1D_t
Definition: JCDFTable2D.hh:50
The template JSharedPointer class can be used to share a pointer to an object.
Multidimensional interpolation method.
JCDFTable2D()
Default constructor.
Definition: JCDFTable2D.hh:60
JArray< NUMBER_OF_DIMENSIONS, argument_type > buffer
Map list.
Definition: JMapList.hh:24
General purpose class for collection of equidistant elements.
Physics constants.
static const double PI
Mathematical constants.
static JMultiMapTransformer * getClone()
Get clone of default transformer.
JMapList< JPolint1FunctionalGridMap > JMaplist_t
Definition: JCDFTable2D.hh:51
then for FUNCTION in pdf npe cdf
Definition: JPlotNPE-PDG.sh:73
collection_type::iterator iterator
Definition: JPolint.hh:1018
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Interface for weight application and coordinate transformation of function.
JMultiQuantile_t intensity
Definition: JCDFTable.hh:229
2D Element.
Definition: JElement.hh:46
int j
Definition: JPolint.hh:703
double getNPE(const double D, const double cd) const
Get number of photo-electrons.
Definition: JCDFTable2D.hh:133
JCDFTable2D(const JCDFTable< JCDF_t, JCDFMaplist_t, JCDFDistance_t > &cdf, const int number_of_bins, const double safety_factor=2.0)
Constructor.
Definition: JCDFTable2D.hh:72
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:209
JElement2D< argument_type, result_type > JElement2D_t
Definition: JCDFTable2D.hh:49
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
JArgument_t argument_type
Definition: JCDFTable2D.hh:46
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:1003
JMultiMapTransformer< 2, argument_type > transformer_type
Definition: JCDFTable2D.hh:54