Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Poisson.hh File Reference
#include <CLHEP/Units/PhysicalConstants.h>
#include "G4Types.hh"
#include "G4Exp.hh"
#include "Randomize.hh"
Include dependency graph for G4Poisson.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

G4long G4Poisson (G4double mean)
 

Function Documentation

G4long G4Poisson ( G4double  mean)
inline

Definition at line 51 of file G4Poisson.hh.

52 {
53  G4long number = 0;
54  const G4int border = 16;
55  const G4double limit = 2e9;
56 
57  if(mean <= border)
58  {
60  G4double poissonValue = G4Exp(-mean);
61  G4double poissonSum = poissonValue;
62 
63  while(poissonSum <= position)
64  {
65  ++number;
66  poissonValue *= mean/number;
67  poissonSum += poissonValue;
68  }
69  return number;
70  } // the case of mean <= 16
71 
72  G4double t = std::sqrt(-2.*std::log(G4UniformRand()))*
73  std::cos(2.*CLHEP::pi*G4UniformRand());
74  G4double value = mean + t*std::sqrt(mean) + 0.5;
75  if(value < 0.) {return 0;}
76  return (value >= limit) ? G4long(limit) : G4long(value);
77 }
static unsigned border[]
Definition: csz_inflate.cc:298
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
double G4double
Definition: G4Types.hh:76
static constexpr double pi
Definition: SystemOfUnits.h:54

Here is the call graph for this function:

Here is the caller graph for this function: