69{
70
71
72 fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, 0.0));
73 fParticleGun->SetParticlePolarization(G4ThreeVector(0,1,0));
74
75 G4double particleEnergy = 1e-9*eV + G4UniformRand()*(1e-7*eV-1e-9*eV);
77
78 G4double theta = 2*pi*G4UniformRand();
79 G4double phi = std::acos(1-2*G4UniformRand());
80 if (phi > pi/2 && phi < pi) phi = pi-phi;
81
82 G4double z = std::sin(phi)*std::cos(theta);
83 G4double x = std::sin(phi)*std::sin(theta);
84 G4double y = std::cos(phi);
85
86 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(x,y,z));
87
89}