File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments