From 7f9f4ff51320be246b7f6ced065bd2a0f1b2411c Mon Sep 17 00:00:00 2001 From: JuanGonzalezCaminero Date: Fri, 21 Mar 2025 15:46:26 +0100 Subject: [PATCH] Setting step status when on boundary --- examples/Example1/src/RunAction.cc | 2 +- .../integration/AdePTGeant4Integration.hh | 3 ++- include/AdePT/kernels/gammas.cuh | 1 + src/AdePTGeant4Integration.cpp | 21 +++++++++++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/Example1/src/RunAction.cc b/examples/Example1/src/RunAction.cc index 9aa6c57e4..e7ddc328b 100644 --- a/examples/Example1/src/RunAction.cc +++ b/examples/Example1/src/RunAction.cc @@ -54,6 +54,6 @@ void RunAction::EndOfRunAction(const G4Run *) const std::lock_guard lock(print_mutex); // Print timer just for the master thread since this is called when all workers are done if (tid < 0) { - G4cout << "Run time: " << time << "\n"; + std::cout << "Run time: " << time << "\n"; } } diff --git a/include/AdePT/integration/AdePTGeant4Integration.hh b/include/AdePT/integration/AdePTGeant4Integration.hh index 852f7c57b..f9cb797f9 100644 --- a/include/AdePT/integration/AdePTGeant4Integration.hh +++ b/include/AdePT/integration/AdePTGeant4Integration.hh @@ -82,7 +82,8 @@ private: void FillG4NavigationHistory(vecgeom::NavigationState aNavState, G4NavigationHistory &aG4NavigationHistory) const; void FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, G4TouchableHandle &aPreG4TouchableHandle, - G4TouchableHandle &aPostG4TouchableHandle) const; + G4TouchableHandle &aPostG4TouchableHandle, G4StepStatus aPreStepStatus, + G4StepStatus aPostStepStatus) const; void ReturnTrack(adeptint::TrackData const &track, unsigned int trackIndex, int debugLevel) const; diff --git a/include/AdePT/kernels/gammas.cuh b/include/AdePT/kernels/gammas.cuh index d75459e0f..e85b866d6 100644 --- a/include/AdePT/kernels/gammas.cuh +++ b/include/AdePT/kernels/gammas.cuh @@ -466,6 +466,7 @@ __global__ void TransportGammas(adept::TrackManager *gammas, Secondaries survive(); } } + // If there is some edep from cutting particles, record the step if ((edep > 0 && auxData.fSensIndex >= 0) || returnAllSteps || returnLastStep) { adept_scoring::RecordHit(userScoring, diff --git a/src/AdePTGeant4Integration.cpp b/src/AdePTGeant4Integration.cpp index 9be654198..d5f6a09a0 100644 --- a/src/AdePTGeant4Integration.cpp +++ b/src/AdePTGeant4Integration.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -351,6 +352,17 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs &fScoringObjects->fPostG4NavigationHistory); } + // Get step status + // NOTE: Currently, we only check for the geometrical boundary, other statuses are set as unknown for now + G4StepStatus preStepStatus{G4StepStatus::fUndefined}; + G4StepStatus postStepStatus{G4StepStatus::fUndefined}; + if (preNavState.IsOnBoundary()) { + preStepStatus = G4StepStatus::fGeomBoundary; + } + if (postNavState.IsOnBoundary()) { + postStepStatus = G4StepStatus::fGeomBoundary; + } + // Reconstruct G4Step switch (hit.fParticleType) { case 0: @@ -364,7 +376,7 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs break; } FillG4Step(&hit, fScoringObjects->fG4Step, *fScoringObjects->fPreG4TouchableHistoryHandle, - *fScoringObjects->fPostG4TouchableHistoryHandle); + *fScoringObjects->fPostG4TouchableHistoryHandle, preStepStatus, postStepStatus); // Call SD code G4VSensitiveDetector *aSensitiveDetector = @@ -445,7 +457,8 @@ void AdePTGeant4Integration::FillG4NavigationHistory(vecgeom::NavigationState aN void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, G4TouchableHandle &aPreG4TouchableHandle, - G4TouchableHandle &aPostG4TouchableHandle) const + G4TouchableHandle &aPostG4TouchableHandle, G4StepStatus aPreStepStatus, + G4StepStatus aPostStepStatus) const { const G4ThreeVector aPostStepPointMomentumDirection(aGPUHit->fPostStepPoint.fMomentumDirection.x(), aGPUHit->fPostStepPoint.fMomentumDirection.y(), @@ -519,7 +532,7 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, aPreStepPoint->SetPolarization(G4ThreeVector(aGPUHit->fPreStepPoint.fPolarization.x(), aGPUHit->fPreStepPoint.fPolarization.y(), aGPUHit->fPreStepPoint.fPolarization.z())); // Real data - // aPreStepPoint->SetStepStatus(G4StepStatus::fUndefined); // Missing data + aPreStepPoint->SetStepStatus(aPreStepStatus); // Missing data // aPreStepPoint->SetProcessDefinedStep(nullptr); // Missing data // aPreStepPoint->SetMass(0); // Missing data aPreStepPoint->SetCharge(aGPUHit->fPreStepPoint.fCharge); // Real data @@ -544,7 +557,7 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, // aPostStepPoint->SetSensitiveDetector(nullptr); // Missing data // aPostStepPoint->SetSafety(0); // Missing data aPostStepPoint->SetPolarization(aPostStepPointPolarization); // Real data - // aPostStepPoint->SetStepStatus(G4StepStatus::fUndefined); // Missing data + aPostStepPoint->SetStepStatus(aPostStepStatus); // Missing data // aPostStepPoint->SetProcessDefinedStep(nullptr); // Missing data // aPostStepPoint->SetMass(0); // Missing data aPostStepPoint->SetCharge(aGPUHit->fPostStepPoint.fCharge); // Real data