  Diamond Tin-Vacancy centers have emerged as a promising platform for quantum
information science and technology. A key challenge for their use in more
complex quantum experiments and scalable applications is the ability to prepare
the center in the desired charge state with the optical transition at a
pre-defined frequency. Here we report on heralding such successful preparation
using a combination of laser excitation, photon detection, and real-time logic.
We first show that fluorescence photon counts collected during an optimized
resonant probe pulse strongly correlate with the subsequent charge state and
optical transition frequency, enabling real-time heralding of the desired state
through threshold photon counting. We then implement and apply this heralding
technique to photoluminescence excitation measurements, coherent optical
driving, and an optical Ramsey experiment, finding strongly improved optical
coherence with increasing threshold. Finally, we demonstrate that the prepared
optical frequency follows the probe laser across the inhomogeneous linewidth,
enabling tuning of the transition frequency over multiple homogeneous
linewidths.
