def TrimMu(Stot, oldmu, thresh, norm=True):

    """ Remove mu measurements below the threshold and adjust mu measurements
    above the threshold to unity if we seek P(mu > thresh). """

    trim = oldmu > thresh
    if norm:
        oldmu[:] = 0
        oldmu[trim] = 1
    else:
        oldmu = oldmu[trim]
        Stot = Stot[trim]

    return Stot, oldmu