# Finding the correlation function of two rectangular impulses

I'm trying to understand the principle of correlaction functions.
I have two rectangular signals:

$$s(\tau) = a_1 \cdot (\sigma (\tau) - \sigma (\tau - T_1))$$
$$g(\tau) = a_2 \cdot (\sigma (\tau) - \sigma (\tau - T_2))$$

To find the correlation function, I need to take a look at five intervals:
1. $$t < -T_1$$
2. $$-T_1 \leq t < - T_1 + T_2$$
3. $$-T_1 + T_2 \leq t < 0$$
4. $$0 \leq t < T_2$$
5. $$t > T_2$$

I know, that the correlation for 1. and 5. is 0. The question is: how do I find the correlation function for 2, 3 and 4?

$$\varphi_{sg}^E = \int_{-\infty}^{\infty} s(\tau) \cdot g(t + \tau) d\tau$$

I know that for 2. it should be $$\varphi_{sg}^E (t) = (t + T_1) \cdot a_1 a_2$$. But as far as I know, you can't integrate heaviside functions. So how do I find the solution for this without "really" integrating?

Edit:
Despite the question, how to integrate the heaviside function, I have a second problem. I should have written it more clearly.
I want to find a function (or functions) which look like the one in the screenshot, when you combine them. The question is, from where to where I need to integrate to achieve this.
The 5 intervals given at the beginning should help, but unfortunately they don't help me.

You only need to integrate over the region where the two square signals have overlap. Both signals start at $$t=0$$, lasting $$T_1$$ and $$T_2$$, respectively, and without lag between them.
Since you seem to assume $$T_2>T_1$$, then their correlation is non-zero over $$(0,T_1)$$,
$$\int_0^{T_1} s(\tau)g(\tau)d\tau = a_1 a_2 T_1$$