#include <G4DecayKineticTracks.hh>
Public Member Functions | |
G4DecayKineticTracks (G4KineticTrackVector *tracks=0) | |
void | Decay (G4KineticTrackVector *tracks) const |
Definition at line 38 of file G4DecayKineticTracks.hh.
G4DecayKineticTracks::G4DecayKineticTracks | ( | G4KineticTrackVector * | tracks = 0 |
) |
Definition at line 39 of file G4DecayKineticTracks.cc.
References Decay().
00039 { 00040 if (tracks) Decay(tracks); 00041 }
void G4DecayKineticTracks::Decay | ( | G4KineticTrackVector * | tracks | ) | const |
Definition at line 43 of file G4DecayKineticTracks.cc.
Referenced by G4DecayKineticTracks().
00043 { 00044 if (!tracks) return; 00045 00046 G4KineticTrackVector* daughters = 0; 00047 for (size_t i=0; i<tracks->size(); ++i) { 00048 G4KineticTrack* track = (*tracks)[i]; 00049 if (!track) continue; 00050 00051 // Select decay of current track, put daughters at end of vector 00052 daughters = track->GetDefinition()->IsShortLived() ? track->Decay() : 0; 00053 if (daughters) { 00054 tracks->insert(tracks->end(), daughters->begin(), daughters->end()); 00055 delete track; // Remove parent track 00056 delete daughters; 00057 (*tracks)[i] = NULL; // Flag parent's slot for removal 00058 } 00059 } 00060 00061 // Find and remove null pointers created by decays above 00062 for (int j=tracks->size()-1; j>=0; --j) { 00063 if (NULL == (*tracks)[j]) tracks->erase(tracks->begin()+j); 00064 } 00065 }