New method G4Track::SetTrackLength()

Hello, would it be possible to introduce such a setter method? Possible utilization can be imagined when the track enter certain volume of interest its length could be easily reset, and start being accumulated again from zero.


void G4Track::SetTrackLength(G4double val) { fTrackLength=val; }
1 Like


G4Track is a kernel class, if user code will change step length, Geant4 tracking will be broken and results will be wrong.


Thank you for fast reply. Well… I don’t want to change the step length but only the track length, which seems to be accumulation of steps length from the beginning when the track is created. Am I right?
Maybe I’m not aware in which crucial kernel code the G4Track::fTrackLength is being used… is it?

That’s correct.

If you change the track length, then (a) production cuts may not mean what you think they mean; (b) you can’t compute energy loss rate or range correctly. You’re changing the meaningful physics output.

If you want to collect extra information about a track, you could make use of G4VUserTrackInformation.

1 Like

@mkelsey thank you for this hint! This is very nice feature that I needed…