Disclosed herein is a radiation detector, comprising: an avalanche photodiode (APD) with a first side coupled to an electrode and configured to work in a linear mode; a capacitor module electrically connected to the electrode and comprising a capacitor, wherein the capacitor module is configured to collect charge carriers from the electrode onto the capacitor; a current sourcing module in parallel to the capacitor, the current sourcing module configured to compensate for a leakage current in the APD and comprising a current source and a modulator; wherein the current source is configured to output a first electrical current and a second electrical current; wherein the modulator is configured to control a ratio of a duration at which the current source outputs the first electrical current to a duration at which the current source outputs the second electrical current.