Definition of winding numbers for Hamiltonian In Witten's lectures at the PSSCMP/PiTP summer school, there is a use of winding number for "bad points" at sec.1.3. The formula is 
$$
w = \int_S\frac{d^2p}{4\pi}\left[\epsilon^{\mu\nu}\epsilon^{abc}n_a\frac{\partial n_b}{\partial p^{\mu}}\frac{\partial n_c}{\partial p^{\nu}}\right].
$$
I notice that it's also the formula to calculate first Chern number directly from Hamiltonian, like for Graphene. (Iff the Hamiltonian contains all three Pauli matrices, the result might be nontrivial.) But in some [papers][1], there are also another formula for winding number, 
$$
w = \int_C\frac{d\vec{k}}{2\pi}\left[\frac{h_x}{|\vec{h}|}\nabla\frac{h_y}{|\vec{h}|}-\frac{h_y}{|\vec{h}|}\nabla\frac{h_x}{|\vec{h}|}\right],
$$
which seems to be considered also a characteristic of band topology. This winding number needs only two Pauli matrices, so I guess it's different from the first. BUT what is the difference? Is it because the first is insulator and the second is semimetal? I actually don't have any idea about this concept and I can't seem to find any reference talking about it. 
Thanks in advance!
EDIT:
So I add some of my understanding here. The first winding number has something to do with mapping the 2D BZ ($T^2$) to unit-norm $\mathbf{n}$-vector manifold, which is a 2-sphere. So it can be nontrivial iff $\mathbf{n}$ has no vanishing component. 
So with the first formula, graphene with no magnetic field and no spin-obit coupling is trivial. BUT with the second formula, it's not.
$\vec{h}$ is defined to have only 2 component, which, in my eyes, only form a 1-sphere. The winding number should always be trivial, from homotopy arguments (I don't really understand this.). The counterargument is that if we plot the flow plot of $\vec{h}$, we see a vertex structure exactly like the vertex structure in XY model from statistical mechanics, which is one of the staring points of topology in physics.
So I am lost in these thoughts. I don't know where I did make a mistake.
EDIT2:I gather that $\pi_2(S^1)$ is always trivial from wiki. But I am no sure why we always choose to see 2D BZ, which is actually a $T^2$, as a $S^2$. (For hours, I can't find any information for $\pi_{T^2}(S^1)$.) Any help for this is also welcome.
[1]An example is doi:10.1038/nphys2134 (eq.S29 in http://www.nature.com/nphys/journal/v8/n1/extref/nphys2134-s1.pdf)
 A: Both examples you ask about are for gapless systems, but in your edit you then bring up some notions related to the gapped systems, so let me address both. Moreover it will turn out that understanding the gapped case well (which is simpler) almost naturally implies the gapless case.
Topological invariants for band insulators
Suppose we have our Brillouin zone in $d$ dimensions. Because of periodicity this is basically the $d$-dimensional torus $T^d$. If we imagine for simplicity that our system has two bands, then in Fourier space $H_{\boldsymbol k} = \boldsymbol n_{\boldsymbol k} \cdot \boldsymbol \sigma$ (putting chemical potential to zero such that we have one filled band). This defines a map $\boldsymbol n_{\boldsymbol k} :T^d \to \mathbb R^3$. But note that we assume our system is an insulator, which means that at every point, $H_{\boldsymbol k}$ should have a gap. Since the eigenvalues are given by $\pm |\boldsymbol n_{\boldsymbol k}|$, this means we require $\boldsymbol n_{\boldsymbol k} \neq 0$. In other words $\boldsymbol n_{\boldsymbol k} :T^d \to \mathbb R^3_0$ which topologically is equivalent to 
$$ \boldsymbol n_{\boldsymbol k} :T^d \to S^2 $$
Case $ d = 2$: Then we have a map $T^2 \to S^2$. This map has a topological invariant which is easy to picture: imagine taking a torus and two spheres. One sphere is outside of the torus (containing it completely), the other sphere is inside the tube of the torus. Now imagine inflating the smaller sphere until it touches the bigger sphere. In the process the torus is being flattened in between the two spheres. So this now visually defines a map from the (squashed) torus to the sphere. Moreover you can see this map is topologically non-trivial: by locally pulling and stretching the torus, you can't shrink it to a point. We say this torus winds once around the sphere, and such a number can be measured by calculating the winding number:
$$\propto \iint_{T^2}  \mathrm d k_1 \mathrm d k_2 \; \boldsymbol n_{\boldsymbol k} \cdot \left( \frac{\partial \boldsymbol n_{\boldsymbol k}}{\partial k_1} \times \frac{\partial \boldsymbol n_{\boldsymbol k}}{\partial k_2} \right) $$
(Note that this formula is intuitive: the cross product measures the surface area on the sphere covered by a small piece of the torus $\mathrm d k_1 \mathrm d k_2$. So this formula is basically measuring the (signed) surface area covered by the torus on the sphere, so if it equals the area of the sphere we know the torus winds around once.)
In this case you see this topological invariant can take any integer value. In fact this corresponds to all the integer quantum hall states. More generally we don't need to map to $S^2$ (this is particular to the two-bands case). In general it can be some space $X$. Then to figure out the number of topological phases we need to know all topologically distinct maps $T^2 \to X$. But in practice people instead look at the topologically distinct maps $S^2 \to X$. This is for two good reasons:


*

*For any map $S^2 \to X$ with winding number $\gamma$ you can easily construct a map $T^2 \to X$ with that same winding number (basically by using the above map $T^2 \to S^2$ we just described). Moreover it turns out that the non-trivial maps from $T^2 \to X$ that you cannot get from $S^2 \to X$ are usually less interesting.

*Mathematicians love classifying the number of topologically distinct maps from spheres into spaces, called the homotopy groups of a space. So now we've translated our problem into something we can solve with Google.


Case $ d = 1$: Now we have a map $T^1 \to S^2$. Note that $T^1 = S^1$ so such a map must be topologically trivial: if you put a closed string on the surface of a sphere, you can always continuously shrink it to a point. So no topological phases in 1D... Unless we place further restrictions on $H_{\boldsymbol k}$. For example if we demand that our Hamiltonian must be invariant under complex conjugation, then the $\sigma_y$ component must be zero, i.e. $\boldsymbol n_{\boldsymbol k} = \left(n^x_{\boldsymbol k},0,n^z_{\boldsymbol k} \right)$. So now we effectively have the map $T^1 \to S^1$. But this is mapping the circle to the circle, which can clearly have non-trivial winding number! Similar to above, this is now calculated by
$$ \propto \int_{T^1} \mathrm d k \; \boldsymbol n_{\boldsymbol k} \cdot \left( \nabla \times \boldsymbol n_{\boldsymbol k} \right) $$
So we see that as long as we enforce time reversal invariance, we can have topological band insulators in $d= 1$. These are usually referred to as topological insulators (in one dimension). This is different from the integer quantum hall states which do not need any symmetry protection (although that is not entirely clear from the above $d=2$ analysis, since I did presume translation symmetry and charge conservation -- it turns out these are not essential).
Topological invariants for (non-interacting) semi-metals
I will keep this part short. Partly because I am running out of time, but partly because it will soon become really obvious :) There is only one crucial realization. When defining the above invariants we crucially used the fact our system was gapped, since that meant $\boldsymbol n_{\boldsymbol k} \neq 0$ which allowed us to replace $\mathbb R^3$ by $S^2$ et cetera. None of the topological analysis could have gone through otherwise: any map to $\mathbb R^3$ is topologically trivial. The key insight is that for semi-metals we only have a finite number of points in the Brillouin zone that are gapless. And around each point we can take a hypersurface surrounding it, and on this hypersurface our system is gapped and we can then calculate our above topological invariants. Moreover it is not hard to show that this number is independent of the details of our hypersurface: what only matters is the number of gapless points it encloses. Let's be more exact:
Case $ d = 3$: This is the case Witten is working with in his notes. Take such a three-dimensional semi-metal, find one of the ``bad points'' (i.e. one of the gapless points) and choose a spherical surface $S^2$ around it. By restricting our $\boldsymbol n_{\boldsymbol k}$ to this surface, we now effectively have a map $S^2 \to S^2$. So now we can again use the above formula (which is also the formula you write down in your post, now over $S^2$ instead of $T^2$). So each gapless point now has a well-defined topological number associated to it! (Moreover that is how Witten explains the Nielsen-Ninomiya theorem: to each point we can associate such a gapped topological invariant, and it is then not hard to show that the total sum must be zero--since enclosing all gapless points is equivalent to enclosing none (draw a torus to convince yourself!).)
Case $ d = 2$: Exactly the same thing goes through: take graphene, a two-dimensional semi-metal. Around each gapless point we can take a hypersurface (now a circle...) and measure our above invariant for one-dimensional gapped systems. This again gives the formula you quote. Note that for the same reason as above this would have been trivial if we allowed for all Pauli spin components, but we again get a well-defined topological invariant if we force our Hamiltonian to be invariant under complex conjugation. If you think about it, this in fact explains why graphene needs time reversal symmetry to protect its gapless points! :)
