Writing and Reading A User Defined Source File

Hi Experts,

I am trying to write an application where I irradiate a target with electrons to generate Bremsstrahlung photons and use these resulting photons as a source to irradiate a sample. Basically I would prefer to have the two steps as separate simulations. In order to do so I will like to generate an ASCII file which can write the Bremsstrahlung photon source into then in the second simulation read and sample the data from this ASCII file.

I saw some commands in the G4GeneralParticleSource (GPS) that seem to indicate that this might be possible using the User Defined source type. I believe I will have to write the source myself but would like to know the format of the structure the I need to pass to /gps/hist/file. It seems it an energy and bin magnitude pair. I don’t know if a third column of angle can be added (also if so, how is this angle evaluated). I have looked at the user guide and its helpful but I will appreciate if someone can refer me to an example in the documentation where something similar is done.