|Message: Re: Final step information for parent particle||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
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:|