Garfield++
4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
pois.cpp
Go to the documentation of this file.
1
#include <cmath>
2
3
#include "
wcpplib/random/pois.h
"
4
#include "
wcpplib/random/rnorm.h
"
5
#include "
wcpplib/random/ranluxint.h
"
6
7
namespace
Heed
{
8
9
long
pois
(
const
double
amu) {
10
// POISSON GENERATOR
11
// CODED FROM LOS ALAMOS REPORT LA-5061-MS
12
// PROB(N)=EXP(-AMU)*AMU**N/FACT(N)
13
// WHERE FACT(N) STANDS FOR FACTORIAL OF N
14
15
if
(amu <= 0.)
return
0;
16
if
(amu > 100.) {
17
return
static_cast<
long
>
(
rnorm_improved
() *
sqrt
(amu) + amu + 0.5);
18
}
19
double
expma =
exp
(-amu);
20
double
pir = 1.;
21
long
n = -1;
22
while
(1) {
23
++n;
24
pir *= SRANLUX();
25
if
(pir <= expma)
break
;
26
}
27
return
n;
28
}
29
}
Heed
Definition:
BGMesh.cpp:6
Heed::rnorm_improved
double rnorm_improved()
Definition:
rnorm.h:11
Heed::exp
DoubleAc exp(const DoubleAc &f)
Definition:
DoubleAc.cpp:377
Heed::pois
long pois(const double amu)
Definition:
pois.cpp:9
Heed::sqrt
DoubleAc sqrt(const DoubleAc &f)
Definition:
DoubleAc.cpp:314
pois.h
ranluxint.h
rnorm.h
garfieldpp-4.0
Heed
wcpplib
random
pois.cpp
Generated by
1.9.6