def METHOD_NAME(waveform, rampTime=400, flatTime=200, decayTime=0., baseline=0.):
    """
    Apply a trap filter to a waveform.
    """
    decayConstant = 0.
    norm = rampTime
    if decayTime != 0:
        decayConstant = 1. / (np.exp(1. / decayTime) - 1)
        norm *= decayConstant
    trapOutput = np.zeros_like(waveform)
    fVector = np.zeros_like(waveform)
    scratch = np.zeros_like(waveform)
    fVector[0] = waveform[0] - baseline
    trapOutput[0] = (decayConstant + 1.) * (waveform[0] - baseline)
    wf_minus_ramp = np.zeros_like(waveform)
    wf_minus_ramp[:rampTime] = baseline
    wf_minus_ramp[rampTime:] = waveform[:len(waveform) - rampTime]
    wf_minus_ft_and_ramp = np.zeros_like(waveform)
    wf_minus_ft_and_ramp[:(flatTime + rampTime)] = baseline
    wf_minus_ft_and_ramp[(flatTime + rampTime):] = waveform[:len(waveform) - flatTime - rampTime]
    wf_minus_ft_and_2ramp = np.zeros_like(waveform)
    wf_minus_ft_and_2ramp[:(flatTime + 2 * rampTime)] = baseline
    wf_minus_ft_and_2ramp[(flatTime + 2 * rampTime):] = waveform[:len(waveform) - flatTime -
                                              2 * rampTime]
    scratch = waveform - (wf_minus_ramp +
                          wf_minus_ft_and_ramp - # NOTE: clint changed this to - after walter convinced him
                          wf_minus_ft_and_2ramp)
    if decayConstant != 0:
        fVector = np.cumsum(fVector + scratch)
        trapOutput = np.cumsum(trapOutput + fVector + decayConstant * scratch)
    else:
        trapOutput = np.cumsum(trapOutput + scratch)
    # Normalize and resize output
    tmp_hi = len(waveform) - (2 * rampTime + flatTime)
    trapOutput[:tmp_hi] = trapOutput[2 * rampTime + flatTime:] / norm
    trapOutput.resize((len(waveform) - (2 * rampTime + flatTime)))
    return trapOutput