36 #include "PrimaryGeneratorAction.hh"
67 G4double sinAlpha = std::sqrt(1. - cosAlpha*cosAlpha);
69 G4ThreeVector dir(sinAlpha*std::cos(psi),sinAlpha*std::sin(psi),cosAlpha);
96 { 0.000, 0.077, 0.380, 2.044, 5.535, 15.077, 12.443, 14.766,
97 17.644, 18.518, 17.772, 14.776, 8.372, 3.217, 0.194, 0.000 };
104 x[j] = xx[j];
f[j] = ff[j];
111 for (
G4int j=0; j<nPoints-1; j++) {
112 a[j] = (
f[j+1] -
f[j])/(
x[j+1] -
x[j]);
120 Fc[j] =
Fc[j-1] + 0.5*(
f[j] +
f[j-1])*(
x[j] -
x[j-1]);
131 G4double x_rndm = 0., y_rndm = 0., f_inter = -1.;
133 while (y_rndm > f_inter) {
139 while ((
x[j] > x_rndm) && (j > 0)) j--;
141 f_inter =
f[j] +
a[j]*(x_rndm -
x[j]);
158 while ((
Fc[j] > y_rndm) && (j > 0)) j--;
166 x_rndm += sign*std::sqrt(delta) - b;
167 }
else if (
f[j] > 0.) {
168 x_rndm += (y_rndm -
Fc[j])/
f[j];
Definition of the PrimaryGeneratorAction2 class.
CLHEP::Hep3Vector G4ThreeVector
void GeneratePrimaries(G4Event *)
std::vector< G4double > a
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
G4ParticleGun * particleGun
virtual void GeneratePrimaryVertex(G4Event *evt)
PrimaryGeneratorAction2(G4ParticleGun *)
void SetParticleEnergy(G4double aKineticEnergy)
std::vector< G4double > x
G4double energy(const ThreeVector &p, const G4double m)
std::vector< G4double > Fc
std::vector< G4double > f
G4int sign(const T t)
A simple sign function that allows us to port fortran code to c++ more easily.
~PrimaryGeneratorAction2()