Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JK40Rates.hh
Go to the documentation of this file.
1 #ifndef __JPHYSICS__JK40RATES___
2 #define __JPHYSICS__JK40RATES___
3 
4 #include <vector>
5 
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JPHYSICS {}
14 namespace JPP { using namespace JPHYSICS; }
15 
16 namespace JPHYSICS {
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 singles rate.
68  *
69  * \return rate [Hz]
70  */
71  double getSinglesRate() const
72  {
73  return rateL0;
74  }
75 
76 
77  /**
78  * Get multiples rate.
79  *
80  * \param M multiplicity (M >= JK40Rates::LOWER_L1_MULTIPLICITY)
81  * \return rate [Hz]
82  */
83  double getMultiplesRate(const multiplicity_type M) const
84  {
86  return rateL1[M - LOWER_L1_MULTIPLICITY];
87  else
88  return 0.0;
89  }
90 
91 
92  /**
93  * Get lower multiplicty.
94  *
95  * \return lower multiplicity
96  */
98  {
99  return LOWER_L1_MULTIPLICITY;
100  }
101 
102 
103  /**
104  * Get upper multiplicty.
105  *
106  * \return upper multiplicity
107  */
109  {
110  return rateL1.size() + 1;
111  }
112 
113 
114  /**
115  * Correct rates for global efficiency,
116  *
117  * \param QE global efficiency
118  */
119  void correct(const double QE)
120  {
121  if (QE > 0.0) {
122 
123  rateL0 /= QE;
124 
125  JRateL1_t buffer = rateL1;
126 
128 
129  // determine contribution from higher multiplicities
130 
131  double R = 0.0;
132 
133  for (multiplicity_type i = M + 1; i <= getUpperL1Multiplicity(); ++i) {
134  R += buffer[i - LOWER_L1_MULTIPLICITY] * JMATH::binomial(i, M) * pow(QE, M) * pow(1.0 - QE, i - M);
135  }
136 
137  if (getMultiplesRate(M) > R)
138  buffer[M - LOWER_L1_MULTIPLICITY] = (getMultiplesRate(M) - R) / pow(QE, M);
139  else
140  buffer[M - LOWER_L1_MULTIPLICITY] = 0.0;
141  }
142 
143  rateL1 = buffer;
144 
145  } else {
146 
147  rateL0 = 0.0;
148 
149  for (JRateL1_t::iterator i = rateL1.begin(); i != rateL1.end(); ++i) {
150  *i = 0.0;
151  }
152  }
153  }
154 
155 
156  /**
157  * Read K40 rates from input.
158  *
159  * \param in input stream
160  * \param object K40 rates
161  * \return input stream
162  */
163  friend inline std::istream& operator>>(std::istream& in, JK40Rates& object)
164  {
165  const double rateL0 = object.rateL0;
166 
167  if (in >> object.rateL0) {
168 
169  object.rateL1.clear();
170 
171  for (double x; in >> x; ) {
172  object.rateL1.push_back(x);
173  }
174 
175  } else {
176 
177  object.rateL0 = rateL0;
178  }
179 
180  return in;
181  }
182 
183 
184  /**
185  * Write K40 rates to output.
186  *
187  * \param out output stream
188  * \param object K40 rates
189  * \return output stream
190  */
191  friend inline std::ostream& operator<<(std::ostream& out, const JK40Rates& object)
192  {
193  out << object.rateL0;
194 
195  for (JRateL1_t::const_iterator i = object.rateL1.begin(); i != object.rateL1.end(); ++i) {
196  out << ' ' << *i;
197  }
198 
199  return out;
200  }
201 
202 
203  /**
204  * Lower L1 multiplicity
205  */
207 
208 
209  protected:
210  JRateL0_t rateL0; //!< singles rate [Hz]
211  JRateL1_t rateL1; //!< multiples rates [Hz]
212  };
213 }
214 
215 #endif
JK40Rates()
Default constructor.
Definition: JK40Rates.hh:45
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
Auxiliary methods for mathematics.
JK40Rates(const JRateL0_t rateL0_Hz, const JRateL1_t &rateL1_Hz=JRateL1_t())
Constructor.
Definition: JK40Rates.hh:59
double binomial(const int n, const int k)
Binomial function.
static const multiplicity_type LOWER_L1_MULTIPLICITY
Lower L1 multiplicity.
Definition: JK40Rates.hh:206
multiplicity_type getLowerL1Multiplicity() const
Get lower multiplicty.
Definition: JK40Rates.hh:97
friend std::istream & operator>>(std::istream &in, JK40Rates &object)
Read K40 rates from input.
Definition: JK40Rates.hh:163
JRateL1_t rateL1
multiples rates [Hz]
Definition: JK40Rates.hh:211
friend std::ostream & operator<<(std::ostream &out, const JK40Rates &object)
Write K40 rates to output.
Definition: JK40Rates.hh:191
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:98
double getMultiplesRate(const multiplicity_type M) const
Get multiples rate.
Definition: JK40Rates.hh:83
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
double getSinglesRate() const
Get singles rate.
Definition: JK40Rates.hh:71
size_t multiplicity_type
Type definition of multiplicity.
Definition: JK40Rates.hh:33
multiplicity_type getUpperL1Multiplicity() const
Get upper multiplicty.
Definition: JK40Rates.hh:108
void correct(const double QE)
Correct rates for global efficiency,.
Definition: JK40Rates.hh:119
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
double JRateL0_t
Type definition of singles rate [Hz].
Definition: JK40Rates.hh:21
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
JRateL0_t rateL0
singles rate [Hz]
Definition: JK40Rates.hh:210
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41