  A study of the associated production of a Z boson and a charm quark jet (Z +
c), and a comparison to production with a b quark jet (Z + b), in pp collisions
at a centre-of-mass energy of 8 TeV are presented. The analysis uses a data
sample corresponding to an integrated luminosity of 19.7 fb$^{-1}$, collected
with the CMS detector at the CERN LHC. The Z boson candidates are identified
through their decays into pairs of electrons or muons. Jets originating from
heavy flavour quarks are identified using semileptonic decays of c or b
flavoured hadrons and hadronic decays of charm hadrons. The measurements are
performed in the kinematic region with two leptons with $p_{\rm T}^{\ell} > $
20 GeV, ${|\eta^{\ell}|} < $ 2.1, 71 $ < m_{\ell\ell} < $ 111 GeV, and heavy
flavour jets with $p_{\rm T}^{{\rm jet}} > $ 25 GeV and ${|\eta^{{\rm jet}}|} <
$ 2.5. The Z + c production cross section is measured to be
$\sigma({\mathrm{p}}{\mathrm{p}} \rightarrow \mathrm{Z} + \mathrm{c} +
\mathrm{X}) {\cal B}(\mathrm{Z} \rightarrow \ell^+\ell^-) = $ 8.8 $ \pm $ 0.5
(stat) $ \pm $ 0.6 (syst) pb. The ratio of the Z + c and Z + b production cross
sections is measured to be $\sigma({\mathrm{p}}{\mathrm{p}} \rightarrow
\mathrm{Z} + \mathrm{c} + \mathrm{X}) / \sigma({\mathrm{p}}{\mathrm{p}}
\rightarrow \mathrm{Z} + \mathrm{b} + \mathrm{X}) = $ 2.0 $ \pm $ 0.2 (stat) $
\pm $ 0.2 (syst). The Z + c production cross section and the cross section
ratio are also measured as a function of the transverse momentum of the Z boson
and of the heavy flavour jet. The measurements are compared with theoretical
predictions.
