X-ray spectrum simulation

_Geant4 Version:_v11.1.1
_Operating System:_Ubuntu 22.04.3 LTS
_Compiler/Version:_gcc 11.4.0
_CMake Version:_3.22.1


I am trying to simulate the x-ray spectrum of my xr generator and I am struggling at the ActionInitialization part. I created my electron source (MyPrimaryGenerator) and now I want to set a detection volume at 1 meter from the xr source and score the no. of photons of energy E_g (in a particular energy bin). I want to have like 150 energy bins.
My problem is I don’t know exactly what detector class to use and how to score the number of photons of a particular energy group (I think I have to count the photons that have a specific energy when they reach my detector?).

Any suggestion would help me a lot!