Jpp
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 
78  typedef JPDFTransformer<3, argument_type> JPDFTransformer_t;
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
JTOOLS::JGridCollection
General purpose class for collection of equidistant elements.
Definition: JGridCollection.hh:30
JTOOLS::JPolint1FunctionalGridMap
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Definition: JFunctionalMap_t.hh:91
JPHYSICS::JCDFTable1D::getNPE
double getNPE(const double R) const
Get number of photo-electrons.
Definition: JCDFTable1D.hh:121
JPHYSICS::JCDFTable
Multi-dimensional CDF table for arrival time of Cherenkov light.
Definition: JCDFTable.hh:51
JTOOLS::JAngleRange
JRange< double > JAngleRange
Type definition for angle range.
Definition: JAngleRange.hh:19
JPHYSICS::JCDFTable::getNPE
double getNPE(const argument_type x,...) const
Get number of photo-electrons.
Definition: JCDFTable.hh:156
JPHYSICS::JCDFTable::intensity
JMultiQuantile_t intensity
Definition: JCDFTable.hh:241
JPHYSICS::JCDFTable1D::transformer
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable1D.hh:132
JCDFTable.hh
JSharedPointer.hh
JPHYSICS
Auxiliary classes and methods for calculation of PDF and muon energy loss.
Definition: JAbstractMedium.hh:9
JGEOMETRY3D::JDirection3D
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:32
JTOOLS::j
int j
Definition: JPolint.hh:634
JPolint.hh
JTOOLS::JFunctional< JElement_t::abscissa_type, JResult_t >::evaluate
virtual result_type evaluate(const argument_type *pX) const=0
Recursive function value evaluation.
JTOOLS::JMultiMapTransformer::getClone
static JMultiMapTransformer * getClone()
Get clone of default transformer.
Definition: JMultiMapTransformer.hh:124
JPHYSICS::JPDFTransformer
Template definition of transformer of the Probability Density Functions of the time response of a PMT...
Definition: JPDFTransformer.hh:33
JPHYSICS::JCDFTable1D::transformer_type
JMultiMapTransformer< 1, argument_type > transformer_type
Definition: JCDFTable1D.hh:49
JPDFTransformer.hh
JTOOLS::JMapList
Map list.
Definition: JMapList.hh:24
JPHYSICS::JCDFTable1D::JCDFTable1D
JCDFTable1D()
Default constructor.
Definition: JCDFTable1D.hh:55
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JPHYSICS::JCDFTable1D::JFunction1D_t
JPolintFunction1D< 1, JElement2D_t, JGridCollection > JFunction1D_t
Definition: JCDFTable1D.hh:47
JTOOLS::JMultiMapTransformer
Interface for weight application and coordinate transformation of function.
Definition: JMultiMapTransformer.hh:35
JFunctionalMap_t.hh
JPHYSICS::JCDFTable1D::JElement2D_t
JElement2D< argument_type, result_type > JElement2D_t
Definition: JCDFTable1D.hh:46
JPHYSICS::JCDFTable1D::result_type
JResult_t result_type
Definition: JCDFTable1D.hh:44
JTOOLS::make_grid
JGrid< JAbscissa_t > make_grid(const int nx, const JAbscissa_t Xmin, const JAbscissa_t Xmax)
Helper method for JGrid.
Definition: JGrid.hh:177
JPHYSICS::JCDFTable1D::JCDFTable1D
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
JPHYSICS::JCDFTable1D::argument_type
JArgument_t argument_type
Definition: JCDFTable1D.hh:43
JGridCollection.hh
JTOOLS::PI
static const double PI
Constants.
Definition: JConstants.hh:20
JGEOMETRY3D
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition: JAngle3D.hh:18
JPHYSICS::JCDFTable::transformer
JLANG::JSharedPointer< transformer_type > transformer
Definition: JCDFTable.hh:243
JTOOLS::JPolintFunction1D
Template class for polynomial interpolation in 1D.
Definition: JPolint.hh:933
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JElement2D
2D Element.
Definition: JElement.hh:44
JTOOLS::JMultiFunction
Multidimensional interpolation method.
Definition: JMultiFunction.hh:40
JGEOMETRY3D::JOmega3D
Direction set covering (part of) solid angle.
Definition: JOmega3D.hh:64
JTOOLS::configure
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Definition: JToolsToolkit.hh:285
JLANG::JSharedPointer
The template JSharedPointer class can be used to share a pointer to an object.
Definition: JSharedPointer.hh:28
JTOOLS::JPolintFunction1D::iterator
collection_type::iterator iterator
Definition: JPolint.hh:948
JOmega3D.hh
JPHYSICS::JCDFTable1D
Custom class for CDF table in 1 dimension.
Definition: JCDFTable1D.hh:38