Harmonic phase detector for phase locking of cryogenic terahertz oscillators