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
6
7namespace Heed {
8
9long 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}
Definition: BGMesh.cpp:6
double rnorm_improved()
Definition: rnorm.h:11
DoubleAc exp(const DoubleAc &f)
Definition: DoubleAc.cpp:377
long pois(const double amu)
Definition: pois.cpp:9
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314