63 particleGun -> SetParticlePosition(position);
65 particleGun -> SetParticleMomentumDirection(direction);
66 particleGun -> SetParticleEnergy(250. *
MeV);
81 G4double primaryParticleEnergy = particleGun -> GetParticleEnergy();
82 return primaryParticleEnergy;
87 G4int baryon = particleGun -> GetParticleDefinition() -> GetBaryonNumber();
101 while (nabove > nbelow+1) {
102 middle = (nabove + nbelow+1)>>1;
103 if (random >= cumulate[middle]) {
114 G4double binMeasure = cumulate[nabove] - cumulate[nbelow];
116 if ( binMeasure == 0 ) {
118 energy_gun = (energy[nbelow] + random*(energy[nabove] - energy[nbelow]))* baryon;
124 G4double binFraction = (random - cumulate[nbelow]) / binMeasure;
125 energy_gun = energy[nbelow] + binFraction *(energy[nabove] - energy[nbelow]);
127 particleGun -> SetParticleEnergy(energy_gun * baryon);
131 particleGun -> GeneratePrimaryVertex(anEvent);
141 std::filebuf* lsdp = file.rdbuf();
143 if (! (lsdp->is_open()) )
145 G4String excep =
"RemSimPrimaryGenerator - data file: "
146 + fileName +
" not found";
147 G4Exception(
"RemSimPrimaryGeneratorAction::ReadProbability()",
163 if (a == -1 || a == -2)
172 energies -> push_back(ene);
176 else if (k%nColumns == 0)
179 data -> push_back(data_value);
192 energy [0] = (*energies)[0];
194 for (
G4int ptn = 0; ptn <size; ptn++ ) {
196 G4double yy = ((*data)[ptn+1] + (*data)[ptn])/2.;
198 cumulate[ptn +1] = cumulate[ptn] +
weight;
199 energy[ptn+1] = (*energies)[ptn+1];
203 for (
G4int ptn= 0; ptn < size + 1; ptn++ )
205 cumulate[ptn] /= cumulate[size];