If any person in respect of whom an order requiring security has been made under section 15 is, at the time when such order is made, sentenced to, or undergoing a sentence of imprisonment or is detained under any law providing for preventive detention, the period for which such security is required shall commence on the expiration of such sentence...