Jpp  15.0.5
the software that should make you happy
 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 "JPhysics/JK40Rates.hh"
8 
9 #include "JFit/JTimeRange.hh"
10 #include "JFit/JFitToolkit.hh"
11 
12 
13 /**
14  * \author mdejong
15  */
16 
17 namespace JFIT {}
18 namespace JPP { using namespace JFIT; }
19 
20 namespace JFIT {
21 
22  using JPHYSICS::JK40Rates;
23 
24 
25  /**
26  * Auxiliary class for converting various rates to expectation values
27  * of the number of hits within a given time interval.
28  */
29  struct JK40 {
30  /**
31  * Type definition of expectation values of number of multiple hits.
32  */
34 
35 
36  /**
37  * Default constructor.
38  */
39  JK40() :
40  __y0(0.0),
41  __y1()
42  {}
43 
44 
45  /**
46  * Constructor for single PMT.
47  *
48  * \param T_ns time range [ns]
49  * \param R_Hz K40 singles rate [Hz]
50  */
51  JK40(const JTimeRange& T_ns,
52  const double R_Hz) :
53  __y0(0.0),
54  __y1()
55  {
56  const double T_s = (T_ns.getUpperLimit() - T_ns.getLowerLimit()) * 1.0e-9; // period [s]
57 
58  __y0 = R_Hz * T_s;
59  }
60 
61 
62  /**
63  * Constructor for modules.
64  *
65  * \param T_ns time range [ns]
66  * \param numberOfPMTs number of PMTs in module
67  * \param rates_Hz K40 singles and multiples rates [Hz]
68  */
69  JK40(const JTimeRange& T_ns,
70  const size_t numberOfPMTs,
71  const JK40Rates& rates_Hz) :
72  __y0(0.0),
73  __y1()
74  {
75  const double T_s = (T_ns.getUpperLimit() - T_ns.getLowerLimit())* 1.0e-9; // period [s]
76 
77  __y0 = numberOfPMTs * rates_Hz.getSinglesRate() * T_s;
78 
79  // genuine coincidences
80 
81  for (size_t M = rates_Hz.getLowerL1Multiplicity(); M <= rates_Hz.getUpperL1Multiplicity(); ++M) {
82  __y1.push_back(rates_Hz.getMultiplesRate(M) * T_s);
83  }
84 
85  // random coincidences
86 
87  if (__y1.empty()) {
88  __y1.push_back(0.0);
89  }
90 
91  __y1[0] += __y0 * (1.0 - exp(-__y0));
92  }
93 
94 
95  /**
96  * Get expectation value for number of single hits.
97  *
98  * \return expectation value
99  */
100  double getY0() const
101  {
102  return __y0;
103  }
104 
105 
106  /**
107  * Get expectation value for number of multiple hits.
108  *
109  * \param M multiplicity (M >= 2)
110  * \return expectation value
111  */
112  double getY1(const size_t M) const
113  {
114  if (M >= 2 && M - 2 < __y1.size())
115  return __y1[M-2];
116  else
117  return 0.0;
118  }
119 
120 
121  /**
122  * Get probability to observe a hit with given multiplicity.
123  * Note that if M = 0, the probability corresponds to observing no hits.
124  *
125  * \param M multiplicity (M >= 0)
126  * \return probability
127  */
128  double getP(size_t M) const
129  {
130  double expval = 0.0;
131 
132  if (M < 2)
133  expval = getY0();
134  else
135  expval = getY1(M);
136 
137  return JFIT::getP(expval, M != 0);
138  }
139 
140  protected:
141  double __y0; //!< expectation value of number of single hits
142  JL1_t __y1; //!< expectation values of number of multiple hits
143  };
144 }
145 
146 #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:33
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
double getY0() const
Get expectation value for number of single hits.
Definition: JK40.hh:100
JK40(const JTimeRange &T_ns, const double R_Hz)
Constructor for single PMT.
Definition: JK40.hh:51
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [ns]).
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition: JK40Rates.hh:97
Auxiliary class for converting various rates to expectation values of the number of hits within a giv...
Definition: JK40.hh:29
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` typeset -Z 4 STRING JOpera1D -f hydrophone.root
double getY1(const size_t M) const
Get expectation value for number of multiple hits.
Definition: JK40.hh:112
double getP(size_t M) const
Get probability to observe a hit with given multiplicity.
Definition: JK40.hh:128
JK40()
Default constructor.
Definition: JK40.hh:39
JL1_t __y1
expectation values of number of multiple hits
Definition: JK40.hh:142
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate.
Definition: JK40Rates.hh:83
JK40(const JTimeRange &T_ns, const size_t numberOfPMTs, const JK40Rates &rates_Hz)
Constructor for modules.
Definition: JK40.hh:69
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:34
double getSinglesRate() const
Get singles rate.
Definition: JK40Rates.hh:71
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition: JK40Rates.hh:108
double __y0
expectation value of number of single hits
Definition: JK40.hh:141
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41