Geant4 10.7.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 "G4Exp.hh"
#include "G4Types.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 const G4double limit = 2e9;
55
56 if(mean <= border)
57 {
59 G4double poissonValue = G4Exp(-mean);
60 G4double poissonSum = poissonValue;
61
62 while(poissonSum <= position)
63 {
64 ++number;
65 poissonValue *= mean / number;
66 poissonSum += poissonValue;
67 }
68 return number;
69 } // the case of mean <= 16
70
71 G4double t = std::sqrt(-2. * std::log(G4UniformRand())) *
72 std::cos(2. * CLHEP::pi * G4UniformRand());
73 G4double value = mean + t * std::sqrt(mean) + 0.5;
74 if(value < 0.)
75 {
76 return 0;
77 }
78 return (value >= limit) ? G4long(limit) : G4long(value);
79}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:179
double G4double
Definition: G4Types.hh:83
long G4long
Definition: G4Types.hh:87
int G4int
Definition: G4Types.hh:85
#define G4UniformRand()
Definition: Randomize.hh:52

Referenced by G4WilsonAbrasionModel::ApplyYourself(), G4ShellVacancy::GenerateNumberOfIonisations(), G4ForwardXrayTR::GetEnergyTR(), G4ParticleHPProduct::GetMultiplicity(), G4ParticleHPPhotonDist::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(), G4OpWLS2::PostStepDoIt(), G4RPGFragmentation::ReactionStage(), G4RPGTwoBody::ReactionStage(), G4RPGTwoCluster::ReactionStage(), G4PAIPhotData::SampleAlongStepPhotonTransfer(), G4PAIPhotData::SampleAlongStepPlasmonTransfer(), G4PAIPhotData::SampleAlongStepTransfer(), G4PAIModelData::SampleAlongStepTransfer(), G4BohrFluctuations::SampleFluctuations(), G4UniversalFluctuation::SampleFluctuations(), and G4ParticleHPFSFissionFS::SampleNeutronMult().