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

G4long G4Poisson ( G4double  mean  )  [inline]

Definition at line 50 of file G4Poisson.hh.

References G4UniformRand, and position.

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

00051 {
00052   G4long number = 0;
00053   const G4int border = 16;
00054   G4double limit = 2e9;
00055 
00056   if(mean <= border) {
00057     G4double position = G4UniformRand();
00058     G4double poissonValue = std::exp(-mean);
00059     G4double poissonSum = poissonValue;
00060 
00061     while(poissonSum <= position) {
00062       number++ ;
00063       poissonValue *= mean/number;
00064       poissonSum += poissonValue;
00065     }
00066     return number;
00067   } // the case of mean <= 16
00068 
00069   G4double value, t, y;
00070   t = std::sqrt(-2*std::log(G4UniformRand()));
00071   y = CLHEP::twopi*G4UniformRand();
00072   t *= std::cos(y);
00073   value = mean + t*std::sqrt(mean) + 0.5;
00074   if(value <= 0) {return 0;}
00075   if(value >= limit) { return G4long(limit);}
00076   return G4long(value);
00077 }


Generated on Mon May 27 17:51:02 2013 for Geant4 by  doxygen 1.4.7