Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Poisson.hh File Reference
#include <CLHEP/Units/PhysicalConstants.h>
#include "globals.hh"
#include "Randomize.hh"

Go to the source code of this file.

Functions

G4long G4Poisson (G4double mean)
 

Function Documentation

◆ G4Poisson()

G4long G4Poisson ( G4double  mean)
inline

Definition at line 50 of file G4Poisson.hh.

51{
52 G4long number = 0;
53 const G4int border = 16;
54 G4double limit = 2e9;
55
56 if(mean <= border) {
58 G4double poissonValue = std::exp(-mean);
59 G4double poissonSum = poissonValue;
60
61 while(poissonSum <= position) {
62 number++ ;
63 poissonValue *= mean/number;
64 poissonSum += poissonValue;
65 }
66 return number;
67 } // the case of mean <= 16
68
69 G4double value, t, y;
70 t = std::sqrt(-2*std::log(G4UniformRand()));
71 y = CLHEP::twopi*G4UniformRand();
72 t *= std::cos(y);
73 value = mean + t*std::sqrt(mean) + 0.5;
74 if(value <= 0) {return 0;}
75 if(value >= limit) { return G4long(limit);}
76 return G4long(value);
77}
double G4double
Definition: G4Types.hh:64
long G4long
Definition: G4Types.hh:68
int G4int
Definition: G4Types.hh:66
#define G4UniformRand()
Definition: Randomize.hh:53

Referenced by G4WilsonAbrasionModel::ApplyYourself(), G4ShellVacancy::GenerateNumberOfIonisations(), G4ForwardXrayTR::GetEnergyTR(), G4VEnergyLoss::GetLossWithFluct(), G4VeLowEnergyLoss::GetLossWithFluct(), G4NeutronHPPhotonDist::GetPhotons(), G4PAIxSection::GetStepCerenkovLoss(), G4PAIySection::GetStepCerenkovLoss(), G4PAIxSection::GetStepEnergyLoss(), G4PAIySection::GetStepEnergyLoss(), G4PAIxSection::GetStepMMLoss(), G4PAIxSection::GetStepPlasmonLoss(), G4PAIySection::GetStepPlasmonLoss(), G4PAIxSection::GetStepResonanceLoss(), G4Cerenkov::PostStepDoIt(), G4ForwardXrayTR::PostStepDoIt(), G4Scintillation::PostStepDoIt(), G4OpWLS::PostStepDoIt(), G4RPGFragmentation::ReactionStage(), G4RPGTwoBody::ReactionStage(), G4RPGTwoCluster::ReactionStage(), G4NeutronHPProduct::Sample(), G4BohrFluctuations::SampleFluctuations(), G4UniversalFluctuation::SampleFluctuations(), and G4NeutronHPFSFissionFS::SampleNeutronMult().