Does contour integral over $\mathbb{R}$ give a step function? I have the following integral
$$ \int \frac{dx}{2\pi i} \frac{1}{(x+ia)^2+b^2} $$
where $x$ is a real variable and we integrate in the real axis from $-\infty$ to $+\infty$. I am also given the fact that
$$
\int dx \frac{1}{(x + ia)^2+b^2}=\frac{\pi}{|b|}\theta(|b|-|a|)
$$
integrating again in the real line and where $\theta$ is the step function. I want to know why the latter integral gives me this theta function and if I am right that the first integral would then give me
$$
\frac{-i}{|b|}\theta(|b|-|a|)
$$
 A: Let $I(a,b)$ be integral of interest given by  
$$I(a,b)=\int_{-\infty}^\infty \frac{1}{(x+ia)^2+b^2}\,dx \tag 1$$
We assume that $b\ne0$ else the integral is trivially $0$ for $a\ne 0$.
Note that the function $f(z)$, defined as $f(z)=\frac{1}{(z+ia)^2+b^2}$ has first-order poles at $z=-i(a\pm b)$ with corresponding residues given by 
$$\text{Res}\left(\frac{1}{(z+ia)^2+b^2},z=-i(a\pm b)\right)=\mp \frac{1}{2ib} \tag 2$$
Next, $C$ be the closed contour comprised of the real line segment from $-R$ to $R$ and the semi-circle in the upper-half plane, with radius $R$ and centered at the origin.  Define $J(a,b)$ as the closed-contour integral around $C$ of $f(z)$.  Then, we can write 
$$\begin{align}
J(a,b)&=\oint_C \frac{1}{(z+ia)^2+b^2}\,dz\\\\
&=\int_{-R}^R \frac{1}{(x+ia)^2+b^2}\,dx+\int_0^{\pi}\frac{1}{(Re^{i\phi}+ia)^2+b^2}\,iRe^{i\phi}\,d\phi \tag 3
\end{align}$$
In the limit as $R\to \infty$, the first integral on the right-hand side of $(3)$ tends to $I(a,b)$ as given in $(1)$ while the second integral on the right-hand side of $(2)$ tends to $0$.
Moreover, the residue theorem guarantees that $J(a,b)$ is $2\pi i$ times the residues from the poles enclosed in $C$ as given in $(2)$.  We have four cases to examine.  


Case 1:  Neither pole is in the upper-half plane.

Here, if $\text{Re}(a-b)>0$ and $\text{Re}(a+b)>0$, then no pole is enclosed and $I(a,b)=0$.
Note that this corresponds to $|\text{Re}(a)|>|\text{Re}(b)|$.


Case 2:  Both poles are enclosed in the upper-half plane.

Here, if $\text{Re}(a-b)<0$ and $\text{Re}(a+b)<0$, then both poles are enclosed.  The sum of the residues is $0$ and $I(a,b)=0$.
Note that this also corresponds to $|\text{Re}(a)|>|\text{Re}(b)|$.


Case 3:  Only the pole at $z=-i(a-b)$ is enclosed in the upper-half plane.

Here, if $\text{Re}(a-b)<0$ and $\text{Re}(a+b)>0$, then only the pole at $z=-i(a-b)$ is enclosed.  The residue from this pole is $\frac{1}{2ib}$ and $I(a,b)=\frac{\pi}{b}$.
Note that this corresponds to $|\text{Re}(b)|>|\text{Re}(a)|$.


Case 4:  Only the pole at $z=-i(a+b)$ is enclosed in the upper-half plane.

Here, if $\text{Re}(a-b)>0$ and $\text{Re}(a+b)<0$, then only the pole at $z=-i(a+b)$ is enclosed.  The residue from this pole is $-\frac{1}{2ib}$ and $I(a,b)=-\frac{\pi}{b}$.
Note that this also corresponds to $|\text{Re}(b)|>|\text{Re}(a)|$.

Putting all $4$ cases together, we see that if $|\text{Re}(a)|>|\text{Re}(b)|$, $I(a,b)=0$, while if $|\text{Re}(b)|>|\text{Re}(a)|$, then $I(a,b)=\pm \frac{\pi}{b}$.  In addition, for Case $3$, we see that $\text{Re}(b)>0$, while for Case $4$, $\text{Re}(b)<0$.  Thus, we can finally write
$$\bbox[5px,border:2px solid #C0A000]{I(a,b)=\text{sgn}\left(\text{Re}(b)\right)\,\left(\frac{\pi}{b}\right)\,\theta\left(|\text{Re}(b)|-|\text{Re}(a)|\right)} \tag 4$$
where 
$$\text{sgn}(x)=\begin{cases}1&,x>0\\\\0&,x=0\\\\1&,x< 0 \end{cases}$$
and
$$\theta(x)=\begin{cases}1&,x>0\\\\0&,x\le 0 \end{cases}$$
For real-valued $a$ and $b$, $(4)$ simplifies to 
$$\bbox[5px,border:2px solid #C0A000]{I(a,b)=\left(\frac{\pi}{|b|}\right)\,\theta\left(|b|-|a|\right)} $$
as was to be shown!
