  We consider light scattering from ultracold atoms trapped in an optical
lattice into a cavity. The measurement of photons leaking out the cavity
provides a quantum nondemolition (QND) access to various atomic variables.
Depending on the chosen geometry the time resolved light detection projects the
atomic quantum state to various atom-number squeezed and Schroedinger cat
states. Modifications of the atomic and light properties at a single quantum
trajectory are demonstrated. The quantum structure of final states can be
revealed by further observations of the same sample.
