38 theTotalResult->Clear();
39 theTotalResult->Initialize(aTrack);
40 theTotalResult->ProposeWeight(aTrack.GetWeight());
41 if (aTrack.GetTrackStatus() != fAlive) {
42 return theTotalResult;
47 G4DynamicParticle* aParticle =
const_cast<G4DynamicParticle*
>(aTrack.GetDynamicParticle());
50 aParticle->SetPDGcode(2112);
51 aParticle->SetDefinition(G4Neutron::Neutron());
53 G4Nucleus*
target = GetTargetNucleusPointer();
54 const G4Material* aMaterial = aTrack.GetMaterial();
55 const G4Element* anElement = GetCrossSectionDataStore()->SampleZandA(aParticle, aMaterial, *
target);
59 if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) {
60 if (aTrack.GetTrackStatus() == fStopAndKill || aTrack.GetTrackStatus() == fKillTrackAndSecondaries ||
61 aTrack.GetTrackStatus() == fPostponeToNextEvent) {
62 G4ExceptionDescription ed;
63 ed <<
"CMSSIMPInelasticProcess: track in unusable state - " << aTrack.GetTrackStatus() << G4endl;
64 ed <<
"CMSSIMPInelasticProcess: returning unchanged track " << G4endl;
65 DumpState(aTrack,
"PostStepDoIt", ed);
66 G4Exception(
"CMSSIMPInelasticProcess::PostStepDoIt",
"had004", JustWarning, ed);
69 return theTotalResult;
73 thePro.Initialise(aTrack);
74 G4HadronicInteraction* anInteraction = GetHadronicInteractionList()[0];
76 G4HadFinalState*
result =
nullptr;
77 G4int reentryCount = 0;
84 }
catch (G4HadronicException& aR) {
85 G4ExceptionDescription ed;
87 ed <<
"Call for " << anInteraction->GetModelName() << G4endl;
88 ed <<
"Target element " << anElement->GetName() <<
" Z= " <<
target->GetZ_asInt()
89 <<
" A= " <<
target->GetA_asInt() << G4endl;
90 DumpState(aTrack,
"ApplyYourself", ed);
91 ed <<
" ApplyYourself failed" << G4endl;
92 G4Exception(
"CMSSIMPInelasticProcess::PostStepDoIt",
"had006", FatalException, ed);
97 if (reentryCount > 100) {
98 G4ExceptionDescription ed;
99 ed <<
"Call for " << anInteraction->GetModelName() << G4endl;
100 ed <<
"Target element " << anElement->GetName() <<
" Z= " <<
target->GetZ_asInt()
101 <<
" A= " <<
target->GetA_asInt() << G4endl;
102 DumpState(aTrack,
"ApplyYourself", ed);
103 ed <<
" ApplyYourself does not completed after 100 attempts" << G4endl;
104 G4Exception(
"CMSSIMPInelasticProcess::PostStepDoIt",
"had006", FatalException, ed);
112 G4int nSec =
result->GetNumberOfSecondaries();
114 for (G4int
i = 0;
i < nSec; ++
i) {
115 G4DynamicParticle* dynamicParticle =
result->GetSecondary(
i)->GetParticle();
116 const G4ParticleDefinition* particleDefinition = dynamicParticle->GetParticleDefinition();
117 if (particleDefinition == G4KaonZero::Definition() || particleDefinition == G4AntiKaonZero::Definition()) {
118 G4ParticleDefinition* newPart;
119 if (G4UniformRand() > 0.5) {
120 newPart = G4KaonZeroShort::Definition();
122 newPart = G4KaonZeroLong::Definition();
124 dynamicParticle->SetDefinition(newPart);
125 G4ExceptionDescription ed;
126 ed <<
" Hadronic model " << anInteraction->GetModelName() << G4endl;
127 ed <<
" created " << particleDefinition->GetParticleName() << G4endl;
128 ed <<
" -> forced to be " << newPart->GetParticleName() << G4endl;
129 G4Exception(
"G4HadronicProcess::PostStepDoIt",
"had007", JustWarning, ed);
134 result->SetTrafoToLab(thePro.GetTrafoToLab());
136 ClearNumberOfInteractionLengthLeft();
138 FillResult(
result, aTrack);
140 return theTotalResult;