Layer-resolved readout of magnetic signals using ferromagnetic resonance effect