From cd504e86ef66d4db575a480421abd46d52b45a31 Mon Sep 17 00:00:00 2001 From: Adrien Matta <matta@lpccaen.in2p3.fr> Date: Mon, 27 Apr 2020 14:33:25 +0200 Subject: [PATCH] * Fixing issue with elastic scattering - The elastic process could trigger to daughters particle in certain cases - This lead to an infinite chain of particle generation stopping the programm - Beam reaction now test the parent particle have trackID 0 --- NPSimulation/Process/BeamReaction.cc | 11 +++++++++-- NPSimulation/Process/BeamReaction.hh | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NPSimulation/Process/BeamReaction.cc b/NPSimulation/Process/BeamReaction.cc index 07f42fcf5..3ace565b8 100644 --- a/NPSimulation/Process/BeamReaction.cc +++ b/NPSimulation/Process/BeamReaction.cc @@ -123,6 +123,11 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { double out = solid->DistanceToOut(P, -V); double ratio = in / (out + in); + m_Parent_ID = PrimaryTrack->GetParentID(); + // process reserved to the beam + if(m_Parent_ID!=0) + return false; + //cout<< "in:"<<in<<std::scientific<<endl; //cout<< "ou:"<<out<<std::scientific<<endl; //cout<< "ratio:"<<ratio<<std::scientific<<endl; @@ -137,7 +142,7 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { m_ReactionConditions->Clear(); shoot = true; } - else if ((in-m_StepSize) <= 1E-9) { // last step + else if (((in-m_StepSize) <= 1E-9) && shoot) { // last step //cout<< "LAST"<<endl; return true; } @@ -157,7 +162,9 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { } else { return false; } - }else if(m_ReactionType=="TwoBodyReaction"){ + } + + else if(m_ReactionType=="TwoBodyReaction"){ if ( shoot && m_Reaction.IsAllowed(PrimaryTrack->GetKineticEnergy()) ) { shoot = false; return true; diff --git a/NPSimulation/Process/BeamReaction.hh b/NPSimulation/Process/BeamReaction.hh index b77c424d8..f5c9a41d2 100644 --- a/NPSimulation/Process/BeamReaction.hh +++ b/NPSimulation/Process/BeamReaction.hh @@ -52,6 +52,7 @@ namespace NPS{ double m_PreviousLength; bool m_active;// is the process active double m_StepSize; + int m_Parent_ID; private: TReactionConditions* m_ReactionConditions; -- GitLab