Nonideal quantum measurements