36 #include "PrimaryGeneratorAction.hh"
67 G4double sinAlpha = std::sqrt(1. - cosAlpha*cosAlpha);
85 void PrimaryGeneratorAction2::InitFunction()
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 };
101 x.resize(nPoints); f.resize(nPoints);
103 for (
G4int j=0; j<nPoints; j++) {
104 x[j] = xx[j]; f[j] = ff[j];
105 if (fMax < f[j]) fMax = f[j];
111 for (
G4int j=0; j<nPoints-1; j++) {
112 a[j] = (f[j+1] - f[j])/(x[j+1] - x[j]);
119 for (
G4int j=1; j<nPoints; 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--;
163 G4double b = f[j]/aa,
c = 2*(y_rndm - Fc[j])/aa;
166 x_rndm += sign*std::sqrt(delta) -
b;
167 }
else if (f[j] > 0.) {
168 x_rndm += (y_rndm - Fc[j])/f[j];