def compute_efficiencies(denominator_lumi, numerator_lumi, weight, weighted_mean_numerator, sum_weights):
    """Compute efficiencies based on the input parameters. Returns a
    tuple consisting of (efficiency, weighted efficiency,
    weighted_mean_numerator, sum_weights). We return the partial
    numerator and denominator of the weighed mean calculation to ease
    the calculation of weighted values iteratively. It is
    responsibility of the calling function to properly store these
    numbers and keep on passing them to this routine.  """

    if denominator_lumi == 0:
        return (-1, -1,
                weighted_mean_numerator,
                sum_weights)
    eff  = numerator_lumi/denominator_lumi
    sum_weights += weight
    weighted_mean_numerator += (eff * weight)
    if sum_weights == 0:
        weighted_mean = 0.
    else:
        weighted_mean = weighted_mean_numerator / sum_weights
    return (eff, weighted_mean,
            weighted_mean_numerator,
            sum_weights)