Avalanche photodiodes are commonly used as detectors for low energy x-rays. In this work, we report on a fitting technique used to account for different detector responses resulting from photoabsorption in the various avalanche photodiode layers. The use of this technique results in an improvement of the energy resolution at 8.2 keV by up to a factor of 2 and corrects the timing information by up to 25 ns to account for space dependent electron drift time. In addition, this waveform analysis is used for particle identification, e.g., to distinguish between x-rays and MeV electrons in our experiment.