What is a ghost number? I am currently studying CFT chapter of Becker,Becker,Schwarz and am trying to understand what the ghost number is in BRST Quantization.
From what I gather BRST Quantization is used to add an extra symmetry to the theory by adding things called ghost fields to the Lagrangian. This symmetry provides you with a nilpotent charge that then allows you to identify physical string states as BRST cohomology classes. 
The book keeps mentioning these quantities called ghost numbers but doesn't explain exactly what they are and how they are affecting the results of certain formulas. The book also mentions a ghost number operator $$U = {1 \over {2\pi i}}\oint {\;:c(z)b(z):} \;dz$$ but doesn't really explain its significance either. Can someone help me understand what these things are and how they are used?
 A: Caveat: The first part of this answer takes a very technical stance on the BRST procedure, and additionally works with a finite-dimensional phase space for convenience. It could appear quite far from the understanding of ghosts in the average application of BRST transformations or ghosts as a tool.

The general conception of ghosts
There are many different levels at which one may discuss the appearance of ghosts, anti-ghosts, and their numbers in constrained Hamiltonian mechanics (which is the same as gauge theories on a Lagrangian level). One of them is partly sketched in this answer of mine, where the BRST operator is exhibited as the differential in the gauge Lie algebra cohomology.
We will look at a slightly different way of looking at ghosts, namely by "extending the phase space", in this answer, although this can be seen as a rephrasing of the Lie algebra cohomology approach in "phase space terms":
The BRST formalism, on an abstract level, seeks to implement the reduction to a constraint surface $\Sigma$ in a phase space $X$ not by solving the constraints $G_a$, but by searching a suitable enlargement of the phase space such that the functions on the enlarged phase space have a graded derivation $\delta$ living on them whose homology computes the functions on the constraint surface, which are the gauge-invariant observables.1
The enlarged phase space is obtained as follows:

*

*A function on the constraint surface $\Sigma$ is given by the quotient of all phase space functions modulo the functions vanishing on the surface. Every function $f$ vanishing on the surface is given by
$$ f = f^a G_a$$
where the $f^a$ are arbitrary phase space functions. If one introduces as many variables $P_a$ as there are constraints, and defines $\delta P_a = G_a$ as well as $\delta z = 0$ for any original phase space variable, then the image of $\delta$ is exactly all functions that vanish on $\Sigma$. For $\delta$ to be graded, $P_a$ has to be taken to be of degree $1$. The degree of a function as simply the degree of it as a polynomial in the $P_a$ is called the anti-ghost number.2


*The $P_a$ are lonely, and they need conjugate variables. These are given by so-called longitudinal 1-forms on the constraint surface, where a longitudinal vector field on the constraint surface is one that is tangent to the gauge orbits. Their duals are 1-forms which are only defined on longitudinal vectors. It should be geometrically intuitive (and it is in fact true) that the longitudinal vector fields are precisely the fields generating the gauge transformations (they are again just another incarnation of the gauge Lie algebra). Therefore, there are as many basic longitudinal 1-forms $\eta^a$ as there are constraints, and as there are anti-ghosts $P_a$. Since there is the natural action $\eta^a(P_b) = \delta^a_b$ by definition of the dual, it is also natural to just define the Poisson bracket on an enlarged phase space with coordinates $(x^i,p_i,\eta^a,P_a)$ by
$$ [\eta^a,P_b] = \delta^a_b$$
so the pairs $(\eta^a,P_a)$ act as additional pairs of canonical variables. The derivation is extended to the $\eta$ simply by $\delta(\eta^a) = 0$. Functions on this enlarged phase space are now assigned a pure ghost number based on their degree in the $\eta$.
Given any function on the enlarged phase space, the ghost number is simply the pure ghost number minus the anti-ghost number.
The nice thing about the ghost number is that it is the charge of a certain generator - it is measured by the operator3
$$ \mathcal{G} := \mathrm{i}\eta^a P_a$$
which fulfills
$$ [f,\mathcal{G}] = \mathrm{i}\operatorname{gh}(f)f$$
for any function of definite ghost number. The ghost number is physically important because being a state of ghost number zero is, together with the condition of being BRST invariant, the necessary and sufficient condition of being a physical state.
Obtaining this condition, however, requires now obtaining the BRST differential by adding another differential $\mathrm{d}$ to $\delta$, and showing that the $\delta + \mathrm{d}$ gives, when "small perturbations" are added to it, the nilpotent operator required for the BRST formalism. (The derivation of this is very technical, and sometimes known as the "theorem of homological perturbation theory") Examining then again the actions of $\mathrm{d},\delta$, one finds that the gauge-invariant functions are precisely those invariant under the BRST operator with zero ghost number, so the quantum theory should also impose this restriction.

