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