  The quantum spin states of atomic ensemble are of special interesting for
both fundamental studies and precision measurement applications. Here, we
propose a scheme to prepare collective quantum states of an atomic ensemble
placed in an optical cavity via homodyne measurement of probing light field.
The effective interactions of atoms mediated by photons are enhanced by the
optical cavity, and the output probe light could also be entangled with the
collective spin states. By selectively measuring the quadrature of output
light, we can prepare various quantum states, including superposition states of
Dicke states and Dicke squeezed states. It is also demonstrated that the
fidelity of prepared quantum state can be enhanced by repetitive homodyne
detection and using longer probe laser pulses. Our scheme is feasible for
experimental realization with current technologies, which may be used in future
study of quantum mechanics and quantum metrology.
