G4RandomDirection.hh File Reference

#include <CLHEP/Units/PhysicalConstants.h>
#include "globals.hh"
#include "Randomize.hh"
#include "G4ThreeVector.hh"

Go to the source code of this file.

Functions

G4ThreeVector G4RandomDirection ()


Function Documentation

G4ThreeVector G4RandomDirection (  )  [inline]

Definition at line 55 of file G4RandomDirection.hh.

References G4UniformRand.

Referenced by G4MuonMinusBoundDecay::ApplyYourself(), G4MuMinusCapturePrecompound::ApplyYourself(), G4QNucleus::ChooseFermiMomenta(), G4QNucleus::ChoosePositions(), G4PionDecayMakeSpin::DaughterPolarization(), G4LambertianRand(), G4QLowEnergy::PostStepDoIt(), G4QInelastic::PostStepDoIt(), G4QDiffractionRatio::ProjFragment(), G4HeatedKleinNishinaCompton::SampleSecondaries(), G4eeTo3PiModel::SampleSecondaries(), and G4QDiffractionRatio::TargFragment().

00056 {
00057   G4double cosTheta  = 2.*G4UniformRand()-1.;
00058   G4double sinTheta2 = 1. - cosTheta*cosTheta;
00059   if( sinTheta2 < 0.)  sinTheta2 = 0.;
00060   G4double sinTheta  = std::sqrt(sinTheta2); 
00061   G4double phi       = CLHEP::twopi*G4UniformRand();
00062   return G4ThreeVector(sinTheta*std::cos(phi),
00063                        sinTheta*std::sin(phi), cosTheta).unit(); 
00064 }


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