Jpp
 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/JCDFTable.hh"
8 #include "JTools/JPolint.hh"
11 #include "JTools/JMultiGrid.hh"
12 #include "JGeometry3D/JOmega3D.hh"
13 #include "JLang/JSharedPointer.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JPHYSICS {}
21 namespace JPP { using namespace JPHYSICS; }
22 
23 namespace JPHYSICS {
24 
25  using JTOOLS::JMapList;
26  using JTOOLS::JElement2D;
31 
32 
33  /**
34  * Custom class for CDF table in 2 dimensions.
35  * This class provides an upper limit for the average number of photo-electrons
36  * as a function of the distance and the cosine of the emission angle.
37  */
38  template<class JArgument_t, class JResult_t>
39  class JCDFTable2D :
40  public JMultiFunction<JPolintFunction1D<1, JElement2D<JArgument_t,JResult_t>, JGridCollection>,
41  JMapList<JPolint1FunctionalGridMap> >
42  {
43  public:
44 
45  typedef JArgument_t argument_type;
46  typedef JResult_t result_type;
47 
52 
54 
55 
56  /**
57  * Default constructor.
58  */
60  {}
61 
62 
63  /**
64  * Constructor.
65  *
66  * \param cdf CDF (5D table)
67  * \param number_of_bins number of bins (2D table)
68  * \param safety_factor safety factor
69  */
70  template<class JCDF_t, class JCDFMaplist_t, class JCDFDistance_t>
72  const int number_of_bins,
73  const double safety_factor = 2.0) :
75  {
76  using namespace JTOOLS;
77  using namespace JGEOMETRY3D;
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), JAngleRange(0.0,PI/2), 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:39
do echo Generating $dir eval D
Definition: JDrawLED.sh:50
multimap_type::iterator iterator
Multi-dimensional CDF table for arrival time of Cherenkov light.
Definition: JCDFTable.hh:50
double getNPE(const Args &...args) const
Get number of photo-electrons.
Definition: JCDFTable.hh:156
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable2D.hh:145
JRange< double > JAngleRange
Type definition for angle range.
Definition: JAngleRange.hh:19
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable.hh:228
JMultiFunction< JFunction1D_t, JMaplist_t > JFunction2D_t
Definition: JCDFTable2D.hh:51
Template definition of transformer of the probability density function (PDF) of the time response of ...
static const double PI
Constants.
Definition: JConstants.hh:20
Direction set covering (part of) solid angle.
Definition: JOmega3D.hh:64
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:49
The template JSharedPointer class can be used to share a pointer to an object.
Multidimensional interpolation method.
JCDFTable2D()
Default constructor.
Definition: JCDFTable2D.hh:59
Map list.
Definition: JMapList.hh:24
General purpose class for collection of equidistant elements.
static JMultiMapTransformer * getClone()
Get clone of default transformer.
JMapList< JPolint1FunctionalGridMap > JMaplist_t
Definition: JCDFTable2D.hh:50
then for FUNCTION in pdf npe cdf
Definition: JPlotNPE-PDG.sh:71
collection_type::iterator iterator
Definition: JPolint.hh:948
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:226
2D Element.
Definition: JElement.hh:44
int j
Definition: JPolint.hh:634
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:71
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
JElement2D< argument_type, result_type > JElement2D_t
Definition: JCDFTable2D.hh:48
JArgument_t argument_type
Definition: JCDFTable2D.hh:45
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:933
JMultiMapTransformer< 2, argument_type > transformer_type
Definition: JCDFTable2D.hh:53