117 const G4ElementVector* elementVector = material->GetElementVector();
118 const G4double* numberOfAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
120 G4double numberOfProtons = 0;
121 G4double numberOfNucleons = 0;
124 for (
size_t elm = 0; elm < material->GetNumberOfElements(); elm++) {
126 numberOfProtons += numberOfAtomsPerVolume[elm] * (*elementVector)[elm]->GetZ();
128 numberOfNucleons += numberOfAtomsPerVolume[elm] * (*elementVector)[elm]->GetN();
132 if (G4UniformRand() < numberOfProtons / numberOfNucleons) {
140 const G4int incidentPDG = incidentDynamicParticle->GetDefinition()->GetPDGEncoding();
157 for (ReactionProductList::iterator prod_it = reactionProductList->begin(); prod_it != reactionProductList->end();
159 G4int secondaries = prod_it->size();
163 goodReactionProductList.push_back(*prod_it);
164 if (secondaries == 2) {
166 }
else if (secondaries == 3) {
169 G4cerr <<
"ReactionProduct has unsupported number of secondaries: " << secondaries << G4endl;
177 if (goodReactionProductList.empty())
178 G4Exception(
"HadronicProcessHelper",
181 "GetFinalState: No process could be selected from the given list.");
184 G4double prob22 = 0.15;
185 G4double prob23 = 1 - prob22;
187 std::vector<G4double> probabilities;
188 std::vector<G4bool> twoToThreeFlag;
190 G4double cumulatedProbability = 0;
194 size_t numberOfReactions = goodReactionProductList.size();
195 for (
size_t i = 0;
i != numberOfReactions;
i++) {
196 if (goodReactionProductList[
i].
size() == 2) {
197 cumulatedProbability += prob22 / good22;
198 twoToThreeFlag.push_back(
false);
200 cumulatedProbability += prob23 / good23;
201 twoToThreeFlag.push_back(
true);
203 probabilities.push_back(cumulatedProbability);
207 for (std::vector<G4double>::iterator it = probabilities.begin(); it != probabilities.end(); it++) {
208 *it /= cumulatedProbability;
212 G4bool selected =
false;
218 while (!selected && tries < 100) {
220 G4double dice = G4UniformRand();
222 while (dice > probabilities[i] && i < numberOfReactions)
225 if (twoToThreeFlag[i]) {
227 if (
m_phaseSpace(goodReactionProductList[i], incidentDynamicParticle,
target) > G4UniformRand())
236 G4cerr <<
"Could not select process!!!!" << G4endl;
240 if (goodReactionProductList[i].
size() == 2) {
248 return goodReactionProductList[
i];
ReactionMap m_neutronReactionMap
G4bool m_reactionIsPossible(const ReactionProduct &aReaction, const G4DynamicParticle *aDynamicParticle, G4ParticleDefinition *target)
G4double m_phaseSpace(const ReactionProduct &aReaction, const G4DynamicParticle *aDynamicParticle, G4ParticleDefinition *target)
std::map< G4int, ReactionProductList > ReactionMap
G4ParticleDefinition * m_neutron
ReactionMap m_protonReactionMap
G4ParticleDefinition * m_proton
std::vector< ReactionProduct > ReactionProductList