What is an EEG?

Why have I been sent for an EEG and what happens before, during and afterwards?