Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/opengate_core/opengate_lib/GatePhaseSpaceActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ void GatePhaseSpaceActor::SteppingAction(G4Step *step) {

auto &l = fThreadLocalData.Get();

// Check if this SteppingAction was triggered via the sensitive detector
// attached to the top volume, i.e. the "attached_to" volume
// if it was triggered by a daughter volume, this is not truely a step

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pay attention to daughter volume with same boundary than mother volume when the particle enters.
Or if the particle is created inside a daughter volume like in test058 with iec spheres, the mother volume is the world

// at the outer surface, but rather an irrelevant (for the purpose of this
// actor) internal surface crossing
if (!IsStepInTopAttachedVolume(step))
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we manage the others policy of the storing: ‘exiting’, ‘first’ or ‘all’

// Particle enters the volume if the pre step is at the volume boundary
const bool entering =
step->GetPreStepPoint()->GetStepStatus() == fGeomBoundary;
Expand Down
22 changes: 22 additions & 0 deletions core/opengate_core/opengate_lib/GateVActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ bool GateVActor::IsStepEnteringVolume(
return false;
}

bool GateVActor::IsStepInTopAttachedVolume(const G4Step *step) const {
const auto *touchable = step->GetPreStepPoint()->GetTouchable();
if (touchable == nullptr)
return false;

const auto history_depth = touchable->GetHistoryDepth();
int attached_volume_depth = -1;
for (int i = 0; i <= history_depth; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you do a for loop instead of looking for the name of touchable->GetVolume(0)?

const auto *volume = touchable->GetVolume(i);
if (volume == nullptr)
continue;
const auto *logical_volume = volume->GetLogicalVolume();
if (logical_volume != nullptr &&
logical_volume->GetName() == fAttachedToVolumeName) {
attached_volume_depth = i;
break;
}
}

return attached_volume_depth == 0;
}

bool GateVActor::IsStepExitingAttachedVolume(const G4Step *step) const {
if (fAttachedToVolumeMotherName == "None") {
Fatal("Cannot use IsStepExitingAttachedVolume when "
Expand Down
2 changes: 2 additions & 0 deletions core/opengate_core/opengate_lib/GateVActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class GateVActor : public G4VPrimitiveScorer {
IsStepEnteringVolume(const G4Step *step,
const std::vector<const G4LogicalVolume *> &volumes);

bool IsStepInTopAttachedVolume(const G4Step *step) const;

bool IsStepExitingAttachedVolume(const G4Step *step) const;

inline static std::string fOutputNameRoot = "root_output";
Expand Down
Loading