A total absorption spectrometer for energy measurements of high-energy particles