Fast calculation of best focus position