Exercises and Solutions - Day 4 (May 22nd)

Exercises: Main page

Exercises and solutions - Part III

The solutions are indicated in red.

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:

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