Development and applications of THz gyrotrons