Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
G4Poisson.hh File Reference
#include <CLHEP/Units/PhysicalConstants.h>
#include "G4Types.hh"
#include "G4Exp.hh"
#include "Randomize.hh"

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.

References G4Exp(), and G4UniformRand.

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

52 {
53  G4long number = 0;
54  const G4int border = 16;
55  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 value, t, y;
73  t = std::sqrt(-2*std::log(G4UniformRand()));
74  y = CLHEP::twopi*G4UniformRand();
75  t *= std::cos(y);
76  value = mean + t*std::sqrt(mean) + 0.5;
77  if(value <= 0) {return 0;}
78  if(value >= limit) { return G4long(limit);}
79  return G4long(value);
80 }
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:87
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:180
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76