  We aim to study spatial and kinematic substructures of the region encompassed
by Upper Scorpius and Ophiuchus star-forming regions, determining dynamical
traceback ages and studying the star formation history of the complex. We
identified seven different groups in this region. Four groups (nu Sco, beta
Sco, sigma Sco and delta Sco) are part of Upper Scorpius, two groups (rho Oph
and alpha Sco) are in Ophiuchus, and another group (pi Sco) is a nearby young
population. We found an age gradient from the rho Oph group (the youngest) to
the delta Sco group (<~5 Myr), showing that star formation was a sequential
process for the past 5 Myr. Our traceback analysis shows that Upper Scorpius
and rho Oph groups share a common origin. The closer group of pi Sco is
probably older, and the traceback analysis suggests that this group and the
alpha Sco group have a different origin, likely related to other associations
in the Sco-Cen complex. Our study shows that this region has a complex star
formation history that goes beyond the current formation scenario, likely a
result of stellar feedback from massive stars, supernovae explosions, and
dynamic interactions between stellar groups and the molecular gas. In
particular, we speculate that photo-ionisation from the massive delta Sco star
could have triggered star formation first in the beta Sco group and then in the
nu Sco group. The perturbations of stellar orbits due to stellar feedback and
dynamical interactions could also be responsible for the 1-3 Myr difference
that we found between dynamical traceback ages and isochronal ages.
