A general Monte Carlo calculation for the geometrical efficiency of a detection system