Reconstruction of the velocity space of runaway electrons by spectral measurements of the hard x-ray emission in tokamaks