Histogram input file vs. command

Dear experts,
I seem to not get how to successfully use file based input for gps energy biasing, similar to what was discussed here: https://geant4-forum.web.cern.ch/t/can-someone-explain-how-to-use-a-histogram-energy-spectrum-as-a-source-input-for-gps/

Common definition of a simple gps:

/gps/particle gamma
/gps/ene/type Lin
/gps/ene/min 0 keV
/gps/ene/max 220 keV
/gps/ene/gradient 0
/gps/ene/intercept 1

I would expect to be the following two settings to be identical in outcome:


/gps/hist/type biase
/gps/hist/point 0.   0.
/gps/hist/point 0.25 1.
/gps/hist/point 0.5  2.
/gps/hist/point 0.75 1.
/gps/hist/point 1. 0.1
/gps/hist/inter Lin


/gps/hist/type biase
/gps/hist/file file.g4spec
/gps/hist/inter Lin

where the content of file.g4spec is identical to the points in A.

0.   0.
0.25 1.
0.5  2.
0.75 1.
1. 0.1

However, only the first solution seems to work correctly: the generated energy spectrum of A reflects the steps in the histogram, but B gives a flat line (linear with gradient 0) as if there was no histogram/biase at all.

I know I could add /gps/hist/point to all lines in the histogram and call the file as a macro instead. Reading the documentation, this seems to be a workaround. What is the correct way to implement a file based histogram in this case?

edit: I could add that without energy biasing the histogram from file (with energy scale in MeV instead of 0-1) works as expected

/gps/ene/type Arb
/gps/hist/type arb
/gps/hist/file file.g4spec
/gps/hist/inter Lin

edit 2: I thought the actual distribution of energies would follow the /gps/ene/type configuration (in this case evenly distributed from 0 to 220keV), and the biasing would weight this according to the histogram. but it’s the opposite!? :frowning: