In high energy experiments such as active beam dump searches for rare decays
and missing energy events, the beam purity is a crucial parameter. In this
paper we present a technique to reject heavy charged particle contamination in
the 100 GeV electron beam of the H4 beam line at CERN SPS. The method is based
on the detection with BGO scintillators of the synchrotron radiation emitted by
the electrons passing through a bending dipole magnet. A 100 GeV $\pi^-$ beam
is used to test the method in the NA64 experiment resulting in a suppression
factor of $10^{-5}$ while the efficiency for electron detection is $\sim$95%.
The spectra and the rejection factors are in very good agreement with the Monte
Carlo simulation. The reported suppression factors are significantly better
than previously achieved.Comment: 10 pages, 6 figure