| Message: Re: Final step information for parent particle | Not Logged In (login) |
On Tue, 19 May 2009 10:12:55 GMT, Cristian Bungau wrote:
> The only information I need in my code is to > know if the muons which I detect have been produced by pion decay at > rest or in flight. That's why I mentioned I had to access the > information on parent energy or momentum. OK, The kinetic energy of a G4Track is available from track->GetKineticEnergy(). This has the usual floating-point disease that comparisons to 0.0 may not work. Perhaps you can use track->IsBelowThreshold(). Perhaps you can use track->GetTrackStatus() -- you'll have to do this in UserSteppingAction(), checking for fStopButAlive. Note that UserSteppingAction() does not get called after the final step (when the track has been killed); PostUserTrackingAction() does (but status will be fStopAndKill there, having forgotten whether it was at rest or not). I suspect track->IsBelowThreshold() is the best, but I have never used it.
> If there is no simple way of doing this, I guess the tip in > http://geant4.slac.stanford.edu/Tips/event/1.html should probably work? Adding a G4VUserTrackInformation is neither needed nor appropriate. In particular, to access it you need a G4Track pointer, and that requires the vector<G4Track*> I mentioned before. Given that vector, you can get the kinetic energy directly from the G4Track, or the status.
> Or using the GimmeSecondaries() method to pass the information from > parent track to the daughter particles would be best ? Your code would need to be clairvoyant to do that, because you must call that while tracking the parent (in PostUserTrackingAction). You cannot just save the last track's status, as the order of tracks being tracked has no useful ordering (other than parents are tracked before their secondaries). So you need a vector, and must search the vector for the correct parent track. If your events have many tracks (> 30, say), perhaps use a std::map<G4int,G4Track*> mapping track ID to track pointer, avoiding the linear search of a large vector. NOTE: don't use G4Track in the vector or map, as you may not be able to easily distinguish an unknown track ID (default G4Track) from a stopped track; a null pointer is easy to detect. I suggest setting up the vector<G4Track*> in PostUserTrackingAction(), clearing it in BeginOfEventAction() (and deleting the tracks). When your PreUserTrackingAction() finds it has a muon, use track->GetParentID() to get the ID of the parent, and search the vector (or map) for the track with trk->GetTrackID() equal to it, then call trk->GetKineticEnergy() and you'll have the kinetic energy of the parent. Or use trk->IsBelowThreshold().
|
| Inline Depth: | Outline Depth: | Add message: |
|
to: |