Why the codes did not work?

the codes below were used to kill track,
void fpSteppingAction::UserSteppingAction(const G4Step* step)

but it did not work, because the results were produced:

if it worked, no results would produce.

_Geant4 Version:_G4_11.1
_Operating System:_Ubuntu20.04
_Compiler/Version:_GCC 9.4.0
_CMake Version:_3.16

#include “G4TrackStatus.hh”

Hi @siyuan1979

check if it works for you,

if ( step->GetTrack()->GetParentID() == 0)
{return step->GetTrack()->SetTrackStatus(fStopAndKill);}

You can further modify for each particle by calling method GetParticleName();