| Message: Re: Final step information for parent particle | Not Logged In (login) |
|
Hi Cristian,
Yes, the tip: http://geant4.slac.stanford.edu/Tips/event/1.html is almost exactly what you want. Instead of attaching a TrackInformation to every track in PreUserTrackingAction, you can attach one only when the particle is a pion decaying in flight. You would do this in UserSteppingAction:
G4Track* theTrack = theStep->GetTrack();
G4StepPoint* pPostPoint = theStep->GetPostStepPoint();
const G4VProcess* pProcess = pPostPoint->GetProcessDefinedStep();
G4String theProcessName = " ";
if (pProcess) theProcessName = pProcess->GetProcessName();
G4Track* theTrack = theStep->GetTrack();
const G4String theParticleName = theTrack->GetDefinition()->GetParticleName();
if(theTrack->GetParentID()==0 && theTrack->GetUserInformation()==0) {
if(theProcessName == "Decay" && theParticleName=="pi+") {
if(theTrack->GetKineticEnergy()>0.){
TrackInformation* anInfo = new TrackInformation(aTrack);
theTrack->SetUserInformation(anInfo);
etc.
> Note that UserSteppingAction() does not get called after the final step > (when the track has been killed); I am not sure I agree with Tom in this. You can have code in SteppingAction which executes when:
// If the particle is the primary pion and it is stopped...
if (theTrack->GetTrackStatus() == fStopAndKill) {
if (theParticleName == "pi+" && theTrack->GetParentID() == 0 ) {
// If the track is finished but the pion did not decay,
// abort the event
if (theProcessName != "Decay" ) {
G4cout << "AbortEvent: track is finished but the pion did not decay" << G4endl;
G4RunManager::GetRunManager()->AbortEvent();
}
}
}
|
| Inline Depth: | Outline Depth: | Add message: |
|
to: |