Determination of the pattern of neutrino masses at a neutrino factory