y1 = findpeaks(s(1));
s(1) is a scalar. findpeaks() is not going to do anything useful there.
The event function will not receive any information about the history of the ode. You could hypothetically record the history as it runs, but that is risky, as the ode will get evaluated at a number of points that will never be passed through in practice, as Runge-Kutta methods require sampling at nearby locations in order to estimate the local slopes.
If you need a reliable history of the function, you need to use one of the delay differential routines.
You do not have a constant delay (or at least you do not know what it is) so if you have any hope at all it would be in https://www.mathworks.com/help/matlab/math/state-dependent-delay-problem.html . This is not a topic I have enough experience with to know whether that can be usefully adapted.