Many physics analyses using the Compact Muon Solenoid (CMS) detector at the LHC require accurate, high resolution electron and photon energy measurements. Excellent energy resolution is crucial for studies of Higgs boson decays with electromagnetic particles in the final state, as well as searches for very high mass resonances decaying to energetic photons or electrons. The CMS electromagnetic calorimeter (ECAL) is a fundamental component of these analyses, and its energy resolution is crucial for the Higgs boson mass measurement. It also provides a measurement of the electromagnetic component of jets, and contributes to the measurement of calorimeter energy sums, both of which are important for a wide range of CMS physics analyses.
Recently the energy response of the calorimeter has been precisely calibrated exploiting the full Run 2 (2015-18) dataset, and has been used for legacy reprocessing of the data. A dedicated calibration of each detector channel has been performed with physics events exploiting electrons from W and Z boson decays, photons from pi0/eta decays, and from the azimuthally symmetric energy distribution of minimum bias events. This talk presents the calibration strategies that have been implemented and the improved ECAL performance that has been achieved with the ultimate calibration of Run II data, in terms of energy scale stability and energy resolution. The calibration plans currently being developed to achieve and maintain optimum performance during LHC Run 3 (2022-25) will also be discussed.