1"whose homology computes" is math speak for it being an operator $\delta$, where the gauge-invariant functions are precisely the functions with $\delta(f) = 0$ and where we identify $f$ and $g$ if there is an $h$ such that $\delta(h) = f - g$. Also, this gets a bit more complicated in the case of reducible constraints.
2In the case of irreducible constraints, this already correctly computes the gauge-invariant functions, and one could in principle stop here. However, it is unsatisfactory to have added the $P_a$, but not have suitably conjugate variables for them in the Hamiltonian formalism.
3This definition is the discrete, non-conformal analogon to the expression for $U$ that is written in the question.
Main reference: "Quantization of Gauge Systems" by Henneaux/Teitelboim

The specific case of $bc$-CFT
A general "$bc$-CFT", i.e. a 2D conformal field theory with ghost-like fields is given by the ghost action
$$ \frac{1}{2\pi}\left(b(z)\bar\partial c(z) + b(z)\partial c(z)\right)$$
when the fields $b$ and $c$ have conformal weights $h_b$ and $h_c = 1 - h_b$, respectively. Phase space functions with ghost number zero translate now to operators with conformal weight $1$ (since they have equal numbers of ghosts and anti-ghosts in them, and the weight behaves additively).
This shows that primary physical states (by the state-field correspondence of 2D CFTs) in such a theory must necessarily have conformal weight $1$. This is of importance in string theory, where a $bc$-CFT with $h_b = 2$ is naturally added to the $X$-CFT of the worldsheet fields. For a generic CFT, all possible primaries could, in principle, be physical states, but the BRST procedure forces ghost number zero states, i.e. fields with weight $1$, as the only allowed physical states.
A: In the conformal field theory on the plane, you need to define an inner product in the space of states of your theory. In bosonic string theory, the space of states i.e. the Hilbert space of the theory $\mathcal{H}$ is the space of the representation of Virassoro algebra:
$${\bf Vir} \longrightarrow \mathcal{H}$$
In the radial quantization of CFT on the complex plane, to every state in the Hilbert space of the theory, one can associate a local operator on the complex plane, the so-called operator-state correspondence. The BPZ inner product on this Hilbert space can be defined. The first thing is to define the asymptotic states $|0\rangle$ and $\langle0|$.
$$|0\rangle \iff \text {Identity operator}\,\,\hat{I}\,\, \text{at the origin}\,\,z=0$$
$$\langle0| \iff \text {Identity operator}\,\,\hat{I}\,\, \text{at infinity}\,\,z=\infty$$
These two can be related by a conformal transformation $z\longrightarrow\widetilde{z}=-\frac{1}{z}$. It can be shown that under this conformal transformation the modes $\hat{\alpha}_n$ of a field $\Phi$ of conformal dimension $h_{\Phi}$ transforms as:
$$\hat{\alpha}_n \iff (-1)^{h_{\Phi}+n}\hat{\alpha}_{-n}$$
So under the conformal transformation we have the following:
$$\hat{\alpha}_n|0\rangle=0 \iff \langle0|\hat{\alpha}_{-n}=0 \tag{1}$$
This, for the Virasoro algebra, implies that $L_{-1}$, $L_0$ and $L_1$ and their anti-holomorphic counterparts $\overline{L}_{-1}$, $\overline{L}_0$ and $\overline{L}_1$ annihilate both $|0\rangle$ and $\langle0|$. But these modes generates the group ${\bf SL}(2,\mathbb{C})$, the group of global conformal transformation on Riemann sphere. Thus $|0\rangle$ is knows as ${\bf SL}(2,\mathbb{C})$-invariant vacuum. 
On the other hand, using $(1)$ it can be shown that $b_{-1}$, $b_0$ and $b_1$ also annihilate both $|0\rangle$ and $\langle0|$. Canonical commutation relation of the $bc$-system shows that:
$$\{b_n,c_{-n}\}|0\rangle=|0\rangle\ne0$$
so the modes $c_{-1}$, $c_0$ and $c_1$ annihilate none of the $\rvert0\rangle$ and $\langle0\rvert$. The first non-zero matrix element for the $bc$-system on the Riemann sphere is thus:
$$\langle0\lvert c_{-1}c_0c_1\rvert0\rangle\ne0$$
The BPZ conjugation i.e. relation (1) violates the ghost number by 3 units. The action of the $bc$-system has the following ghost number symmetry:
$$\delta b=-i\epsilon b \qquad \delta c=i\epsilon c$$
The corresponding current is:
$$j_z(z)=-:b_{zz}(z)c^z(z):$$
In which $:\cdots:$ denotes normal ordering. 
The origin of the violation of ghost number described above is a geometrical one. $j$ is the fermion number current of chiral fermions which have non-converntial integer spin (the $b$ and $c$ both have integer spin.) So it has gravitational anomaly:
$$\partial_{\overline{z}}j_z=-\frac{1}{2}(2\lambda-1)\sqrt{g}R$$
In which $\lambda$ is the conformal dimension of $b$. By integrating this, one can see that the ghost number violation on a genus $g$ Riemann surface (worldsheet of closed string theory) is $3(g-1)$. The importance of ghost current is that it determines the non-zero S-matrix elements of the CFT.
