1. A photosensor gain detection apparatus, comprising: a detector including a photosensor configured to output a signal; an after-pulse/dark-pulse detector device configured to detect an after-pulse or a dark-pulse in the signal output by the photosensor, and to output an indication signal when the after-pulse or the dark-pulse is detected, the after-pulse and the dark-pulse representing after-events in the photosensor triggered from a previous photon generating event; an integrator device configured to integrate the signal output by the photosensor and to output an integrated signal; a histogram device connected to the integrator and the after-pulse/dark-pulse detector device, and configured to generate a histogram from the integrated signal and the indication signal; a gain determination device configured to determine a gain of the photosensor based on the generated histogram; and a memory configured to store the determined gain.