Part III - Retrieval of information from tracks, steps and particle classes
Exercise 4-4
Introduce a conditional statement in the ProcessHits method of the sensitive detector, in order that hits are only created, filled and stored in the hits collection for primary electron tracks:
- How can primary particle tracks be distinguished from secondary particle tracks? Primary tracks have a track ID = 1, secondary tracks have an ID > 1. NOTE: Primary tracks of hadrons may "loose" their ID in some inelastic hadronic interactions, since they are considered as secondaries products due to the fact that the interaction partners are indistinguisable. However, particles like electrons do not "loose" their ID.
From the G4Step object "step", one can retrieve the track. And from the track object, the track ID can be obtained:
if(step -> GetTrack() -> GetTrackID() == 1) {
DetectorHit* hit = new DetectorHit();
hit -> SetEnergyDeposit(energyDeposit);
hit -> SetBinCenter(binCenter);
hitsCollection -> insert(hit);
}
Exercise 4-5