I am trying to create two particle sources using the GEANT4 gps source. I want each source to produce a single electron per event so that I have two simultaneous electrons in the detector. Currently using the intensity parameter means that there is a 1/2 probability one of the sources will fire twice as opposed to each source once. Any recommendations of how to fix this?
I guess that you would prefer use GPS. But in case …
This configuration can be done with simple G4ParticleGun and C++ code.
See examples/extended/eventgenerator/particleGun: Readme and PrimaryGeneratorAction1
Or even without G4ParticleGun: example userPrimaryGenerator
# Source 1
/gps/particle proton
#
# the incident surface is a disc in the y-z plane at -10 cm
/gps/pos/type Plane
/gps/pos/rot1 0 1 0
/gps/pos/rot2 0 0 1
/gps/pos/shape Circle
/gps/pos/centre -10. 0. 0. cm
/gps/pos/radius 10. cm
#
# angular distribution
/gps/ang/type cos
#
# the proton energy is in gaussian profile centered at 2.5 MeV
/gps/ene/type Gauss
/gps/ene/mono 2.5 MeV
/gps/ene/sigma 0.5 MeV
#
#
# source #2
/gps/source/add 1
#
# this is gamma source
/gps/particle gamma
#
# the incident surface is a square in the x-y plane at 10 cm
/gps/pos/type Plane
/gps/pos/centre 0. 0. 10. cm
/gps/pos/shape Square
/gps/pos/halfx 2 cm
/gps/pos/halfy 2 cm
#
# normal incident
/gps/direction 0 0 -1
#
# mono energy
/gps/energy 1 MeV
#
# both guns will be fired at the same time
/gps/source/multiplevertex true