Problem 2097 - crashes in G4Track functions using fpStep when called from PreUserTrackingAction
Summary: crashes in G4Track functions using fpStep when called from PreUserTrackingAction
Status: RESOLVED WONTFIX
Alias: None
Product: Geant4
Classification: Unclassified
Component: track (show other problems)
Version: 10.4
Hardware: All All
: P4 minor
Assignee: kurasige
URL:
Depends on:
Blocks:
 
Reported: 2018-10-29 16:39 CET by Krzysztof Genser
Modified: 2018-10-30 15:59 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Krzysztof Genser 2018-10-29 16:39:42 CET
The fpstep of G4Track is 0 when PreUserTrackingAction is called
causing crashes in 
G4Track::GetMaterialCutsCouple()
G4Track::GetNextMaterialCutsCouple()
G4Track::GetMaterial()
G4Track::GetNextMaterial()
The information seems available through the touchable though.
Comment 1 kurasige 2018-10-30 01:00:32 CET
These methods of G4Track are provided to get information of the material through PostStepPoint (see G4Track.icc#L152). The method of PreUserTrackingAction of G4UserTrackingAction is invoked just before the first stepping of the track (see G4TrackingManager.cc#L93). So, the PostStepPoint has no information yet. In short, it is not a bug but the limitation of tracking algorithm in Geant4. 
As for the touchable, situation is different between primary tracks and secondary tracks. The touchable of a primary track is set in during the first step; i.e. you can’t access the touchable in PreUserTrackingAction. In most cases, the touchable of a secondary track is set by the process which creates the secondary track; you may access the touchable in PreUserTrackingAction.
Comment 2 Krzysztof Genser 2018-10-30 15:59:11 CET
Those are good reasons for the limitations, however the current code
segfaults when used, as there is no check for fpStep being null,
while the check is done for fpTouchable avoiding a crash.
May be one should add such checks for fpStep before using it to access PostStepPoint.