THz grating sensors for investigation of thin dielectric layers