Skip to content

Commit 7f9f4ff

Browse files
Setting step status when on boundary
1 parent 2f3036c commit 7f9f4ff

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

examples/Example1/src/RunAction.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ void RunAction::EndOfRunAction(const G4Run *)
5454
const std::lock_guard<std::mutex> lock(print_mutex);
5555
// Print timer just for the master thread since this is called when all workers are done
5656
if (tid < 0) {
57-
G4cout << "Run time: " << time << "\n";
57+
std::cout << "Run time: " << time << "\n";
5858
}
5959
}

include/AdePT/integration/AdePTGeant4Integration.hh

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ private:
8282
void FillG4NavigationHistory(vecgeom::NavigationState aNavState, G4NavigationHistory &aG4NavigationHistory) const;
8383

8484
void FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step, G4TouchableHandle &aPreG4TouchableHandle,
85-
G4TouchableHandle &aPostG4TouchableHandle) const;
85+
G4TouchableHandle &aPostG4TouchableHandle, G4StepStatus aPreStepStatus,
86+
G4StepStatus aPostStepStatus) const;
8687

8788
void ReturnTrack(adeptint::TrackData const &track, unsigned int trackIndex, int debugLevel) const;
8889

include/AdePT/kernels/gammas.cuh

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ __global__ void TransportGammas(adept::TrackManager<Track> *gammas, Secondaries
466466
survive();
467467
}
468468
}
469+
469470
// If there is some edep from cutting particles, record the step
470471
if ((edep > 0 && auxData.fSensIndex >= 0) || returnAllSteps || returnLastStep) {
471472
adept_scoring::RecordHit(userScoring,

src/AdePTGeant4Integration.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <G4TouchableHandle.hh>
2020
#include <G4PVReplica.hh>
2121
#include <G4ReplicaNavigation.hh>
22+
#include <G4StepStatus.hh>
2223

2324
#include <G4HepEmState.hh>
2425
#include <G4HepEmData.hh>
@@ -351,6 +352,17 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs
351352
&fScoringObjects->fPostG4NavigationHistory);
352353
}
353354

355+
// Get step status
356+
// NOTE: Currently, we only check for the geometrical boundary, other statuses are set as unknown for now
357+
G4StepStatus preStepStatus{G4StepStatus::fUndefined};
358+
G4StepStatus postStepStatus{G4StepStatus::fUndefined};
359+
if (preNavState.IsOnBoundary()) {
360+
preStepStatus = G4StepStatus::fGeomBoundary;
361+
}
362+
if (postNavState.IsOnBoundary()) {
363+
postStepStatus = G4StepStatus::fGeomBoundary;
364+
}
365+
354366
// Reconstruct G4Step
355367
switch (hit.fParticleType) {
356368
case 0:
@@ -364,7 +376,7 @@ void AdePTGeant4Integration::ProcessGPUStep(GPUHit const &hit, bool const callUs
364376
break;
365377
}
366378
FillG4Step(&hit, fScoringObjects->fG4Step, *fScoringObjects->fPreG4TouchableHistoryHandle,
367-
*fScoringObjects->fPostG4TouchableHistoryHandle);
379+
*fScoringObjects->fPostG4TouchableHistoryHandle, preStepStatus, postStepStatus);
368380

369381
// Call SD code
370382
G4VSensitiveDetector *aSensitiveDetector =
@@ -445,7 +457,8 @@ void AdePTGeant4Integration::FillG4NavigationHistory(vecgeom::NavigationState aN
445457

446458
void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step,
447459
G4TouchableHandle &aPreG4TouchableHandle,
448-
G4TouchableHandle &aPostG4TouchableHandle) const
460+
G4TouchableHandle &aPostG4TouchableHandle, G4StepStatus aPreStepStatus,
461+
G4StepStatus aPostStepStatus) const
449462
{
450463
const G4ThreeVector aPostStepPointMomentumDirection(aGPUHit->fPostStepPoint.fMomentumDirection.x(),
451464
aGPUHit->fPostStepPoint.fMomentumDirection.y(),
@@ -519,7 +532,7 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step,
519532
aPreStepPoint->SetPolarization(G4ThreeVector(aGPUHit->fPreStepPoint.fPolarization.x(),
520533
aGPUHit->fPreStepPoint.fPolarization.y(),
521534
aGPUHit->fPreStepPoint.fPolarization.z())); // Real data
522-
// aPreStepPoint->SetStepStatus(G4StepStatus::fUndefined); // Missing data
535+
aPreStepPoint->SetStepStatus(aPreStepStatus); // Missing data
523536
// aPreStepPoint->SetProcessDefinedStep(nullptr); // Missing data
524537
// aPreStepPoint->SetMass(0); // Missing data
525538
aPreStepPoint->SetCharge(aGPUHit->fPreStepPoint.fCharge); // Real data
@@ -544,7 +557,7 @@ void AdePTGeant4Integration::FillG4Step(GPUHit const *aGPUHit, G4Step *aG4Step,
544557
// aPostStepPoint->SetSensitiveDetector(nullptr); // Missing data
545558
// aPostStepPoint->SetSafety(0); // Missing data
546559
aPostStepPoint->SetPolarization(aPostStepPointPolarization); // Real data
547-
// aPostStepPoint->SetStepStatus(G4StepStatus::fUndefined); // Missing data
560+
aPostStepPoint->SetStepStatus(aPostStepStatus); // Missing data
548561
// aPostStepPoint->SetProcessDefinedStep(nullptr); // Missing data
549562
// aPostStepPoint->SetMass(0); // Missing data
550563
aPostStepPoint->SetCharge(aGPUHit->fPostStepPoint.fCharge); // Real data

0 commit comments

Comments
 (0)