# Generating function for sum of two squares is a modular form

Let $$\theta(\tau) = \sum_{n = -\infty}^{\infty}q^{n^2}, \quad q:=e^{2\pi i\tau}$$ be the classical theta series. The Fourier coefficients $$r_2(n)$$ of $$\theta(\tau)^2$$ give the number of ways of writing $$n$$ as a sum of two squares. It is known that $$r_2(n) = 4\sum_{d \mid n}\chi_{-4}(n),$$ where $$\chi_{-4}$$ is the Dirichlet character defined by $$\chi_{-4}(n) = \begin{cases} 1, & n\equiv 1 \mod 4 \\ -1, &n \equiv 3 \mod 4\\ 0, &n \equiv 0,2 \mod 4.\end{cases}.$$ It is known that $$\theta(\tau)$$ is a modular form of weight $$1$$ on the congruence subgroup $$\Gamma_0(4)$$ of $$\textrm{SL}_2(\mathbb{Z})$$. My question is how do we directly show that $$f(\tau) = 1 + \sum_{n=1}^{\infty}4\left(\sum_{d \mid n}\chi_{-4}(d)\right)q^n$$ is a modular form of weight $$1$$ on $$\Gamma_0(4)$$? It seems tempting to use Poisson summation as is used to find the Fourier expansion of Eisenstein series, but the corresponding "Eisenstein series" would be weight $$1$$ and I don't think Poisson summation would apply.