  We have determined the production cross sections of the $X(3872)$ state in
the reactions $\bar D D\to\pi X$, $\bar D^* D\to \pi X$ and $\bar D^* D^*\to\pi
X$, information which is useful for studies of the $X(3872)$ meson abundance in
heavy ion collisions. We construct a formalism considering $X$ as a molecular
bound state of $\bar D^0 D^{*0} - \textrm{c.c}$, $D^- D^{*+} - \textrm{c.c}$
and $D^-_s D^{*+}_s - \textrm{c.c}$. To obtain the amplitudes related to these
processes we have made use of effective field Lagrangians. The evaluation of
the cross section of the processes involving $D^*$ meson(s) requires the
calculation of an anomalous vertex, $X\bar D^* D^*$, which has been obtained by
considering triangular loops motivated by the molecular nature of $X(3872)$.
Proceeding in this way, we have evaluated the cross section for the reaction
$\bar D^* D\to \pi X$, and find that the diagrams involving the $X\bar D^* D^*$
vertex give a large contribution. Encouraged by this finding we estimate the
$X\bar D^* D^*$ coupling, which turns out to be $1.95\pm 0.22$. We then use it
to obtain the cross section for the reaction $\bar D^* D^*\to\pi X$ and find
that, in this case too, the $X\bar D^* D^*$ vertex is relevant. We also discuss
the role of the charged components of $X$ in the determination of the
production cross sections.
