Detecting magnetically guided atoms with an optical cavity