Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JK40.hh
Go to the documentation of this file.
1 #ifndef __JFIT__JK40__
2 #define __JFIT__JK40__
3 
4 #include <cmath>
5 #include <vector>
6 
7 #include "TMath.h"
8 
9 #include "JDetector/JK40Rates.hh"
10 #include "JFit/JTimeRange.hh"
11 #include "JFit/JFitToolkit.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JFIT {}
19 namespace JPP { using namespace JFIT; }
20 
21 namespace JFIT {
22 
24 
25 
26  /**
27  * Auxiliary class for converting various rates to expectation values
28  * of the number of hits within a given time interval.
29  */
30  struct JK40 {
31  /**
32  * Type definition of expectation values of number of multiple hits.
33  */
35 
36 
37  /**
38  * Default constructor.
39  */
40  JK40() :
41  __y0(0.0),
42  __y1()
43  {}
44 
45 
46  /**
47  * Constructor for single PMT.
48  *
49  * \param T_ns time range [ns]
50  * \param R_Hz K40 singles rate [Hz]
51  */
52  JK40(const JTimeRange& T_ns,
53  const double R_Hz) :
54  __y0(0.0),
55  __y1()
56  {
57  const double T_s = (T_ns.getUpperLimit() - T_ns.getLowerLimit()) * 1.0e-9; // period [s]
58 
59  __y0 = R_Hz * T_s;
60  }
61 
62 
63  /**
64  * Constructor for modules.
65  *
66  * \param T_ns time range [ns]
67  * \param numberOfPMTs number of PMTs in module
68  * \param rates_Hz K40 singles and multiples rates [Hz]
69  */
70  JK40(const JTimeRange& T_ns,
71  const size_t numberOfPMTs,
72  const JK40Rates& rates_Hz) :
73  __y0(0.0),
74  __y1()
75  {
76  const double T_s = (T_ns.getUpperLimit() - T_ns.getLowerLimit())* 1.0e-9; // period [s]
77 
78  __y0 = numberOfPMTs * rates_Hz.getSinglesRate() * T_s;
79 
80  // genuine coincidences
81 
82  for (size_t M = rates_Hz.getLowerL1Multiplicity(); M <= rates_Hz.getUpperL1Multiplicity(); ++M) {
83  __y1.push_back(rates_Hz.getMultiplesRate(M) * T_s);
84  }
85 
86  // random coincidences
87 
88  if (__y1.empty()) {
89  __y1.push_back(0.0);
90  }
91 
92  __y1[0] += __y0 * (1.0 - exp(-__y0));
93  }
94 
95 
96  /**
97  * Get expectation value for number of single hits.
98  *
99  * \return expectation value
100  */
101  double getY0() const
102  {
103  return __y0;
104  }
105 
106 
107  /**
108  * Get expectation value for number of multiple hits.
109  *
110  * \param M multiplicity (M >= 2)
111  * \return expectation value
112  */
113  double getY1(const size_t M) const
114  {
115  if (M >= 2 && M - 2 < __y1.size())
116  return __y1[M-2];
117  else
118  return 0.0;
119  }
120 
121 
122  /**
123  * Get probability to observe a hit with given multiplicity.
124  * Note that if M = 0, the probability corresponds to observing no hits.
125  *
126  * \param M multiplicity (M >= 0)
127  * \return probability
128  */
129  double getP(size_t M) const
130  {
131  double expval = 0.0;
132 
133  if (M < 2)
134  expval = getY0();
135  else
136  expval = getY1(M);
137 
138  return JFIT::getP(expval, M != 0);
139  }
140 
141  protected:
142  double __y0; //!< expectation value of number of single hits
143  JL1_t __y1; //!< expectation values of number of multiple hits
144  };
145 }
146 
147 #endif
Auxiliary methods to evaluate Poisson probabilities and chi2.
std::vector< double > JL1_t
Type definition of expectation values of number of multiple hits.
Definition: JK40.hh:34
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
double getSinglesRate() const
Get singles rate.
Definition: JK40Rates.hh:97
double getY0() const
Get expectation value for number of single hits.
Definition: JK40.hh:101
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition: JK40Rates.hh:123
JK40(const JTimeRange &T_ns, const double R_Hz)
Constructor for single PMT.
Definition: JK40.hh:52
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:30
JRange< double > JTimeRange
Type definition for time range.
double getY1(const size_t M) const
Get expectation value for number of multiple hits.
Definition: JK40.hh:113
double getP(size_t M) const
Get probability to observe a hit with given multiplicity.
Definition: JK40.hh:129
JK40()
Default constructor.
Definition: JK40.hh:40
JL1_t __y1
expectation values of number of multiple hits
Definition: JK40.hh:143
JK40(const JTimeRange &T_ns, const size_t numberOfPMTs, const JK40Rates &rates_Hz)
Constructor for modules.
Definition: JK40.hh:70
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate.
Definition: JK40Rates.hh:109
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits...
Definition: JFitToolkit.hh:36
double __y0
expectation value of number of single hits
Definition: JK40.hh:142
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition: JK40Rates.hh:134
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable OUTPUT_FILE histogram.root JHistogram1D -o $WORKDIR/$OUTPUT_FILE -F "$FORMULA" -
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41