Generating real xray beam

Dear Geant4 experts,

Hello,
I’m making a real X-ray spectrum.
For now, I’m just using a “W” target and a mono-energy electron beam to describe the X-ray.
But it is a highly simplified X-ray, and I would like to simulate an X-ray beam as it is used in practice.
And actually, I don’t have any knowledge or technique to make a real, accurate X-ray machine using Geant4.
But, I think it is very usual to use well-processed X-rays.
I tried to find if there are any kind of examples, but I haven’t found yet.
My final purpose is not making a sophisticated X-ray, but just wanting to sample X-rays in a specific energy range(low energy).
Could you please recommend what would be the best course of action in this case?
Thank you so much in advance.
Have a nice day!

Best regards,
Hyeonseok.

Are you interested in the beam formation or just in the resulting spectrum? You can make an x-ray tube, see this post. But it will be inefficient in terms of computational time since x-ray tubs are not very efficient per electron (they compensate with a lot of beam current).

If you want to use the x-ray spectrum for some other purpose you could just generate the spectrum, also in that link, and then use the particle gun to emit photons sampled from that energy distribution in a particular direction. See this.

Thanks for your reply.

I read your link, but I think I don’t fully understand, and the codes are not available now.
For now, I just made a simple simulation(100keV e- and W target) and sampled the energy of X-rays to a CSV file. And I used that CSV file for the input of another Geant4 simulation.
So, is there any way to generate only the spectrum, not a real beam?
Always thank you for your help.
Have a wonderful weekend.

I am not sure what you mean. Presumably you want the spectrum to interrogate some other object of interest? Since you have already saved the x-ray spectrum you can use it as an input to the gps i.e. you’d have something like this somewhere in your macro:

/gps/ene/type Arb
/gps/ene/diffspec 1
/gps/hist/type arb
/gps/hist/file macro_files/YourXRayEnergySpectrum.dat
/gps/hist/inter Lin

Where YourXRaySpectrum.dat would be a file with one column on energies in MeV and the next column the relative intensities. There are a lot of ways to do, you can use a lot of the test macros here as a guide. For example: test19, test20, test21, test22, test26, etc.