Quantizing a self-trapping transition