Problem 2422

Summary: PreUserTrackingAction called more than once for the same particle (primary or not) when the option "TrackSecondariesFirst" is set for the optical processes
Product: Geant4 Reporter: bernardo
Component: trackingAssignee: Shogo Okada <shogo.okada>
Status: RESOLVED DUPLICATE    
Severity: normal CC: asai
Priority: P4    
Version: 10.7   
Hardware: All   
OS: All   

Description bernardo 2021-09-15 16:21:54 CEST
I first found this in my code so decided to check in  the LXe extended example.
Inserting in LXeTrackingAction::PreUserTrackingAction the line 

if (aTrack->GetUserInformation())
   G4cout << aTrack->GetTrackID() << G4endl;


and running with the cerenkov.mac macro, you will see the track id being written.
However if the option SetTrackSecondariesFirst is set to false in the LXe.cc : 

opticalParams->SetCerenkovTrackSecondariesFirst(false);

the above output will go silent.

Given that in this specific example (as I am doing in my code) a new object of the 
UserTrackInformation class is created for each call to PreUserTrackingAction, this results in a potential memory leak, because (I think...) only the last created UserTrackInformation object is deleted when the associated G4Track object is destroyed. In fact I could check that the memory consumption was increasing in the case with  SetTrackSecondariesFirts true.

Bernardo Tomé
Comment 1 Takashi.Sasaki 2021-09-16 02:18:49 CEST
Shogo, please investigate this.
Comment 2 asai 2021-12-14 22:37:24 CET

*** This problem has been marked as a duplicate of problem 2425 ***