def gate_detections(gate, epoch_frame):
    """
    Gates detections and returns trimmed list of detections for epoch frame
    Inputs:
        gate -- list of tuples containing allowed rng ranges, bearing ranges, and object types
        epoch_frame -- list of detections
    Returns:
        gated_epoch_frame -- gated list of detections
        detections_used -- list of detections used in creation of observation for this object
    """
    # initialize gated epoch frame
    gated_epoch_frame = [0] * len(epoch_frame)

    # initialize detections used
    detections_used = [0] * len(epoch_frame)

    # loop through detections and gate
    for ii, det in enumerate(epoch_frame):
        if (gate[0][0] < det[0] < gate[0][1]) and (gate[1][0] < det[1] < gate[1][1]) and (det[2] in gate[2]):
            # add detection to gated epoch frame
            gated_epoch_frame[ii] = det

            # update detections used
            detections_used[ii] = 1

    return gated_epoch_frame, detections_used