An Algorithm for the Energy Deposition by Fast Electrons