Differential cohomology in quantum field theory