How to reflect an electron?

Hi,

i have a simple geometry with a gold absorber in a world volume. I let electrons impinge on the gold and record all electrons (also secondarys) which leave the world volume under a certain angle.
Now, all electrons which would leave the world volume outside of this angle should be back reflected to the absorber. Till they either absorbed or within the angle.
I’ve tried to do this in SteppingAction. I check whether the next volume is outside the world and use:
aTrack->SetMomentumDirection(G4ThreeVector(-x, y, z));

Nevertheless, Geant4 seems to have a problem when doing this. The particle seems to be vanishing without back reflection. I’ve tried the same when the particle goes from the gold absorber to the world volume but then the particle seems to be stuck until Geant4 finally kills it.

It seems that i can’t do this between volume/material transitions. What would be the appropiate way to realize this?

Thanks for hints!
Best Wishes,
Marco

Addendum:
I modified the code to make sure, i switch momentum direction on a step within the world volume and not between two different volumes but it still don’t work.

Here is what i did in User Stepping Action to reflect the electron:

void SteppingAction::UserSteppingAction(const G4Step* aStep){
//Reflect all particles outside of acceptance angle 
    G4Track* aTrack = aStep->GetTrack();
    G4int TrackID = aTrack->GetTrackID();
    G4int ParentID = aTrack->GetParentID();
    G4double x,y,z,r,theta;
    x=(aTrack->GetMomentumDirection()).x();
    y=(aTrack->GetMomentumDirection()).y();
    z=(aTrack->GetMomentumDirection()).z();
    r=(std::sqrt(z*z+y*y+x*x)); //useless, it's normalized
    theta=(std::acos(x/r));
    if((aTrack->GetNextVolume()) != 0){  
    G4cout << "aTrack->GetNextVolume()->GetName(): "<<(aTrack->GetNextVolume()->GetName())<< G4endl;}

    if((aTrack->GetNextVolume() != 0 && aTrack->GetDefinition()->GetPDGCharge()!=0)){
        if((aTrack->GetNextMaterial()->GetName())=="G4_Galactic" && (aTrack->GetMaterial()->GetName())=="G4_Galactic"){
            G4cout << "Youve made it into if" << G4endl;
            G4cout << "Theta:" << theta/3.1415927*180 << " x:" << x << " y:" <<y << " z:" <<z << " r:" << r << G4endl;
            G4cout << "Position: "<< aStep->GetPostStepPoint()->GetPosition() << G4endl;
            if(theta<=147.1*deg && theta>90*deg){
	        G4cout << "Acos larger than 32.9. Trying to reflect particle."<< " x:" << x << " y:" <<y << " z:" <<z << " r:" << r << G4endl;
	        aTrack->SetMomentumDirection(G4ThreeVector(-x, y, z));
	        G4cout << "New Values: "<< " x:" << (aTrack->GetMomentumDirection()).x() << " y:" <<(aTrack->GetMomentumDirection()).y() << " z:" <<(aTrack->GetMomentumDirection()).z() << " r:" << r << G4endl;
	        }	
        return;
        }
    }

Here is the output of one of the events:

...
G4WT0 > aTrack->GetNextVolume()->GetName(): Absorber
G4WT0 > aTrack->GetNextVolume()->GetName(): Absorber
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > Youve made it into if
G4WT0 > Theta:127.77 x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > Position: (-1.06125,0.078352,0.0127839)
G4WT0 > Acos larger than 32.9. Trying to reflect particle. x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > New Values:  x:0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > Youve made it into if
G4WT0 > Theta:127.77 x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > Position: (-1,0.156363,0.0255465)
G4WT0 > Acos larger than 32.9. Trying to reflect particle. x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > New Values:  x:0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > aTrack->GetNextVolume()->GetName(): Absorber
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > Youve made it into if
G4WT0 > Theta:127.77 x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > Position: (-1.06125,0.234374,0.0383092)
G4WT0 > Acos larger than 32.9. Trying to reflect particle. x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > New Values:  x:0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > Youve made it into if
G4WT0 > Theta:127.77 x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > Position: (-1,0.312385,0.0510718)
G4WT0 > Acos larger than 32.9. Trying to reflect particle. x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > New Values:  x:0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > aTrack->GetNextVolume()->GetName(): Absorber
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > aTrack->GetNextVolume()->GetName(): World
G4WT0 > Youve made it into if
G4WT0 > Theta:127.77 x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > Position: (-1.06125,0.390396,0.0638344)
G4WT0 > Acos larger than 32.9. Trying to reflect particle. x:-0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > New Values:  x:0.612488 y:0.780109 z:0.127626 r:1
G4WT0 > aTrack->GetNextVolume()->GetName(): World
...

Even it seems to make several steps also to the absorber, it always comes out with the same angle/momentum.

Appearently this is the wrong way to modify the momentum direction. As described here: