  We define and study a sheaf-theoretic cohomological Hall algebra for suitably
geometric Abelian categories $\mathcal{A}$ of homological dimension at most
two, and a sheaf-theoretic BPS algebra under the conditions that $\mathcal{A}$
is 2-Calabi-Yau and has a good moduli space. We show that the BPS algebra for
the preprojective algebra $\Pi_Q$ of a totally negative quiver is the free
algebra generated by the intersection cohomology of the closure of the locus
parameterising simple $\Pi_Q$-modules in the coarse moduli space.
  We define and study the BPS Lie algebra of arbitrary 2-Calabi-Yau categories
$\mathcal{A}$ for which the Euler form is negative on all pairs of non-zero
objects, which recovers the BPS algebra as its universal enveloping algebra for
such "totally negative" 2CY categories. We show that for totally negative 2CY
categories the BPS algebra is freely generated by intersection complexes of
certain coarse moduli spaces as above, and the Borel-Moore homology of the
stack of objects in such $\mathcal{A}$ satisfies a Yangian-type PBW theorem for
the BPS Lie algebra. In this way we prove the cohomological integrality theorem
for these categories.
  We use our results to prove that for $C$ a smooth projective curve, and for
$r$ and $d$ not necessarily coprime, there is a nonabelian Hodge isomorphism
between the Borel-Moore homologies of the stack of rank $r$ and degree $d$
Higgs bundles, and the appropriate stack of twisted representations of the
fundamental group of $C$. In addition we prove the Bozec-Schiffmann positivity
conjecture for totally negative quivers; we prove that their polynomials
counting cuspidal functions in the constructible Hall algebra for $Q$ have
positive coefficients, strengthening the positivity theorem for the Kac
polynomials of such quivers.
