Cavity phenomenon and terahertz radiation of a tall stack of intrinsic Josephson junctions wrapped by a dielectric material