New jet flavour definition: Backport from 7_1_X

Backport of #2395, #3025, and #3228.