Characterization of Bose-Hubbard models with quantum nondemolition measurements