Ensemble of asymmetric quantum dots in a cavity as a terahertz laser source