Energy transfer from photocarriers into the magnetic ion system mediated by a two-dimensional electron gas in (Cd,Mn)Te/(Cd,Mg)Te quantum wells