Skip to content

Commit 62336b6

Browse files
committed
fix: mv user end calls before reason use in Geant4ParticleHandler
1 parent 5af01ad commit 62336b6

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

DDG4/src/Geant4ParticleHandler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ void Geant4ParticleHandler::end(const G4Track* track) {
344344
ph->vey = pos.y();
345345
ph->vez = pos.z();
346346

347+
// Allow user handlers to repair m_currTrack (e.g. restore stale fields for
348+
// GPU-offloaded tracks) before any bookkeeping fields are read. Must come
349+
// after pex/vex are set so the final state is visible to handlers, and
350+
// before track_reason is copied so the backscatter logic uses correct bits.
351+
for( auto* handler : this->m_userHandlers )
352+
handler->end(track, m_currTrack);
353+
track_reason = m_currTrack.reason;
354+
347355
// Set the simulator status bits
348356
PropertyMask simStatus(m_currTrack.status);
349357

@@ -382,10 +390,6 @@ void Geant4ParticleHandler::end(const G4Track* track) {
382390
}
383391
}
384392

385-
/// Final update of the particle using the user handler
386-
for( auto* handler : this->m_userHandlers )
387-
handler->end(track, m_currTrack);
388-
389393
//
390394
// These are candidate tracks with a probability to be stored due to their properties:
391395
// - primary particle

0 commit comments

Comments
 (0)