A new method for the determination of goodness-of-fit in gamma spectroscopy