Jpp  18.0.0-rc.3
the software that should make you happy
 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/JConstants.hh"
7 #include "JPhysics/JCDFTable.hh"
9 #include "JTools/JPolint.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 1 dimension.
35  * This class provides an upper limit for the avegare number of photo-electrons
36  * as a function of the distance.
37  */
38  template<class JArgument_t, class JResult_t>
39  class JCDFTable1D :
40  public JPolintFunction1D<1, JElement2D<JArgument_t,JResult_t>, JGridCollection>
41  {
42  public:
43 
44  typedef JArgument_t argument_type;
45  typedef JResult_t result_type;
46 
49 
51 
52 
53  /**
54  * Default constructor.
55  */
57  {}
58 
59 
60  /**
61  * Constructor.
62  *
63  * \param cdf CDF (4D table)
64  * \param number_of_bins number of bins (1D table)
65  * \param safety_factor safety factor
66  */
67  template<class JCDF_t, class JCDFMaplist_t, class JCDFDistance_t>
69  const int number_of_bins,
70  const double safety_factor = 2.0)
71  {
72  using namespace JPP;
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  // build the 1D table
89 
90  this->configure(make_grid(number_of_bins, cdf.intensity.begin()->getX(), cdf.intensity.rbegin()->getX()));
91 
92  const JOmega3D omega(JDirection3D(0,1,0), JOmega3D::range_type(0.0,0.501*PI), 0.07*PI);
93 
94  for (typename JFunction1D_t::iterator j = this->begin(); j != this->end(); ++j) {
95 
96  const double R = j->getX();
97  const double W = transformer->getWeight(R);
98 
99  double y = 0.0;
100 
101  for (JOmega3D::const_iterator dir = omega.begin(); dir != omega.end(); ++dir) {
102  y += cdf.getNPE(R, dir->getTheta(), fabs(dir->getPhi()));
103  }
104 
105  y /= omega.size();
106 
107  j->getY() = safety_factor * y / W;
108  }
109 
110  this->compile();
111  }
112 
113 
114  /**
115  * Get number of photo-electrons.
116  *
117  * \param R distance between muon and PMT [m]
118  * \return number of photo-electrons
119  */
120  double getNPE(const double R) const
121  {
122  const double buffer[] = { R };
123 
124  const double y = this->evaluate(buffer);
125  const double W = this->transformer->getWeight(R);
126 
127  return y * W;
128  }
129 
130 
132  };
133 }
134 
135 #endif
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: JCDFTable1D.hh:131
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable.hh:231
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.
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:50
JPolintFunction1D< 1, JElement2D_t, JGridCollection > JFunction1D_t
Definition: JCDFTable1D.hh:48
The template JSharedPointer class can be used to share a pointer to an object.
JElement2D< argument_type, result_type > JElement2D_t
Definition: JCDFTable1D.hh:47
Multidimensional interpolation method.
Map list.
Definition: JMapList.hh:24
JCDFTable1D()
Default constructor.
Definition: JCDFTable1D.hh:56
General purpose class for collection of equidistant elements.
Physics constants.
static const double PI
Mathematical constants.
static JMultiMapTransformer * getClone()
Get clone of default transformer.
then for FUNCTION in pdf npe cdf
Definition: JPlotNPE-PDG.sh:73
Custom class for CDF table in 1 dimension.
Definition: JCDFTable1D.hh:39
collection_type::iterator iterator
Definition: JPolint.hh:1018
JArgument_t argument_type
Definition: JCDFTable1D.hh:44
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
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
double getNPE(const double R) const
Get number of photo-electrons.
Definition: JCDFTable1D.hh:120
int j
Definition: JPolint.hh:703
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:68
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:209
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:1003