Message: Setting Track Info for secondaries Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Setting Track Info for secondaries  

Forum: Event and Track Management
Date: 26 Nov, 2013
From: Nigel Hawkes <Nigel Hawkes>

Hello Geant4 experts,

I need to transfer scoring information from parent tracks to their secondaries. As this information depends on where the parent is at the time, I need to do this at each step (e.g. in G4VSensitiveDetector::ProcessHits() or in G4UserSteppingAction::SteppingAction()) and not just when the parent track ends.

I thought that the recently-added function G4Step::GetSecondaryInCurrentStep() would be just what I needed, but there are problems.

This function returns a vector of pointers to const G4Track, so it's not easy to add an information object pointer via G4Track::SetUserInformation(). I'd be interested to know why the design was done this way, as the self-same track pointers are available in non-const form via the likes of G4Step::GetSecondary(), if you only knew which ones relate to the current step.

So, following a suggestion from Tom Roberts in his reply "Re: Passing info to tracks" (12 Sep 2009), I set up a std::map to relate tracks to information objects. My first attempt used the track ID as key, but unfortunately this didn't work: the IDs in the tracks provided by GetSecondaryInCurrentStep() were all zero (when making the call from within ProcessHits(), at any rate).

So in my next attempt I changed the map to use a pointer to const G4Track as key instead. This largely worked but with occasional surprises. It occurred to me that tracks are deleted during the processing of an event, and if an area of memory got re-used for a new track, the new track would magically acquire the information object from the old one. To get round this I used G4UserTrackingAction::PostUserTrackingAction() to erase the track's entry in the map when the track ended. This now seems to be working, although there will still be trouble if a track is moved from one memory location to another (hopefully the kernel never does this).

I'd be very grateful for your expert thoughts on:

(1) Do people in fact just cast away const in order to force SetUserInformation() to work? (It would save a lot of trouble!)

(2) At what point do the many members of G4Track become valid? It would be useful if the ID were one of the early ones.

(3) Is there a way for the user to intervene at the moment a secondary is created, in order to (for example) implement routine copying of context-dependent information from parent to secondary?

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Feedback: Re: Setting Track Info for secondaries   (Gumplinger Peter - 26 Nov, 2013)
(_ None: Re: Setting Track Info for secondaries   (Hisaya Kurashige - 26 Nov, 2013)
(_ Ok: Re: Setting Track Info for secondaries   (Nigel Hawkes - 27 Nov, 2013)
(_ Feedback: Re: Setting Track Info for secondaries   (Gumplinger Peter - 27 Nov, 2013)
(_ Feedback: Re: Setting Track Info for secondaries   (Nigel Hawkes - 28 Nov, 2013)
 Add Message Add Message
to: "Setting Track Info for secondaries "

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]