fix(g4app): record initial optical photon steps with null pre-step process#408
Merged
Conversation
…ocess Geant4 can report a null `GetProcessDefinedStep()` on the pre-step point, notably for the first optical-photon step. `SteppingAction` previously treated that as a reason to return early, which skipped recording the initial Geant4 photon point even though the process value was not used afterward. Remove that early return so the Geant4-side `record.npy` output preserves the initial optical-photon step and stays aligned with the Opticks-side record. Update `optiphy/ana/compare_ab.py` to compare the A/B event records directly instead of compensating for the previous one-step offset.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Geant4 optical-photon step recording so that the initial photon step is not skipped when GetProcessDefinedStep() is null on the pre-step point, keeping Geant4 record.npy aligned with the Opticks record. It also updates the analysis script to compare A/B records directly now that the one-step offset is no longer expected.
Changes:
- Remove early-return logic in
SteppingActionthat skipped recording when pre-stepGetProcessDefinedStep()is null. - Update
optiphy/ana/compare_ab.pyto comparerecord.npyarrays without applying a one-step alignment slice.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/g4app.h | Ensures the initial optical-photon step is recorded even when the pre-step process is null. |
| optiphy/ana/compare_ab.py | Compares A/B event records directly (no longer compensating for a one-step shift). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Geant4 can report a null
GetProcessDefinedStep()on the pre-steppoint, notably for the first optical-photon step.
SteppingActionpreviously treated that as a reason to return early, which skipped
recording the initial Geant4 photon point even though the process value
was not used afterward.
Remove that early return so the Geant4-side
record.npyoutputpreserves the initial optical-photon step and stays aligned with the
Opticks-side record.
Update
optiphy/ana/compare_ab.pyto compare the A/B event recordsdirectly instead of compensating for the previous one-step offset.