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

Go to the source code of this file.

Functions

G4ThreeVector G4RandomDirection ()
 
G4ThreeVector G4RandomDirection (G4double cosTheta)
 

Function Documentation

◆ G4RandomDirection() [1/2]

G4ThreeVector G4RandomDirection ( )
inline

Definition at line 58 of file G4RandomDirection.hh.

59{
60 G4double u, v, b;
61 do
62 {
63 u = 2. * G4UniformRand() - 1.;
64 v = 2. * G4UniformRand() - 1.;
65 b = u * u + v * v;
66 } while(b > 1.);
67 G4double a = 2. * std::sqrt(1. - b);
68 return G4ThreeVector(a * u, a * v, 2. * b - 1.);
69}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
#define G4UniformRand()
Definition: Randomize.hh:52

Referenced by G4MuMinusCapturePrecompound::ApplyYourself(), G4MuonMinusBoundDecay::ApplyYourself(), G4NeutronRadCapture::ApplyYourself(), G4MuonMinusAtomicCapture::AtRestDoIt(), G4UnstableFragmentBreakUp::BreakUpChain(), G4LightTargetCollider::collide(), G4PionDecayMakeSpin::DaughterPolarization(), G4FermiPhaseSpaceDecay::Decay(), G4DNABrownianTransportation::Diffusion(), G4GEMChannel::EmittedFragment(), G4GEMChannelVI::EmittedFragment(), G4EvaporationChannel::EmittedFragment(), G4CompetitiveFission::EmittedFragment(), G4LambertianRand(), G4RandomPointOnEllipsoid(), DNA::Penetration::GetGaussianPenetrationFromRmean3D(), DNA::Penetration::Kreipl2009::GetPenetration(), G4Orb::GetPointOnSurface(), G4PreCompoundEmission::PerformEmission(), G4PhononScattering::PostStepDoIt(), G4GEMProbabilityVI::SampleEvaporationFragment(), G4ANuElNucleusCcModel::SampleLVkr(), G4ANuElNucleusNcModel::SampleLVkr(), G4ANuMuNucleusCcModel::SampleLVkr(), G4ANuMuNucleusNcModel::SampleLVkr(), G4ANuTauNucleusCcModel::SampleLVkr(), G4ANuTauNucleusNcModel::SampleLVkr(), G4NuElNucleusCcModel::SampleLVkr(), G4NuElNucleusNcModel::SampleLVkr(), G4NuMuNucleusCcModel::SampleLVkr(), G4NuMuNucleusNcModel::SampleLVkr(), G4NuTauNucleusCcModel::SampleLVkr(), G4NuTauNucleusNcModel::SampleLVkr(), G4eeToTwoGammaModel::SampleSecondaries(), G4eeTo3PiModel::SampleSecondaries(), and G4GammaTransition::SampleTransition().

◆ G4RandomDirection() [2/2]

G4ThreeVector G4RandomDirection ( G4double  cosTheta)
inline

Definition at line 71 of file G4RandomDirection.hh.

72{
73 G4double z = (1. - cosTheta) * G4UniformRand() + cosTheta;
74 G4double rho = std::sqrt((1. + z) * (1. - z));
75 G4double phi = CLHEP::twopi * G4UniformRand();
76 return G4ThreeVector(rho * std::cos(phi), rho * std::sin(phi), z);
77}