Method for producing a spectral computed tomography image data set by means of a detection unit, having at least one photon-counting X-ray detector (71, 72, 73, 74) and configured to convert detected X-rays into measurement signals which are resolved at least into a first adaptable energy range and a second adaptable energy range, and by means of an X-ray source unit, configured to emit X-rays having a first energy spectrum and having a second energy spectrum which differs from the first, comprising the steps of: - adapting the first energy range and the second energy range as a function of the first energy spectrum and the second energy spectrum by means of an adaptation unit, wherein in each case at least one limiting energy (GE1, GE2) of a respective energy range (EB1, EB2) is adapted, - emitting X-rays having the first energy spectrum and having the second energy spectrum by means of the X-ray source unit, - detecting the emitted X-rays having the first energy spectrum and having the second energy spectrum by means of the detection unit, wherein at least one first measurement signal is generated as a function of the first energy range and the first energy spectrum and at least one second measurement signal as a function of the second energy range and the second energy spectrum, - producing the spectral computed tomography image data set at least on the basis of the generated first and the generated second measurement signals with the assistance of a spectral image processing technique by means of an image processing unit, - outputting the spectral computed tomography image data set by means of an interface, characterised in that the method further comprises - determining an optimised energy value for the respective at least one limiting energy (GE1, GE2) of the first energy range and the second energy range at least on the basis of the first energy spectrum and the second energy spectrum by means of an optimisation unit, wherein moreover at least one criterion from the following list is optimised: • an image noise value of the computed tomography image data set, • an image contrast value of the computed tomography image data set, • a material contrast value of the computed tomography image data set, • an artifact value of the computed tomography image data set, • a spectral overlap value between the first energy spectrum and the second energy range and/or the second energy spectrum and the first energy range, and wherein the adapting is based on the optimised energy value for the respective at least one limiting energy (GE1, GE2). - adapting the first energy range and the second energy range as a function of the first energy spectrum and the second energy spectrum by means of an adaptation unit, wherein in each case at least one limiting energy (GE1, GE2) of a respective energy range (EB1, EB2) is adapted, - emitting X-rays having the first energy spectrum and having the second energy spectrum by means of the X-ray source unit, - detecting the emitted X-rays having the first energy spectrum and having the second energy spectrum by means of the detection unit, wherein at least one first measurement signal is generated as a function of the first energy range and the first energy spectrum and at least one second measurement signal as a function of the second energy range and the second energy spectrum, - producing the spectral computed tomography image data set at least on the basis of the generated first and the generated second measurement signals with the assistance of a spectral image processing technique by means of an image processing unit, - outputting the spectral computed tomography image data set by means of an interface, characterised in that the method further comprises - determining an optimised energy value for the respective at least one limiting energy (GE1, GE2) of the first energy range and the second energy range at least on the basis of the first energy spectrum and the second energy spectrum by means of an optimisation unit, wherein moreover at least one criterion from the following list is optimised: • an image noise value of the computed tomography image data set, • an image contrast value of the computed tomography image data set, • a material contrast value of the computed tomography image data set, • an artifact value of the computed tomography image data set, • a spectral overlap value between the first energy spectrum and the second energy range and/or the second energy spectrum and the first energy range, and • an image noise value of the computed tomography image data set, • an image contrast value of the computed tomography image data set, • a material contrast value of the computed tomography image data set, • an artifact value of the computed tomography image data set, • a spectral overlap value between the first energy spectrum and the second energy range and/or the second energy spectrum and the first energy range, and