Inclusion of Particle spectra in PrimaryGenerator Action class

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: 11.3.2
Operating System: Ubuntu 22.04
Compiler/Version: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
CMake Version: 3.22.1

I have a file that contains Energy and Count information for an electron Spectrum. I want my particle gun to to take this file as inpute spectra and generate the particle according to the file. At the end, I want to recover this spectrum after it falls onto the defined geometry, with the material and physics list.

Can anyone suggest how to do that? Please let me know if there are any examples available in Geant4 for this exercise. If you find anything releated to this, please reply


Hi Aman

Have a look at the General Particle Source: Geant4 General Particle Source — Book For Application Developers 11.4 documentation. An example of its use is: examples/extended/eventgenerator/exgps.

For recording spectra, perhaps have a look at examples/basic/B5?

John

Thanks for the idea. Will look into this.