Friedrich-Wintgen bound states in the continuum in a photonic and plasmonic T-shaped cavity: Application to filtering and sensing