A spectroscopic technique for optimally setting the pole-zero (P-Z) compensation in a digital spectrometer has been implemented, which has substantially improved the resolution of the measurements at high count rates. Before analog-to-digital conversion, the signal undergoes an analog preprocessing, consisting of P-Z compensation and simple three-pole shaping, which is the proper antialiasing-filter shape in this context. A subsequent suitable digital filter optimizes the overall weight function and introduces digital baseline restoration. It is well known that an imperfect P-Z setting causes pulse-tail pileup which is seen as an additional noise and may impact significantly on the final resolution of the measurements, particularly at high count rates. A spectroscopic technique which permits a second-order tuning of the P-Z compensation is proposed. Such a fine-tuning degree yields a substantial improvement in the performance of the system. Namely, at a count rate of 24 kcounts/s the second-order tuning (1% adjustment) yields a 30% narrowing of the 1.17 MeV 60 Co line.Index Terms-Digital baseline restorer, gidital signal processing, digital spectrometry, optimal filter, pole-zero compensation.