Let $f \in L^2(\mathbb R)$ then it is well-known that $$ \widetilde{f}(x):=\sum_{n \in \mathbb Z} \frac{1}{\varepsilon}\int_{[n\varepsilon,(n+1)\varepsilon]} f(s) \ ds 1_{[n\varepsilon,(n+1)\varepsilon)}(x)$$
converges in the $L^2$ sense to $f.$
But even more is true, as we can write
$$(\widetilde{f}-f)(x):=\sum_{n \in \mathbb Z} \frac{1}{\varepsilon}\int_{[n\varepsilon,(n+1)\varepsilon]} f(s)-f(x) \ ds 1_{[n\varepsilon,(n+1)\varepsilon)}(x).$$
Then, it follows that if $f$ is absolutely continuous that $$(\widetilde{f}-f)(x):=\sum_{n \in \mathbb Z} \frac{1}{\varepsilon}\int_{[n\varepsilon,(n+1)\varepsilon]} \int_x^s f'(\tau) d \tau \ ds 1_{[n\varepsilon,(n+1)\varepsilon)}(x).$$
Hence, it is tempting to ask whether there are conditions on $f$ being in some Sobolev space such that
$$\left\lVert \widetilde{f}-f \right\rVert_{L^2}=\mathcal O(\varepsilon).$$
Moreover, perhaps this generalizes to higher dimensions, i.e. $\mathbb R^d$ rather than $\mathbb R.$
It seems that what would be sufficient is that $$\sum_{n \in \mathbb Z} \frac{1}{\varepsilon} \sup_{s \in [n \varepsilon, (n+1)\varepsilon)}\left\lvert f'(s)\right\rvert 1_{[n\varepsilon,(n+1)\varepsilon)}(x)$$ is square-integrable. However, I fail to see whether there is some natural Sobolev space in which functions have this property.