  Quantum systems are promising candidates for sensing of weak signals as they
can provide unrivaled performance when estimating parameters of external
fields. However, when trying to detect weak signals that are hidden by
background noise, the signal-to-noise-ratio is a more relevant metric than raw
sensitivity. We identify, under modest assumptions about the statistical
properties of the signal and noise, the optimal quantum control to detect an
external signal in the presence of background noise using a quantum sensor.
Interestingly, for white background noise, the optimal solution is the simple
and well-known spin-locking control scheme. We further generalize, using
numerical techniques, these results to the background noise being a correlated
Lorentzian spectrum. We show that for increasing correlation time, pulse based
sequences such as CPMG are also close to the optimal control for detecting the
signal, with the crossover dependent on the signal frequency. These results
show that an optimal detection scheme can be easily implemented in near-term
quantum sensors without the need for complicated pulse shaping.
