Initial and final state effects in the photoionization spin–orbit branching ratio of core levels