TITLE: Number of spin structures
QUESTION [7 upvotes]: I am probably missing something obvious, but still...
Consider an oriented Riemannian $n$-dimensional vector bundle $\pi: E\rightarrow X$ over compact manifold $X$ with $\omega_2(E)=0$ so it has spin structures. Let $P_{SO}(E)$ denote the associated principal $SO_n$ frame bundle. We would like to count the number of different spin structures over $E$.
$1)$ From the fibration $SO_n\xrightarrow{i}P_{SO}(E)\xrightarrow{\pi}X$ we have an exact sequence 
$0\rightarrow H^1(X, \mathbb{Z}_2)\xrightarrow{{\pi}^*}H^1(P_{SO}(E), \mathbb{Z}_2)\xrightarrow{i^*}H^1(SO_n , \mathbb{Z}_2)$ from which we see that the number of different spin structures over $E$ is $H^1(X, \mathbb{Z}_2)$. 
$2)$ On the other hand the short exact sequence $0\rightarrow\mathbb{Z}_2\rightarrow Spin_n\rightarrow SO_n\rightarrow 1$ gives an exact sequence $H^0(X, SO_n)\xrightarrow{\delta} H^1(X, \mathbb{Z}_2)\rightarrow H^1(X, Spin_n)\rightarrow H^1(X, SO_n)$ from which the number of different spin-structures over $E$ is $H^1(X , \mathbb{Z}_2)/\delta(H^0(X, SO_n))$.
So why do we have different answers for the same object?

REPLY [12 votes]: Your first answer is correct, and the second one is almost correct, but the problem is that they count different things:
In the first case, you count all twofold covers of $P = P_{SO} E$ that restrict to a nontrivial cover of each fibre. In other words, you count $Spin (n)$-bundles $Q$, together with an isomorphism $\phi:Q \times_{Spin(n)} SO(n) \cong P$ (up to isomorphism of $(P,\phi)$). Here $Q \times_{Spin(n)} SO(n)$ is just a different way to write $Q/\mathbb{Z}_2$.
This is the usual notion of a spin structure on $E$. 
Your second answer (correctly) counts the number of $Spin (n)$-principal bundles $Q \to X$ such that $Q /\mathbb{Z}_2 $ \emph{admits} an isomorphism with $P$.
The point is that an abstract $Spin (n)$-bundle $Q \to X$ can yield many different spin structures on $P = Q/\mathbb{Z}_2$. Say if $P$ is trivial, then the set of homotopy classes of isomorphisms $Q /\mathbb{Z}_2 \to P$ is in bijection with $[X;SO(n)]$. This accounts for the division by the image $\delta$ in your second answer. 
For nontrivial $P$, your second answer is not quite correct, as your exact sequence is only a sequence of sets.
To see this is an example, let $X=S^1$ and $n \geq 3$. As $SO(n)$ $Spin(n)$ are connected, all principal bundles on $S^1$ are trivial. In this case $H^0 (X;SO(n))=[S^1;SO(n)]=Z/2$; $\delta$ is an isomorpism and the two terms to the left are null. The generator of $[S^1;SO(n)]$ gives an isomorphism of the trivial $SO(n)$-bundle that transforms the two spin structures into each other.