Self-dual cosmic strings and gravitating vortices in gauged sigma models