Skip to content
Snippets Groups Projects
Commit 0a24e7eb authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Fixing issue in beam reaction after merge

        - The active flag was reset to 0 preventing reaction from
          occuring
parent 2466a5d8
No related branches found
No related tags found
No related merge requests found
...@@ -74,7 +74,7 @@ Target::Target(){ ...@@ -74,7 +74,7 @@ Target::Target(){
m_TargetNbLayers = 5; // Number of steps by default m_TargetNbLayers = 5; // Number of steps by default
// Set the global pointer // Set the global pointer
TargetInstance = this; TargetInstance = this;
m_ReactionRegion=0; m_ReactionRegion=NULL;
m_TargetDensity = 0 ; m_TargetDensity = 0 ;
m_FrontDeformation = 0 ; m_FrontDeformation = 0 ;
......
...@@ -37,7 +37,7 @@ NPS::BeamReaction::BeamReaction(G4String modelName,G4Region* envelope) : ...@@ -37,7 +37,7 @@ NPS::BeamReaction::BeamReaction(G4String modelName,G4Region* envelope) :
ReadConfiguration(); ReadConfiguration();
m_PreviousEnergy=0 ; m_PreviousEnergy=0 ;
m_PreviousLength=0 ; m_PreviousLength=0 ;
m_active = 0; m_active = true;
} }
...@@ -55,13 +55,22 @@ void NPS::BeamReaction::ReadConfiguration(){ ...@@ -55,13 +55,22 @@ void NPS::BeamReaction::ReadConfiguration(){
NPL::InputParser input(NPOptionManager::getInstance()->GetReactionFile()); NPL::InputParser input(NPOptionManager::getInstance()->GetReactionFile());
m_Reaction.ReadConfigurationFile(input); m_Reaction.ReadConfigurationFile(input);
m_BeamName=NPL::ChangeNameToG4Standard(m_Reaction.GetNucleus1().GetName()); m_BeamName=NPL::ChangeNameToG4Standard(m_Reaction.GetNucleus1().GetName());
if(m_Reaction.GetNucleus3().GetName()!="") if(m_Reaction.GetNucleus3().GetName()!=""){
m_active = true; m_active = true;
}
else{
m_active = false;
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
G4bool NPS::BeamReaction::IsApplicable( const G4ParticleDefinition& particleType) { G4bool NPS::BeamReaction::IsApplicable( const G4ParticleDefinition& particleType) {
std::string particleName = particleType.GetParticleName(); if(!m_active)
return false;
static std::string particleName;
particleName = particleType.GetParticleName();
if (particleName.find(m_BeamName)!=std::string::npos) { if (particleName.find(m_BeamName)!=std::string::npos) {
return true; return true;
} }
...@@ -70,9 +79,6 @@ G4bool NPS::BeamReaction::IsApplicable( const G4ParticleDefinition& particleType ...@@ -70,9 +79,6 @@ G4bool NPS::BeamReaction::IsApplicable( const G4ParticleDefinition& particleType
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) {
if(!m_active)
return false;
static bool shoot = false; static bool shoot = false;
static double rand = 0; static double rand = 0;
const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack();
...@@ -83,7 +89,11 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { ...@@ -83,7 +89,11 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) {
double in = solid->DistanceToOut(P,V); double in = solid->DistanceToOut(P,V);
double out = solid->DistanceToOut(P,-V); double out = solid->DistanceToOut(P,-V);
double ratio = in / (out+in) ; double ratio = in / (out+in) ;
// Generate a random for this event
if(ratio!=ratio)
ratio =1;
// Generate a random for this event
if(!shoot){ if(!shoot){
rand = G4RandFlat::shoot(); rand = G4RandFlat::shoot();
shoot = true; shoot = true;
......
...@@ -37,9 +37,9 @@ namespace NPS{ ...@@ -37,9 +37,9 @@ namespace NPS{
public: public:
void ReadConfiguration(); void ReadConfiguration();
virtual G4bool IsApplicable(const G4ParticleDefinition&); G4bool IsApplicable(const G4ParticleDefinition&);
virtual G4bool ModelTrigger(const G4FastTrack &); G4bool ModelTrigger(const G4FastTrack &);
virtual void DoIt(const G4FastTrack&, G4FastStep&); void DoIt(const G4FastTrack&, G4FastStep&);
private: private:
NPL::Reaction m_Reaction; NPL::Reaction m_Reaction;
......
...@@ -293,7 +293,7 @@ void PhysicsList::AddStepMax(){ ...@@ -293,7 +293,7 @@ void PhysicsList::AddStepMax(){
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void PhysicsList::AddParametrisation(){ void PhysicsList::AddParametrisation(){
G4FastSimulationManagerProcess* BeamReaction = G4FastSimulationManagerProcess* BeamReaction =
new G4FastSimulationManagerProcess("NPSProcess"); new G4FastSimulationManagerProcess("NPSimulationProcess");
// For 10.3 and higher // For 10.3 and higher
#ifndef theParticleIterator #ifndef theParticleIterator
...@@ -305,7 +305,7 @@ void PhysicsList::AddParametrisation(){ ...@@ -305,7 +305,7 @@ void PhysicsList::AddParametrisation(){
G4ParticleDefinition* particle = theParticleIterator->value(); G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager(); G4ProcessManager* pmanager = particle->GetProcessManager();
std::string name = particle->GetParticleName(); std::string name = particle->GetParticleName();
pmanager->AddDiscreteProcess(BeamReaction); pmanager->AddDiscreteProcess(BeamReaction);
// Add a Step limiter to the beam particle. // Add a Step limiter to the beam particle.
// This will be used to limit the step of the beam in the target // This will be used to limit the step of the beam in the target
pmanager->AddProcess(new G4StepLimiter,-1,-1,5); pmanager->AddProcess(new G4StepLimiter,-1,-1,5);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment