How to kill secondaries(?) without affecting other tracks

im doing some xray simulations and have very weird peaks in the <2keV range, which should be filtered out via my Beryllium window. my thought was that the photons hitting my detector generate free electrons via photo/compton effects and their energy gets detected as well. when i tried killing the tracks via this code:
if(volume==fScoringVolume){
if (step->GetTrack()->GetDefinition() == G4Electron::ElectronDefinition()) {

        step->GetTrack()->SetTrackStatus(fStopAndKill);

}}
my detector only shows the Si-Lines at 1.7keV…
i dont know if i just donw understand how the GetEnergyDeposit works or if it is something else…
this is my complete stepping action code:
#include “stepping.hh”
#include “G4ParticleDefinition.hh”
#include “G4TrackStatus.hh”
#include “G4Track.hh”
#include “G4Material.hh”
MySteppingAction::MySteppingAction(MyEventAction *eventAction)
{
fEventAction=eventAction;

}
MySteppingAction::~MySteppingAction()
{}

void MySteppingAction::UserSteppingAction(const G4Step step)
{
G4Track
track = step->GetTrack();
G4double edep = 0.;
G4double backscatter=0.;
G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
G4String volumeName= volume->GetName();

const construction detectorConstruction = static_cast<const construction>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4LogicalVolume *fScoringVolume =detectorConstruction->GetScoringVolume();

if (volume != fScoringVolume)
{
return;}

// if(volume==fScoringVolume){
// if (step->GetTrack()->GetDefinition() == G4Electron::ElectronDefinition()) {

// step->GetTrack()->SetTrackStatus(fStopAndKill);
// }}

edep = step → GetTotalEnergyDeposit();
fEventAction->AddfEdep(edep); // this adds up the energy deposited , to get the total ammount lost by the photon passing throught the detector

}