The best way to integrate a piecewise function is to integrate the first region, stop the solver, use the last values of the integration as the new initial conditions, then integrate the second region, and continue until you have integrated the entire function.
The reason is that the function may not be differentiable across the abrupt changes between the regions, giving unreliable results.
