How to delete trajectory in trackingaction?

Hi all,
I’ve try to remove some unused trajectory in TrackingAction::PostUserTrackingAction,

void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
G4VTrajectory * traj = fpTrackingManager->GimmeTrajectory();
delete traj;

but it cause delete traj twice after PostUserTrackingAction core dump,
so how can I remove a trajectory of a track or just remove all info. of a trajectory?

Don’t. Let Geant4 take care of it.

I want to save the trajectory only if they hit SD, how could I do?

If you want to save (that is, make a copy of) the trajectory, you can certainly do that in your SD. But don’t delete the pointer to the original trajectory object, because that object is owned by the Geant4 memory managers.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.