Reconstruction of cascading failures in dynamical models of power grids