Finding PDF of sum of 2 uniform random variables I need help understanding the question and its solution below.

Suppose that X is uniformly distributed in [0,a] and Y is uniformly
  distributed in [0,b], $0 < a \le b$, and that X and Y are independent.
  Find the PDF of $Z=X+Y$.

The solution is as follows.
For simplicity, define the unit square pulse
$$q(t) = u(t) - u(t-1)$$
where u(t) is the unit step function. Then the PDFs of X and Y are
$$f_X(x) = \frac{1}{a} q(\frac{x}{a})$$
$$f_Y(y) = \frac{1}{b} q(\frac{x}{b})$$
The PDF of Z is the convolution of $f_x$ and $f_Y$. i.e.
$$f_Z(z) = \int_{-\infty}^{\infty}\frac{1}{ab}q(\frac{\tau}{a})q(\frac{z-\tau}{b})d\tau$$
Therefore, 
\begin{equation}
  f_Z(z) = \frac{1}{ab}\begin{cases}
    z, & \text{if $0<z\le a$}.\\
    a, & \text{if $a<z\le b$}.\\
    a+b-z, & \text{if $b<z\le a+b$}.\\
    0, & \text{elsewhere}.\\
  \end{cases}
\end{equation}
I have a few questions.
(1) How is the $f_X(x)$ and $f_Y(x)$ obtained? Why involve the unit step function instead of just taking $f_X(x) = \frac{1}{a}$ and $f_Y(x) = \frac{1}{b}$?
(2) I don't know how to get $f_Z$. I sketched out the 3 ranges for z.



I think my sketches must be wrong. My understanding of the convolution is that it is the resulting overlapping region between $f_X(x)$ and $f_Y(z-b)$ (the corresponding q functions seem to be a factor of $f_Y$ and $f_X$?), so I don't know how the overlapping region can be more than the red squares, bounded by $x = a$.
 A: 
(1) How is the $f_X(x)$ and $f_Y(x)$ obtained? Why involve the unit step function instead of just taking $f_X(x) = \frac{1}{a}$ and $f_Y(x) = \frac{1}{b}$?

$$f_X(x) = \frac 1 a\;\mathbf q(\tfrac xa) = \frac 1 a \;\mathbf 1_{0\leq x\leq a} = \frac 1 a\begin{cases} 1 & : 0\leq x\leq a \\ 0 & :\text{otherwise}\end{cases}$$
The unit step function ensures the pdf is non-zero over the support and zero elsewhere.   Consider it as an indicator function.   This is useful in determining what bounds should be used for the convolution.

(2) I don't know how to get $f_Z$. I sketched out the 3 ranges for z.

$$\begin{align}f_Z(z) & = \int_{-\infty}^{\infty}\tfrac{1}{ab}\mathbf q\big(\tfrac{\tau}{a}\big)\mathbf q\big(\tfrac{z-\tau}{b}\big)\operatorname d\tau
\\[1ex] & = \int_{-\infty}^{\infty}\tfrac{1}{ab}\mathbf 1_{0\leq \tau\leq a, 0\leq z-\tau\leq b}\operatorname d\tau
\\[1ex] & = \mathbf 1_{0\leq z\leq a+b}\int_{-\infty}^{\infty}\tfrac{1}{ab}\mathbf 1_{0\leq \tau\leq a, z-b\leq \tau\leq z}\operatorname d\tau
\\[2ex] & = \mathbf 1_{0\leq z\leq a+b}\int_{\max(0,z-b)}^{\min(a,z)}\tfrac{1}{ab}\operatorname d\tau
\\[0ex] & = \mathbf 1_{0\leq z< a}\int_{0}^{z}\tfrac{1}{ab}\operatorname d\tau
\\[0ex] & \quad + \mathbf 1_{a\leq z< b}\int_{0}^{a}\tfrac{1}{ab}\operatorname d\tau
\\[0ex] & \quad + \mathbf 1_{b\leq z\leq a+b}\int_{z-b}^{a}\tfrac{1}{ab}\operatorname d\tau
\\[2ex] & = \mathbf q\big(\tfrac{z}{a}\big)\int_{0}^{z}\tfrac{1}{ab}\operatorname d\tau
\\[0ex] & \quad + \mathbf q\big(\tfrac{z-a}{b-a}\big)\int_{0}^{a}\tfrac{1}{ab}\operatorname d\tau
\\[0ex] & \quad + \mathbf q\big(\tfrac{z-b}{a}\big)\int_{z-b}^{a}\tfrac{1}{ab}\operatorname d\tau
\end{align}$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
By definition, the answer is given by:
\begin{align}
&\bbox[5px,#ffd]{\left.\int_{0}^{a}{1 \over a}
{\bracks{0 < z - x < b} \over b}\,\dd x
\,\right\vert_{\ 0\ <\ a\ \leq\ b}}
\\[5mm] = &\
{1 \over ab}\int_{0}^{a}
\bracks{z - b < x < z}\,\dd x
\\[5mm] = &\
{\bracks{z - b < 0} \over ab}
\bracks{0 < z < a}\int_{0}^{z}\dd x
\\[2mm] + &\
{\bracks{z - b < 0} \over ab}
\bracks{z > a}\int_{0}^{a}\dd x
\\[2mm] + &\
{\bracks{0 < z - b < a} \over ab}
\bracks{z > a}\int_{z - b}^{a}\dd x
\\[5mm] = &\
{\bracks{0 < z < a} \over ab}\,z +
{\bracks{a < z < b} \over ab}\,a
\\[2mm] + &\
{\bracks{b < z < a + b} \over ab}
\,\pars{a + b - z}
\\[5mm] \substack{0\ <\ a\ \leq\ b
\,\,\,\,\,\,\,\,\,\, \\[1mm]
{\LARGE =}} &\
\!\!\!\!\!
\left\{\begin{array}{lcl}
\ds{z \over ab} & \mbox{if} & \ds{z \leq a}
\\[2mm]
\ds{1 \over b} & \mbox{if} & \ds{a < z \leq b}
\\[2mm]
\ds{{1 \over b} + {1 \over a} - {z \over ab}} & \mbox{if} & \ds{b < z < a + b}
\\[2mm]
\ds{0} && \mbox{otherwise}
\end{array}\right.
\end{align}
The following picture is a particular example with $\ds{\color{red}{a = 1}}$ and $\ds{\color{red}{b = 2}}$:


