How to count the number of the interaction particles

Dear all,
I want to make a simulation based on exampleB4a to check how many particles will deposit energy in the calorimeter. For example, if I let a beam of gamma go through a 1 cm length’s calorimeter, I want to know the number of the gamma which happened interaction. Is there any examples? I have no idea for how to handle it. In track, event or step?
Thanks!

My answer is as explicit as possible. I apologize if you already know those informations.

a run is made of several events
an event is made of several tracks
a track is made of several steps

in TrackingAction, you have the control at begin and end of each track. So, it is the natural place to collect informations on the track, to be sent to EventAction.

in example B3, you do not have a TrackingAction class.
you can do the same thing in SteppingAction, at first step of each track.
I would write something like :
if (step->GetTrack()->GetCurrentStepNumber() == 1) { eventAction->sumTrack(); … etc …}

Hi, maire
I tried the condition “GetCurrentStepNumber() == 1”, but the number I get is larger than the number of input particles…If GetCurrentStepNumber() > 1, does that mean the reacted particles ?Screen Shot 2021-04-20 at 7.43.47 PM Screen Shot 2021-04-20 at 7.43.27 PM
These are my code. I just count the number of “www” output from terminal.

did you run 1 event with /tracking/verbose 2 ?


Maybe I know the reason. Secondaries also have step1 right?

Oh, for gamma, I can just count the number of “Abso phot” and “compt”, but for more complex process, that’s not a good idea

Yes. Every track has a step 1.