I have an x-ray fluorescence detector which is used to measure the composition of different elements in a sample. The detector measures a signal which contains peaks at certain positions which correspond to different elements, as shown here. The output of the detector is counts per bin, not energy as shown in the image. I need to find the transformation values from the bins scale to the energy scale, which is of the form $ax + b$.
Since I know which elements are likely present, I know at which energies I can expect peaks to appear. These energies are theoretically always the same and so is their spacing, but due to noise it might vary slightly.
My goal is to find an algorithm which is able to find the transformation from the bin scale to the energy scale. And in order to make the algorithm more robust, I do not want it to break if a certain peak is absent or if I find additional peaks.
My initial thought was to select certain points from the bins set and the energy set and check which pair results in the lowest error. I would probably include here a lower bound that it will not use just one or two points which will have a very low error of course. Is there any method to tackle a problem such as this?
Example
Say I measure a sample which has Zn, Cu and Fe. The expected peak positions of the K$\alpha$ and K$\beta$ peaks for these elements are at energies and measured bin positions (with added noise for the bin positions):
Ka (bin) Ka (keV) Kb (bin) Kb (keV)
Fe 1319 6.405 1467 7.059
Cu 1668 8.046 1870 8.904
Zn 1802 8.637 2034 9.57
Which looks like this when plotted and fitted. (Yes I cheated with the fitting by only taking the Kb points).
However this would not work if I did not measure the Kb Fe peak at bin 1467, since I have 6 points in my energy set and only 5 in the bin set. It would also not work if I would measure an extra point at say bin 1500, which would not correspond to any element.
