File of energy spectra for GPS

Hello,
I am using Geant4-v11.0.0 on Ubuntu.
Is it possible that the General Particle Source is a file that contains the energy and the amount of particles with that energy? The file contains 2 columns, column 1 is the energy and column 2 is the amount of particles with that energy.
Thank you for your time and help.

2 Likes

I don’t think that is possible (at least using GPS, you probably need to use the particle gun and define your own primary generation class), but one way could be to loop over the energies using the /control/foreach command with constant number of input particles (larger than the number expected in the entire list of energies) and then normalising your output with the actual number of input particles.

1 Like

Thanks for your response. I’ll try to do that and post if I succeed!

Hi!

I solved the file issue using a macro with the gps commands and various fonts. I’ll put below a small part of my macro, the configuration of the fonts is repeated, changing only the values. The amount of particles is just an example, the values of my simulation are different. For now I have 113 fonts.

**************** SOURCE 1 ****************

/gps/particle proton

/gps/number 5

/gps/energy 400.2 MeV

/gps/pos/type Volume

/gps/pos/shape Sphere

/gps/pos/radius 0.5 cm

Beam output position

/gps/position -5 0 0 cm

beam direction

/gps/direction 0 0 90 deg

**************** SOURCE 2 ****************

/gps/source/add 1.

/gps/particle proton

/gps/number 4

/gps/energy 330.52 MeV

/gps/pos/type Volume

/gps/pos/shape Sphere

/gps/pos/radius 0.5 cm

Beam output position

/gps/position -4 0 0 cm

beam direction

/gps/direction 0 10 90 deg

Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.