Fix/multiphoton event without output - #771
Closed
MateuszBala wants to merge 2 commits into
Closed
Conversation
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.
fix(multiphoton): produce a detector response for every event
Branch:
fix/multiphoton-event-without-output- based ondevelop(01658459)Commits: 2 -
fix(multiphoton): skip events without primary vertex quietly,fix(multiphoton): always run the digitizer at end of eventFiles:
source/digits_hits/src/GateMultiPhotonAnalysis.ccDepends on: nothing
Two defects in the same branch of
GateMultiPhotonAnalysis::RecordEndOfEvent, one deciding whenan event is reported as an anomaly, the other deciding what happens to digitisation on that path.
Defect 1 - a false warning for the event that closes a run
Every simulation using
multianalysisended with oneG4Exceptionwarning about a missingtrajectory container:
Always one event per run, always with
hasProcessableHits=false. The event number matches thecounters written into the ROOT file exactly (
total_nb_primaries = 99142,latest_event_ID = 99142): it is the last event of the run.GateSourceMgr::PrepareNextEventgenerates no vertex once the time limit is exceeded ("m_time >m_timeLimit. No vertex generated"). Geant4 still processes the event to the end, but there is not
a single track in it - and
G4Event::GetTrajectoryContainer()returns a container only once thefirst trajectory has been stored. Hence the null pointer. Under the
strictpolicy the same eventwould have aborted an otherwise correct simulation.
Fix: at the beginning of
RecordEndOfEvent, an event withGetNumberOfPrimaryVertex() == 0ends quietly - no
G4Exception, no increment of the anomaly counters. The condition is strictlyequivalent to the description of the case: no primary vertex means no track, hence neither hits
nor a trajectory container. The warning and the counters are left untouched for the case that
really is an anomaly - an event with hits but without trajectories.
Defect 2 - the digitizer was skipped for the whole event
RecordEndOfEventreturned early when the event had no trajectory container, and the call to thedigitizer stood at the end of the method. An event taking that path produced no singles and no
coincidences at all - the hits were there, but nothing turned them into a detector response.
GateAnalysisplaces the same call outside itsif (!trajectoryContainer)block, so it digitisesregardless.
Fix: a scope guard in an anonymous namespace,
ScopedDigitizerRunner, whose destructor callsRunDigitizersIfNeeded(). It is created once inRecordEndOfEventand the explicit call at theend of the method was removed, so the digitizer runs no matter which way the analysis of the event
ends. Writing the call before each
returnwas rejected: there are three of them today and theremay be a fourth tomorrow.
The guard is created after the tracking-mode check, not before it: an unsupported tracking mode
raises a
FatalExceptionwhose message says explicitly that further processing, digitisationincluded, is skipped. That path is left as it was.
Verification
Defect 1 - the same simulation on both builds:
MissingTrajectoryContainerwarningsMissing trajectory container in ...The data is unchanged: 317 154 hits in
back-to-back-only-detectorbefore and after, with thecolumns
eventID,trackID,parentID,nPhantomCompton,nCrystalCompton,nInteractions,edepandtimeidentical row by row, andtotal_nb_primariesandlatest_event_IDboth still99 142.
Defect 2 - the situation does not arise on its own (GATE stores trajectories for all tracks),
so it was produced deliberately: two binaries differing only in this fix, both with
trajectoryContainer = nullptr;inserted right after the container is read, running the sameshort PET simulation with Singles enabled:
No regression in ordinary running:
positronium-source-mixed-prompt-with-phantomgives the same305 207 hits and 216 312 singles as before, and the whole test suite passes.
Scope
One file, one method of the multi-photon analysis module.
GateAnalysisandGateFastAnalysisareuntouched; the change makes
multianalysisbehave likeGateAnalysison both paths.Details:
https://github.com/MateuszBala/opengate-gate-multiphoton-analysis-verification/blob/main/docs/bugs/bug-14-false-warning-for-empty-event.md
https://github.com/MateuszBala/opengate-gate-multiphoton-analysis-verification/blob/main/docs/bugs/bug-05-digitizer-skipped-without-trajectory-container.md