I am trying to automate the z0 position of photons entering my detector. Normally, the positions for x0, y0, and z0 was specified in the PrimaryGeneratorAction.cc file but I would like to overwrite only that of z0.
I have created a macro papis.mac with the code:
# specified 50keV gamma energies to the direction (0.,0.,zpos)
#
/gun/particle gamma
/gun/energy 50 keV
/gun/position 0 0 {zpos} mm
/run/beamOn 100000
#/control/shell Edep.dat output_{eKin}.dat
However this doesn’t overwrite the value for z0. How can I keep this fixed for each position of z0 from the macro while randomizing x0 and y0 from the main PrimaryGenerator.cc file? I’d appreciate any help please.
I think that the code you posted will be executed for every single event. That means, the changes/settings that you apply in the macro will later be overwritten - especially the z-component of the direction.