def get_proportion_selected(val_list, selector, norm=True):
    """Find the proportion of tracks selected with the given selector.
    If there are no tracks in the tracks property value list, returns
    zero. Can also return the number of tracks meeting the condition.

    Args:
        val_list: a list of values of a track property, such as
            tp_pt or trk_chi2rphi.
        selector: a property that these value can satisfy. For
            example, "lambda trk_eta: trk_eta <= 2.4".
        norm: if True, divides the number of tracks meeting the
            condition by the total number of tracks. This is the default
            option.

    Returns:
        Either the number or proportion of tracks meeting the condition,
        depending on the value of norm.
    """

    if len(val_list) == 0:
        return 0

    num_tracks_meeting_cond = sum(map(selector, val_list))
    return float(num_tracks_meeting_cond) / len(val_list) if norm \
            else num_tracks_meeting_cond