def hamamatsu_count_calibration(counter_data, offset, EM_gain, analog_gain):
    """
    converts hamamatsu counting data to number of incident photons
    Args:
        counter_data : ndarray of camera counts
        offset : couning offset
        EM_gain : EM gain setting on the camera
        analog_gain : analog gain setting on the camera
    """
    return (counter_data - offset) / (EM_gain * analog_gain)