A Comprehensive Model of the Response of Silicon Photomultipliers