118 const G4ElementVector* elementVector = material->GetElementVector() ;
119 const G4double* numberOfAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
121 G4double numberOfProtons=0;
122 G4double numberOfNucleons=0;
125 for (
size_t elm=0 ; elm < material->GetNumberOfElements() ; elm++ )
128 numberOfProtons += numberOfAtomsPerVolume[elm]*(*elementVector)[elm]->GetZ();
130 numberOfNucleons += numberOfAtomsPerVolume[elm]*(*elementVector)[elm]->GetN();
134 if(G4UniformRand()<numberOfProtons/numberOfNucleons)
143 const G4int incidentPDG = incidentDynamicParticle->GetDefinition()->GetPDGEncoding();
160 for (ReactionProductList::iterator prod_it = reactionProductList->begin();
161 prod_it != reactionProductList->end();
163 G4int secondaries = prod_it->size();
167 goodReactionProductList.push_back(*prod_it);
168 if (secondaries == 2){
170 }
else if (secondaries ==3) {
173 G4cerr <<
"ReactionProduct has unsupported number of secondaries: "<<secondaries<<G4endl;
181 if (goodReactionProductList.empty()) G4Exception(
"HadronicProcessHelper",
"NoProcessPossible", FatalException,
182 "GetFinalState: No process could be selected from the given list.");
185 G4double prob22 = 0.15;
186 G4double prob23 = 1-prob22;
188 std::vector<G4double> probabilities;
189 std::vector<G4bool> twoToThreeFlag;
191 G4double cumulatedProbability = 0;
195 size_t numberOfReactions = goodReactionProductList.size();
196 for (
size_t i = 0;
i != numberOfReactions;
i++){
197 if (goodReactionProductList[
i].
size() == 2) {
198 cumulatedProbability += prob22/good22;
199 twoToThreeFlag.push_back(
false);
201 cumulatedProbability += prob23/good23;
202 twoToThreeFlag.push_back(
true);
204 probabilities.push_back(cumulatedProbability);
208 for (std::vector<G4double>::iterator it = probabilities.begin();
209 it != probabilities.end();
212 *it /= cumulatedProbability;
216 G4bool selected =
false;
222 while(!selected && tries < 100){
224 G4double dice = G4UniformRand();
226 while(dice>probabilities[i] && i<numberOfReactions) i++;
228 if(twoToThreeFlag[i]) {
230 if (
m_phaseSpace(goodReactionProductList[i],incidentDynamicParticle,
target)>G4UniformRand()) selected =
true;
237 if(tries>=100)
G4cerr<<
"Could not select process!!!!"<<G4endl;
242 if (goodReactionProductList[i].
size()==2) {
250 return goodReactionProductList[
i];
std::vector< ReactionProduct > ReactionProductList
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