Track the processes that happen to a single photon


I am currently working with the Geant4 Example OpNovice2 and i would really like to get a Histogram from Geant4 that shows me the Number of Processes a Photon has gone trough. I want in particular Track the number of Rayleigh Scattering processes one Photon has gone trough and make a histo like: number of Processes on the x axis and then how many Photons has gone trough like 10 times rayleigh Scattering and 20 times etc one the y axis.
I could get the average number of processes photons make and whats the max. with given physical properties etc.

I am already tracking the processes but its only the average for all photons. The tracking verbose also shows a good listing of the Steps and Processes a Photon has made, but how can i get this into a histo.

I would really appreciate some hints to get this working :slight_smile:

One option is to have a counter in your SteppingAction, counting the number of Rayleigh interactions for a given track. In TrackingAction, at the end of the track, update the histogram. If I understand your question correctly, basically in OpNovice2 the histos are updated each step, whereas you want to update for each track.