An electromagnetic cavity is a cavity that acts as a container for electromagnetic fields such as photons, in effect containing their wave function inside. The size of the cavity determines the maximum photon wavelength that can be trapped. Additionally, it produces quantized energy levels for trapped charged particles like electrons and protons. The Earth's magnetic field in effect places the Earth in an electromagnetic cavity.