I have the following energy spectrum, my question is how can I use this spectrum as a source
see also examples/extended/eventgenerator/particleGun : run2
Thank you all.
Is it also possible to do this with a particle gun?
G4ParticleGun directly. You can write your own PrimaryGeneratorAction with
G4ParticleGun as a data member. Write your own code to throw the energy randomly from the spectrum, and then pass that energy, a random direction, and a particle type into your
G4ParticleGun data member.
Of course, GPS has that functionality, and you can configure it with any spectrum you like via macro commands, so it’s more flexible.