Imaging of spin torque switching and ultrafast spectroscopy at X-ray free electron lasers