How to record particle's deposited energy spectrum for each process

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version:
Operating System:
Compiler/Version:
CMake Version:


Hello everybody,
I have a problem that needs solving.

  • I need to record the deposition energy spectrum of the products in the reaction of protons with target B11 according to each reaction channel in the Si radiation detector. Currently, I have recorded the deposition energy spectrum of each type of particle.
  • For example, I recorded a proton spectrum after the primary proton interacted with the target. But now I want to record the post-interaction proton spectrum separately for each elastic and inelastic reaction, for example. How to score them? My recording method is the same as examples B1 and B4, calculating the energy deposited by the particle in each step when the particle enters the detector, then calculating the total for each event saving it to an NTuple and exporting it to ROOT format.
    Thank you in advance.

Dear @hungbt1908,

in your scoring, you can select for all kind of information. Particle type like you say you already use but also the creator process…

Assuming you have a pointer for a G4Step as fStep, you can try the following

G4Track* fTrack       = fStep->GetTrack();
fTrack->GetCreatorProcess()->GetProcessName()`

see if this gets you closer to what you want.

/Pico

1 Like