  Quantum enhancements of precision in metrology can be compromised by system
imperfections. These may be mitigated by appropriate optimization of the input
state to render it robust, at the expense of making the state difficult to
prepare. In this paper, we identify the major sources of imperfection an
optical sensor: input state preparation inefficiency, sensor losses, and
detector inefficiency. The second of these has received much attention; we show
that it is the least damaging to surpassing the standard quantum limit in a
optical interferometric sensor. Further, we show that photonic states that can
be prepared in the laboratory using feasible resources allow a measurement
strategy using photon-number-resolving detectors that not only attains the
Heisenberg limit for phase estimation in the absence of losses, but also
deliver close to the maximum possible precision in realistic scenarios
including losses and inefficiencies. In particular, we give bounds for the
trade off between the three sources of imperfection that will allow true
quantum-enhanced optical metrology.
