I’m trying to record the energy of each particle after it has passed through a volume and the number of particles to see how many secondary particles have been generated.
What method would work best for this?
I’m trying to record the energy of each particle after it has passed through a volume and the number of particles to see how many secondary particles have been generated.
What method would work best for this?
You could create a vacuum volume and then, using step action, check if the pre-step point was outside and the post-step point was inside. Then, you have a particle object which has the properties you need. It is a different story with secondaries, as you must check if a particle was born at every step. It is a time-consuming thing, and maybe it is better to ponder a bit about what could be needed to solve the problem you have in mind.
phirripu has the best idea.
It will depend on what you define “secondaries” to be which will determine how intensive this is. I think the general strategy would be to populate sets or maps for each particle type of interest that you fill when they pass through the volume. Then to just add these values in histograms with the HistoManager at the end of Event Action. Similar histograms for energy.
The activation example might be a good template for some ideas for the flow.
In addition to the answers above, G4MultiFunctionalDetector
and G4VPrimitiveScorer
might be useful. There are various concrete primitive scorers available, together with filters to select only certain types. Both can be extended if they don’t provide the exact scoring needed.
Example B3a shows a reasonable straightforward case.