36 #include "PrimaryGeneratorAction.hh"
67 G4double sinAlpha = std::sqrt(1. - cosAlpha*cosAlpha);
69 G4ThreeVector dir(sinAlpha*std::cos(psi),sinAlpha*std::sin(psi),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 fX.resize(fNPoints); fY.resize(fNPoints);
103 for (
G4int j=0; j<fNPoints; j++) {
104 fX[j] = xx[j]; fY[j] = yy[j];
105 if (fYmax < fY[j]) fYmax = fY[j];
110 fSlp.resize(fNPoints);
111 for (
G4int j=0; j<fNPoints-1; j++) {
112 fSlp[j] = (fY[j+1] - fY[j])/(fX[j+1] - fX[j]);
117 fYC.resize(fNPoints);
119 for (
G4int j=1; j<fNPoints; j++) {
120 fYC[j] = fYC[j-1] + 0.5*(fY[j] + fY[j-1])*(fX[j] - fX[j-1]);
131 G4double Xrndm = 0., Yrndm = 0., Yinter = -1.;
133 while (Yrndm > Yinter) {
138 G4int j = fNPoints-2;
139 while ((fX[j] > Xrndm) && (j > 0)) j--;
141 Yinter = fY[j] + fSlp[j]*(Xrndm - fX[j]);
157 G4int j = fNPoints-2;
158 while ((fYC[j] > Yrndm) && (j > 0)) j--;
166 Xrndm += sign*std::sqrt(delta) -
b;
167 }
else if (fY[j] > 0.) {
168 Xrndm += (Yrndm - fYC[j])/fY[j];
Definition of the PrimaryGeneratorAction2 class.
std::vector< ExP01TrackerHit * > a
void GeneratePrimaries(G4Event *)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
static constexpr double twopi
PrimaryGeneratorAction2(G4ParticleGun *)
void SetParticleEnergy(G4double aKineticEnergy)
G4double energy(const ThreeVector &p, const G4double m)
static constexpr double keV
~PrimaryGeneratorAction2()