Calculation of gamma-ray pulse height spectrum in a semiconductor detector in the presence of charge carrier trapping