Moving horizon estimation for hybrid systems and fault detection