From 48de41f734df53c43ff98f7bfbe255fc2e1d5bf3 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Fri, 17 May 2024 11:51:23 +0200 Subject: [PATCH 1/2] skip track if isotope in the ignore list --- src/StackingAction.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/StackingAction.cxx b/src/StackingAction.cxx index fc28bdcd..61818b7b 100644 --- a/src/StackingAction.cxx +++ b/src/StackingAction.cxx @@ -27,8 +27,8 @@ for (const auto& particle : fParticlesToIgnore) { } G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* track) { - const G4ClassificationOfNewTrack decayClassification = - fSimulationManager->GetRestMetadata()->isFullChainActivated() ? fWaiting : fKill; + const bool isFullChain = fSimulationManager->GetRestMetadata()->isFullChainActivated(); + const G4ClassificationOfNewTrack decayClassification = isFullChain ? fWaiting : fKill; if (track->GetParentID() <= 0) { // always process the first track regardless return fUrgent; @@ -40,6 +40,11 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* track return fKill; } + if (isFullChain && + fSimulationManager->GetRestMetadata()->IsIsotopeFullChainStop(particle->GetParticleName())) { + return fKill; + } + if (track->GetCreatorProcess()->GetProcessType() != G4ProcessType::fDecay) { return fUrgent; } From 3753b33a25957b60e6e8be60ac826d880eee9774 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Fri, 17 May 2024 11:57:53 +0200 Subject: [PATCH 2/2] handle excited states --- src/StackingAction.cxx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/StackingAction.cxx b/src/StackingAction.cxx index 61818b7b..81e995fb 100644 --- a/src/StackingAction.cxx +++ b/src/StackingAction.cxx @@ -3,13 +3,15 @@ #include #include -#include #include #include #include +#include #include "SimulationManager.h" +using namespace std; + StackingAction::StackingAction(SimulationManager* simulationManager) : fSimulationManager(simulationManager) { fMaxAllowedLifetime = 100; // TODO: update this @@ -19,11 +21,6 @@ StackingAction::StackingAction(SimulationManager* simulationManager) : fSimulati G4NeutrinoE::Definition(), G4AntiNeutrinoE::Definition(), G4NeutrinoMu::Definition(), G4AntiNeutrinoMu::Definition(), G4NeutrinoTau::Definition(), G4AntiNeutrinoTau::Definition(), }; - - /* -for (const auto& particle : fParticlesToIgnore) { -} - */ } G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* track) { @@ -40,9 +37,15 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* track return fKill; } - if (isFullChain && - fSimulationManager->GetRestMetadata()->IsIsotopeFullChainStop(particle->GetParticleName())) { - return fKill; + if (isFullChain) { + const string particleName = particle->GetParticleName(); + // the particle may be an excited state of an isotope we want to remove + // strip the excited state which is assumed to always be inside some "[]" + regex pattern("\\[.*\\]"); + std::string particleNameStripped = regex_replace(particleName, pattern, ""); + if (fSimulationManager->GetRestMetadata()->IsIsotopeFullChainStop(particleNameStripped)) { + return fKill; + } } if (track->GetCreatorProcess()->GetProcessType() != G4ProcessType::fDecay) { @@ -67,7 +70,7 @@ void StackingAction::NewStage() { * Close event and start a new sub event if there are waiting tracks */ - const auto outputManager = fSimulationManager->GetOutputManager(); + const auto outputManager = SimulationManager::GetOutputManager(); const Int_t subEventID = outputManager->fEvent->GetSubID(); outputManager->FinishAndSubmitEvent();