Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JK40Rates.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JK40RATES___
2 #define __JDETECTOR__JK40RATES___
3 
4 #include <vector>
5 
6 #include "TMath.h"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JDETECTOR {}
14 namespace JPP { using namespace JDETECTOR; }
15 
16 namespace JDETECTOR {
17 
18  /**
19  * Type definition of singles rate [Hz].
20  */
21  typedef double JRateL0_t;
22 
23  /**
24  * Type definition of count rate as a function of multiplicty [Hz]
25  * The multiples rate start counting at two-fold coincidences.
26  */
28 
29 
30  /**
31  * Type definition of multiplicity.
32  */
33  typedef size_t multiplicity_type;
34 
35 
36  /**
37  * Auxiliary class for K40 rates.
38  * The singles rate refers to the counting rate of a PMT and
39  * the multiples rate to the rate of genuine coincidences due to K40 decays.
40  */
41  struct JK40Rates {
42  /**
43  * Default constructor.
44  */
46  rateL0(0.0),
47  rateL1()
48  {}
49 
50 
51  /**
52  * Constructor.
53  *
54  * The multiples rates start counting at two-fold coincidences.
55  *
56  * \param rateL0_Hz singles rate [Hz]
57  * \param rateL1_Hz multiples rates [Hz]
58  */
59  JK40Rates(const JRateL0_t rateL0_Hz,
60  const JRateL1_t& rateL1_Hz = JRateL1_t()) :
61  rateL0(rateL0_Hz),
62  rateL1(rateL1_Hz)
63  {}
64 
65 
66  /**
67  * Get reference to unique instance of this class object.
68  *
69  * This method returns an object with default values.
70  * The singles and multiples rates are taken from KM3NeT
71  * internal note "Detector simulations for KM3NeT".
72  *
73  * \return reference to this class object
74  */
76  {
77  static JK40Rates rates_Hz;
78 
79  if (rates_Hz.rateL1.empty()) {
80 
81  rates_Hz.rateL0 = 5.0e3; // [Hz]
82 
83  rates_Hz.rateL1.push_back(500.0); // [Hz]
84  rates_Hz.rateL1.push_back( 50.0);
85  rates_Hz.rateL1.push_back( 5.0);
86  }
87 
88  return rates_Hz;
89  }
90 
91 
92  /**
93  * Get singles rate.
94  *
95  * \return rate [Hz]
96  */
97  double getSinglesRate() const
98  {
99  return rateL0;
100  }
101 
102 
103  /**
104  * Get multiples rate.
105  *
106  * \param M multiplicity (M >= JK40Rates::LOWER_L1_MULTIPLICITY)
107  * \return rate [Hz]
108  */
109  double getMultiplesRate(const multiplicity_type M) const
110  {
112  return rateL1[M - LOWER_L1_MULTIPLICITY];
113  else
114  return 0.0;
115  }
116 
117 
118  /**
119  * Get lower multiplicty.
120  *
121  * \return lower multiplicity
122  */
124  {
125  return LOWER_L1_MULTIPLICITY;
126  }
127 
128 
129  /**
130  * Get upper multiplicty.
131  *
132  * \return upper multiplicity
133  */
135  {
136  return rateL1.size() + 1;
137  }
138 
139 
140  /**
141  * Correct rates for global efficiency,
142  *
143  * \param QE global efficiency
144  */
145  void correct(const double QE)
146  {
147  if (QE > 0.0) {
148 
149  rateL0 /= QE;
150 
151  JRateL1_t buffer = rateL1;
152 
154 
155  // determine contribution from higher multiplicities
156 
157  double R = 0.0;
158 
159  for (multiplicity_type i = M + 1; i <= getUpperL1Multiplicity(); ++i) {
160  R += buffer[i - LOWER_L1_MULTIPLICITY] * TMath::Binomial(i, M) * pow(QE, M) * pow(1.0 - QE, i - M);
161  }
162 
163  if (getMultiplesRate(M) > R)
164  buffer[M - LOWER_L1_MULTIPLICITY] = (getMultiplesRate(M) - R) / pow(QE, M);
165  else
166  buffer[M - LOWER_L1_MULTIPLICITY] = 0.0;
167  }
168 
169  rateL1 = buffer;
170 
171  } else {
172 
173  rateL0 = 0.0;
174 
175  for (JRateL1_t::iterator i = rateL1.begin(); i != rateL1.end(); ++i) {
176  *i = 0.0;
177  }
178  }
179  }
180 
181 
182  /**
183  * Read K40 rates from input.
184  *
185  * \param in input stream
186  * \param object K40 rates
187  * \return input stream
188  */
189  friend inline std::istream& operator>>(std::istream& in, JK40Rates& object)
190  {
191  const double rateL0 = object.rateL0;
192 
193  if (in >> object.rateL0) {
194 
195  object.rateL1.clear();
196 
197  for (double x; in >> x; ) {
198  object.rateL1.push_back(x);
199  }
200 
201  } else {
202 
203  object.rateL0 = rateL0;
204  }
205 
206  return in;
207  }
208 
209 
210  /**
211  * Write K40 rates to output.
212  *
213  * \param out output stream
214  * \param object K40 rates
215  * \return output stream
216  */
217  friend inline std::ostream& operator<<(std::ostream& out, const JK40Rates& object)
218  {
219  out << object.rateL0;
220 
221  for (JRateL1_t::const_iterator i = object.rateL1.begin(); i != object.rateL1.end(); ++i) {
222  out << ' ' << *i;
223  }
224 
225  return out;
226  }
227 
228 
229  /**
230  * Lower L1 multiplicity
231  */
233 
234 
235  protected:
236  JRateL0_t rateL0; //!< singles rate [Hz]
237  JRateL1_t rateL1; //!< multiples rates [Hz]
238  };
239 }
240 
241 #endif
JK40Rates(const JRateL0_t rateL0_Hz, const JRateL1_t &rateL1_Hz=JRateL1_t())
Constructor.
Definition: JK40Rates.hh:59
double getSinglesRate() const
Get singles rate.
Definition: JK40Rates.hh:97
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition: JK40Rates.hh:123
size_t multiplicity_type
Type definition of multiplicity.
Definition: JK40Rates.hh:33
JRateL1_t rateL1
multiples rates [Hz]
Definition: JK40Rates.hh:237
double JRateL0_t
Type definition of singles rate [Hz].
Definition: JK40Rates.hh:21
friend std::ostream & operator<<(std::ostream &out, const JK40Rates &object)
Write K40 rates to output.
Definition: JK40Rates.hh:217
static JK40Rates & getInstance()
Get reference to unique instance of this class object.
Definition: JK40Rates.hh:75
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate.
Definition: JK40Rates.hh:109
friend std::istream & operator>>(std::istream &in, JK40Rates &object)
Read K40 rates from input.
Definition: JK40Rates.hh:189
JRateL0_t rateL0
singles rate [Hz]
Definition: JK40Rates.hh:236
std::vector< double > JRateL1_t
Type definition of count rate as a function of multiplicty [Hz] The multiples rate start counting at ...
Definition: JK40Rates.hh:27
void correct(const double QE)
Correct rates for global efficiency,.
Definition: JK40Rates.hh:145
static const multiplicity_type LOWER_L1_MULTIPLICITY
Lower L1 multiplicity.
Definition: JK40Rates.hh:232
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition: JK40Rates.hh:134
JK40Rates()
Default constructor.
Definition: JK40Rates.hh:45
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41