  Let $k \geq 2$ and $N$ be positive integers and let $\chi$ be a Dirichlet
character modulo $N$. Let $f(z)$ be a modular form in $M_k(\Gamma_0(N),\chi)$.
Then we have a unique decomposition $f(z)=E_f(z)+S_f(z)$, where $E_f(z) \in
E_k(\Gamma_0(N),\chi)$ and $S_f(z) \in S_k(\Gamma_0(N),\chi)$. In this paper we
give an explicit formula for $E_f(z)$ in terms of Eisenstein series. Then we
apply our result to certain families of eta quotients and to representations of
positive integers by $2k$-ary positive definite quadratic forms in order to
give an alternative version of Siegel's formula for the weighted average number
of representations of an integer by quadratic forms in the same genus. Our
formula for the latter is in terms of generalized divisor functions and does
not involve computation of local densities.
