Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCDFTable1D.hh
Go to the documentation of this file.
1 #ifndef __JSIRENE__JCDFTABLE1D__
2 #define __JSIRENE__JCDFTABLE1D__
3 
4 #include <cmath>
5 
6 #include "JPhysics/JCDFTable.hh"
8 #include "JTools/JPolint.hh"
11 #include "JGeometry3D/JOmega3D.hh"
12 #include "JLang/JSharedPointer.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JPHYSICS {}
20 namespace JPP { using namespace JPHYSICS; }
21 
22 namespace JPHYSICS {
23 
24  using JTOOLS::JMapList;
25  using JTOOLS::JElement2D;
30 
31 
32  /**
33  * Custom class for CDF table in 1 dimension.
34  * This class provides an upper limit for the avegare number of photo-electrons
35  * as a function of the distance.
36  */
37  template<class JArgument_t, class JResult_t>
38  class JCDFTable1D :
39  public JPolintFunction1D<1, JElement2D<JArgument_t,JResult_t>, JGridCollection>
40  {
41  public:
42 
43  typedef JArgument_t argument_type;
44  typedef JResult_t result_type;
45 
48 
50 
51 
52  /**
53  * Default constructor.
54  */
56  {}
57 
58 
59  /**
60  * Constructor.
61  *
62  * \param cdf CDF (4D table)
63  * \param number_of_bins number of bins (1D table)
64  * \param safety_factor safety factor
65  */
66  template<class JCDF_t, class JCDFMaplist_t, class JCDFDistance_t>
68  const int number_of_bins,
69  const double safety_factor = 2.0)
70  {
71  using namespace JTOOLS;
72  using namespace JGEOMETRY3D;
73 
74  // extract the weight function
75 
76  try {
77 
79 
80  const JPDFTransformer_t& object = dynamic_cast<const JPDFTransformer_t&>(*(cdf.transformer));
81 
82  transformer.reset(object.transformer.clone());
83  }
84  catch(const std::exception& error) {
86  }
87 
88 
89  // build the 1D table
90 
91  this->configure(make_grid(number_of_bins, cdf.intensity.begin()->getX(), cdf.intensity.rbegin()->getX()));
92 
93  const JOmega3D omega(JDirection3D(0,1,0), JAngleRange(0.0,PI/2), 0.07*PI);
94 
95  for (typename JFunction1D_t::iterator j = this->begin(); j != this->end(); ++j) {
96 
97  const double R = j->getX();
98  const double W = transformer->getWeight(R);
99 
100  double y = 0.0;
101 
102  for (JOmega3D::const_iterator dir = omega.begin(); dir != omega.end(); ++dir) {
103  y += cdf.getNPE(R, dir->getTheta(), fabs(dir->getPhi()));
104  }
105 
106  y /= omega.size();
107 
108  j->getY() = safety_factor * y / W;
109  }
110 
111  this->compile();
112  }
113 
114 
115  /**
116  * Get number of photo-electrons.
117  *
118  * \param R distance between muon and PMT [m]
119  * \return number of photo-electrons
120  */
121  double getNPE(const double R) const
122  {
123  const double buffer[] = { R };
124 
125  const double y = this->evaluate(buffer);
126  const double W = this->transformer->getWeight(R);
127 
128  return y * W;
129  }
130 
131 
133  };
134 }
135 
136 #endif
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
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable1D.hh:132
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JRange< double > JAngleRange
Type definition for angle range.
Definition: JAngleRange.hh:19
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable.hh:228
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.
virtual result_type evaluate(const argument_type *pX) const =0
Recursive function value evaluation.
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.
JMultiMapTransformer< 1, argument_type > transformer_type
Definition: JCDFTable1D.hh:49
JPolintFunction1D< 1, JElement2D_t, JGridCollection > JFunction1D_t
Definition: JCDFTable1D.hh:47
The template JSharedPointer class can be used to share a pointer to an object.
JElement2D< argument_type, result_type > JElement2D_t
Definition: JCDFTable1D.hh:46
Multidimensional interpolation method.
Map list.
Definition: JMapList.hh:24
JCDFTable1D()
Default constructor.
Definition: JCDFTable1D.hh:55
General purpose class for collection of equidistant elements.
static JMultiMapTransformer * getClone()
Get clone of default transformer.
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
then for FUNCTION in pdf npe cdf
Definition: JPlotNPE-PDG.sh:71
Custom class for CDF table in 1 dimension.
Definition: JCDFTable1D.hh:38
collection_type::iterator iterator
Definition: JPolint.hh:948
JArgument_t argument_type
Definition: JCDFTable1D.hh:43
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
double getNPE(const double R) const
Get number of photo-electrons.
Definition: JCDFTable1D.hh:121
int j
Definition: JPolint.hh:634
JCDFTable1D(const JCDFTable< JCDF_t, JCDFMaplist_t, JCDFDistance_t > &cdf, const int number_of_bins, const double safety_factor=2.0)
Constructor.
Definition: JCDFTable1D.hh:67
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:933