A method for characterization of coherent backgrounds in real time and its application in gravitational wave data analysis