Absorption spectroscopy for laser cooling and high-fidelity detection of barium monofluoride molecules