1 Introduction

The study of the production of hadrons containing heavy quarks, i.e. charm and beauty, in proton–proton (pp) collisions at LHC energies is a sensitive test of Quantum Chromodynamics (QCD) calculations with the factorisation approach. In this scheme, the transverse momentum (\(p_{\mathrm{T}}\)) differential production cross sections of hadrons containing charm or beauty quarks are calculated as a convolution of three terms: (i) the parton distribution functions (PDFs) of the incoming protons, (ii) the partonic scattering cross section, calculated as a perturbative series in powers of the strong coupling constant \(\alpha _{\mathrm{s}}\), and (iii) the fragmentation function, which parametrises the non-perturbative evolution of a heavy quark into a given species of heavy-flavour hadron. Factorisation is implemented in terms of the squared momentum transfer \(Q^2\) (collinear factorisation) [1] or of the partonic transverse momentum \(k_{\mathrm{T}}\) [2]. At LHC energies, calculations based on collinear factorisation are available in the general-mass variable-flavour-number scheme, GM-VFNS [3,4,5,6], and in the fixed order plus next-to-leading logarithms approach, FONLL [7, 8], both of them having next-to-leading order (NLO) accuracy with all-order resummation of next-to-leading logarithms. Within the \(k_{\mathrm{T}}\)-factorisation framework, heavy-flavour production cross-section calculations exist only at leading order (LO) approximation in \(\alpha _{\mathrm{s}}\) [2, 9, 10]. All these calculations describe within uncertainties the production cross sections of D and B mesons measured in pp and \(\mathrm{p\overline{p}}\) collisions in different kinematic regions at centre-of-mass energies from 0.2 to 13 TeV (see e.g. Ref. [11] and references therein). In the case of charm production, the uncertainties on the theoretical predictions, which are dominated by the choice of the scales of the perturbative calculation (e.g. the factorisation and renormalisation scales), are significantly larger than the uncertainties on the measured data points [12,13,14,15,16,17,18,19,20,21,22,23]. However, as pointed out in Ref. [24], in the ratios of cross sections at different LHC energies and in different rapidity intervals the uncertainty due to choice of the factorisation and renormalisation scales becomes subdominant with respect to the uncertainty on the PDFs, thus making the measurement sensitive to the gluon PDF at small Bjorken-x values. A precise measurement of the D-meson production cross sections down to \(p_{\mathrm{T}}=0\) can therefore provide important constraints to perturbative QCD (pQCD) calculations and to low-x gluon PDFs. Furthermore, D-meson measurements in pp collisions represent an essential reference for the study of effects induced by cold and hot strongly-interacting matter in the case of proton–nucleus and nucleus–nucleus collisions (see e.g. the recent reviews [11, 25, 26]).

In this article, the measurements of the \(p_{\mathrm{T}}\)-differential production cross sections of prompt \({\mathrm{D}}^0\), \({\mathrm{D}}^+\), \({\mathrm{D}}^{*+}\), and \({\mathrm{D}}_{\mathrm{s}}^+\) mesons (as average of particles and anti-particles) in pp collisions at the centre-of-mass energy \(\sqrt{s}=5.02~\mathrm {TeV}\) are reported together with their ratios. The measurements are performed at mid-rapidity (\(|y|<0.5\)) in the transverse momentum intervals \(0<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({\mathrm{D}}^0\) mesons, \(1<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({\mathrm{D}}^+\) and \({\mathrm{D}}^{*+}\) mesons, and \(2<p_{\mathrm{T}}<24~\mathrm {GeV}/c\) for \({\mathrm{D}}^+_\mathrm{s}\) mesons. The \(p_{\mathrm{T}}\)-integrated D-meson production cross sections per unit of rapidity is also reported for each D-meson species. The ratios of the \({\mathrm{D}}^0\), \({\mathrm{D}}^+\), and \({\mathrm{D}}^{*+}\)-meson production cross sections measured at \(\sqrt{s}=7~\mathrm {TeV}\) [27] and \(\sqrt{s}=5.02~\mathrm {TeV}\) are presented as well, and compared to FONLL calculations. Finally, the ratios of \({\mathrm{D}}^0\)-meson production cross sections at mid- and forward rapidity are also reported, using the measurements done at forward rapidity by the LHCb collaboration in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) [22].

2 Experimental apparatus and data sample

The ALICE experimental apparatus is composed of a set of detectors for particle reconstruction and identification at mid-rapidity, embedded in a large solenoidal magnet that provides a \(B = 0.5~\mathrm {T}\) field parallel to the beams. It also includes a forward muon spectrometer and various forward and backward detectors for triggering and event characterisation. A complete description and an overview of their typical performance in pp, p–Pb, and Pb–Pb collisions is presented in Refs. [28, 29].

The tracking and particle identification capabilities of the ALICE central barrel detectors were exploited to reconstruct the D-meson decay products at mid-rapidity. The Inner Tracking System (ITS), consisting of six cylindrical layers of silicon detectors, is used to track charged particles and to reconstruct primary and secondary vertices. The Time Projection Chamber (TPC) provides track reconstruction with up to 159 three-dimensional space points per track, as well as particle identification via the measurement of their specific ionisation energy loss dE/dx. The particle identification capabilities of the TPC are complemented by the Time-Of-Flight detector (TOF), which is used to measure the flight time of the charged particles from the interaction point. These detectors cover the pseudorapidity interval \(|\eta | < 0.9\). The V0 detector, composed of two arrays of 32 scintillators each, covering the pseudorapidity ranges \(-3.7< \eta < -1.7\) and \(2.8< \eta < 5.1\), provides the minimum-bias (MB) trigger used to collect the data sample. In addition, the timing information of the two V0 arrays and the correlation between the number of hits and track segments in the two innermost layers of the ITS, consisting of Silicon Pixel Detectors (SPD), was used for an offline event selection, in order to remove background due to the interaction between one of the beams and the residual gas present in the beam vacuum tube. In order to maintain a uniform acceptance in pseudorapidity, collision vertices were required to be within \(\pm 10~\mathrm {cm}\) from the centre of the detector in the beam-line direction. The pile-up events (less than 1%) were rejected by detecting multiple primary vertices using track segments defined with the SPD layers. After the aforementioned selections, the data sample used for the analysis consists of about 990 million MB events, corresponding to an integrated luminosity \(L_\mathrm{int} = (19.3 \pm 0.4)~\hbox {nb}^{-1}\), collected during the 2017 pp run at \(\sqrt{s}= 5.02\) TeV.

3 Data analysis

3.1 Analysis with D-meson decay vertex reconstruction

The D mesons and their charge conjugates were reconstructed via the decay channels \(\mathrm{D}^0 \rightarrow {\mathrm{K}}^-\pi ^+\) (with branching ratio, \(\mathrm{BR}\,{=}\,3.89\pm 0.04\%\)), \(\mathrm{D}^+\rightarrow {\mathrm{K}}^-\pi ^+\pi ^+\) (\(\mathrm{BR}\,{=}\,8.98\pm 0.28\%\)), \({\mathrm{D}}^{*+} \rightarrow {\mathrm{D}}^0 \pi ^+ \rightarrow {\mathrm{K}}^- \pi ^+ \pi ^+\) (\(\mathrm{BR}\,{=}\,2.63\pm 0.03\%\)), and \({{\mathrm{D}}^{+}_{\mathrm{s}}\rightarrow \phi \pi ^+\rightarrow {\mathrm{K}}^{+} {\mathrm{K}}^{-} \pi ^{+}}\) (\(\mathrm{BR}\,{=}\,2.27\pm 0.08\%\)) [30]. The analysis was based on the reconstruction of decay vertices displaced from the interaction vertex, exploiting the separation of a few hundred \(\upmu \hbox {m}\) induced by the weak decays of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons (\(c\tau \simeq 123\), 312, and \(150 \,\upmu \hbox {m}\), respectively [30]). The \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates were built combining pairs or triplets of tracks with the proper charge, each with \(|\eta | < 0.8\), \(p_{\mathrm{T}}> 0.3~\mathrm {GeV}/c\), at least 70 associated TPC space points, \(\chi ^{2}/\mathrm{ndf} < 2\) in the TPC (where ndf is the number of degrees of freedom involved in the track fit procedure), and at least one hit in either of the two layers of the SPD. The \({{\mathrm{D}}^{*+}}\) candidates were defined by the combination of \({{\mathrm{D}}^0}\) candidates with tracks reconstructed with at least two points in the ITS, including at least one in the SPD, and \(p_{\mathrm{T}}> 80 \,\mathrm {MeV}/c\). As a consequence of these track selection criteria, the acceptance for D mesons decreases rapidly for \(|y|>0.5\) at low \(p_{\mathrm{T}}\) and for \(|y|>0.8\) for \(p_{\mathrm{T}}>5~\mathrm {GeV}/c\). Therefore, only D-meson candidates within a fiducial acceptance region, \(|y| < y_{\mathrm{fid}}(p_{\mathrm{T}})\), were selected. The \(y_{\mathrm {fid}}(p_{\mathrm{T}})\) factor was defined as a second-order polynomial function, increasing from 0.5 to 0.8 in the transverse momentum range \(0< p_{\mathrm{T}}< 5~\mathrm {GeV}/c\), and a constant term, \(y_{\mathrm {fid}}=0.8\), for \(p_{\mathrm{T}}> 5~\mathrm {GeV}/c\).

In order to reduce the combinatorial background and to increase the signal-over-background ratio (S / B), geometrical selections on the \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson decay topology were applied. In the \(\mathrm{D}^{*+} \rightarrow {\mathrm{D}}^0 \pi ^+\) case, the decay vertex cannot be resolved from the primary vertex and geometrical selections were applied on the secondary vertex topology of the produced \({{\mathrm{D}}^0}\) mesons. The selection requirements, tuned to provide a large statistical significance for the signal and to keep the selection efficiency as high as possible, were mainly based on the displacement of the tracks from the primary vertex (\(d_0\)), the distance between the D-meson decay vertex and the primary vertex (decay length, L), and the pointing of the reconstructed D-meson momentum to the primary vertex. Additional selection criteria, already introduced in Refs. [27, 31], were applied to \({{\mathrm{D}}^+}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates. These selections reject both combinatorial background and D mesons from beauty-hadron decays (selection efficiency reduced by 50% at high \(p_{\mathrm{T}}\)), denoted as “feed-down” in the following. For the \({{\mathrm{D}}^+_{\mathrm{s}}}\)-candidate selection, one of the two pairs of opposite-sign tracks was required have a reconstructed \({{\mathrm{K}}^+{\mathrm{K}}^-}\) invariant mass within \(\pm 10~\mathrm {MeV}/c^{2}\) with respect to the PDG world average of the \(\phi \) meson [30].

Further reduction of the combinatorial background was obtained by applying particle identification (PID) to the decay tracks, except for the soft-pion track coming from \(\mathrm{D}^{*+} \rightarrow {\mathrm{D}}^0 \pi ^+\) decays. Pions and kaons were identified requiring compatibility with the respective particle hypothesis within three standard deviations (\(3\,\sigma \)) between the measured and the expected signals for both the TPC \(\mathrm {d}E/\mathrm {d}x\) and the time-of-flight. Tracks without TOF hits were identified using only the TPC information with a \(3\,\sigma \) selection, except for the decay products of \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates with \(p_{\mathrm{T}}<6~\mathrm {GeV}/c\), for which a \(2\,\sigma \) selection was needed to suppress the larger fraction of combinatorial background in this mode.

The D-meson raw yields, including both particles and antiparticles, were obtained from binned maximum likelihood fits to the invariant-mass (M) distributions of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates and to the mass difference \(\Delta M = M (\mathrm {K} \pi \pi ) - M(\mathrm {K} \pi )\) distributions of \({{\mathrm{D}}^{*+}}\) candidates, in the transverse-momentum intervals \(0.5<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({\mathrm{D}}^0\) mesons, \(1<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({\mathrm{D}}^+\) and \({\mathrm{D}}^{*+}\) mesons, and \(2<p_{\mathrm{T}}<24~\mathrm {GeV}/c\) for \({\mathrm{D}}^+_\mathrm{s}\) mesons. The signal extraction was performed in finer \(p_{\mathrm{T}}\) bins with respect to the previous measurements at \(\sqrt{s}=7~\mathrm {TeV}\) [27], allowing for a more detailed description of the cross-section \(p_{\mathrm{T}}\) shape. The fit function was composed of a Gaussian for the description of the signal and of an exponential term for the background of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates, and of a threshold function for \({{\mathrm{D}}^{*+}}\) candidates [27]. For the \({{\mathrm{D}}^0}\) meson, the contribution of signal candidates present in the invariant-mass distribution with the wrong decay-particle mass assignment (reflections) was included in the fit. It was modelled based on the invariant-mass distributions of the reflected signal in the simulation, which were parametrised as the sum of two Gaussian functions. The contribution of reflections is about \(2\%-3\%\) of the raw signal depending on \(p_{\mathrm{T}}\). For the \(M(\mathrm{KK}\pi )\) distribution, an additional Gaussian was used to describe the signal of the decay \(\mathrm{D}^+\rightarrow {\mathrm{K}}^+{\mathrm{K}}^-\pi ^+\), with a branching ratio of (\(9.51\pm 0.34)\times 10^{-3}\) [30], present on the left side of the \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson signal. Figure 1 shows the invariant mass (mass-difference) distributions together with the result of the fits, in \(1.5<p_{\mathrm{T}}<2~\mathrm {GeV}/c\), \(16<p_{\mathrm{T}}<24~\mathrm {GeV}/c\), \(7<p_{\mathrm{T}}<7.5~\mathrm {GeV}/c\), and \(3<p_{\mathrm{T}}<4~\mathrm {GeV}/c\) intervals for \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates, respectively. The statistical significance of the observed signals, \(S/\sqrt{(S+B)}\), varies from 4 to 28, depending on the meson species and on the \(p_{\mathrm{T}}\) interval. The S / B values obtained applying the selections described above are 0.01–1.85 for \({{\mathrm{D}}^0}\), 0.5–2.2 for \({{\mathrm{D}}^+}\), 0.3–4.2 for \({{\mathrm{D}}^{*+}}\), and 0.3–2.2 for \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons, depending on \(p_{\mathrm{T}}\).

Fig. 1
figure 1

Invariant-mass (mass-difference) distributions of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates and charge conjugates in \(1.5<p_{\mathrm{T}}<2~\mathrm {GeV}/c\), \(16<p_{\mathrm{T}}<24~\mathrm {GeV}/c\), \(7<p_{\mathrm{T}}<7.5~\mathrm {GeV}/c\), and \(3<p_{\mathrm{T}}<4~\mathrm {GeV}/c\) intervals, respectively. The blue solid lines show the total fit functions as described in the text and the red dashed lines are the combinatorial-background terms. In case of \({{\mathrm{D}}^0}\), the grey dashed line represents the combinatorial background with the contribution of the reflections. The values of the mean (\(\mu \)) and the width (\(\sigma \)) of the signal peak are reported together with the signal counts (S) and the signal over background ratio (S / B) in the mass interval (\(\mu -3\sigma ,\mu +3\sigma \)). The reported uncertainties are only the statistical uncertainties from the fit

The \(p_{\mathrm{T}}\)-differential cross section of prompt D mesons in each \(p_{\mathrm{T}}\) interval was computed as:

$$\begin{aligned}&\frac{{\mathrm{d}}^2 \sigma ^\mathrm{D}}{{\mathrm{d}}p_{\mathrm{T}}{\mathrm{d}} y}= \frac{1}{c_{\Delta y}(p_{\mathrm{T}})\Delta p_{\mathrm{T}}}\cdot \frac{1}{\mathrm{BR}}\nonumber \\&\quad \cdot \frac{\frac{1}{2} \, \left. f_{\mathrm{prompt}}(p_{\mathrm{T}})\cdot N^\mathrm{D+{\overline{D}},raw}(p_{\mathrm{T}})\right| _{|y|<y_{\mathrm{fid}}(p_{\mathrm{T}})}}{ (\mathrm{Acc}\times \varepsilon )_{\mathrm{prompt}}(p_{\mathrm{T}})} \frac{1}{L_\mathrm{int}} \,. \end{aligned}$$
(1)

The raw yield values (sum of particles and antiparticles, \(N^{\mathrm{D}+\overline{\mathrm{D}},\mathrm{raw}}\)) were divided by a factor of two and multiplied by the prompt fraction \(f_{\mathrm{prompt}}\) to obtain the charged-averaged yields of prompt D mesons. Furthermore, they were divided by the acceptance-times-efficiency of prompt D mesons \((\mathrm{Acc} \times \varepsilon )_{\mathrm{prompt}}\), the BR of the decay channel, the width of the \(p_{\mathrm{T}}\) interval (\(\Delta p_{\mathrm{T}}\)), the correction factor for the rapidity coverage \(c_{\Delta y}\), and the integrated luminosity \(L_{\mathrm{int}}=N_{\mathrm{ev}} / \sigma _{\mathrm{MB}} \), where \(N_{\mathrm{ev}}\) is the number of analysed events and \(\sigma _{\mathrm{MB}}=(50.9\pm 0.9)\) mb is the cross section for the MB trigger condition [32].

The \((\mathrm{Acc} \times \varepsilon )\) correction was obtained simulating pp collisions with the PYTHIA 6.4.25 event generator [33] (Perugia-11 tune [34]), and propagating the generated particles through the detector using GEANT3 [35]. Each simulated PYTHIA pp event contained a \(\mathrm{c}\overline{\mathrm{c}}\) or \(\mathrm{b}\overline{{\mathrm{b}}}\) pair, and D mesons were forced to decay into the hadronic channels of interest for the analysis. The luminous region distribution and the conditions of all the ALICE detectors in terms of active channels, gain, noise level and alignment, and their evolution with time during the data taking, were taken into account in the simulations.

Figure 2 shows the \(({\mathrm{Acc}} \times \varepsilon )\) as a function of \(p_{\mathrm{T}}\) for prompt and feed-down \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons within the fiducial acceptance region. The average larger displacement from the primary vertex of beauty hadrons due to their long lifetime (\(c\tau \approx 500~\upmu \)m [30]) results in a more efficient selection of feed-down D mesons compared to prompt D mesons in most of the \(p_{\mathrm{T}}\) intervals.

The correction factor for the rapidity acceptance \(c_{\Delta y}\) was computed with the PYTHIA 6.4.25 event generator with Perugia-11 tune. It was defined as the ratio between the generated D-meson yield in \(\Delta y = 2\,y_{\mathrm{fid}}\), and that in \(|y|<0.5\). It was checked that calculations of the \(c_{\Delta y}\) correction factor based on FONLL pQCD calculations [8] or on the assumption of uniform D-meson rapidity distribution in \(|y|<y_{\mathrm{fid}}\) would give the same result, because both in PYTHIA and in FONLL the D-meson yield is uniform within 1% in the range \(|y|<0.8\).

Fig. 2
figure 2

Acceptance \(\times \) efficiency for \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons, as a function of \(p_{\mathrm{T}}\). The efficiencies for prompt (solid lines) and feed-down (dotted lines) D mesons are shown

The \(f_{\mathrm{prompt}}\) fraction was calculated similarly to previous measurements (see e.g. Refs. [27, 31]) using the beauty-hadron production cross sections from FONLL calculations [7, 36], the \(\mathrm {beauty~hadron} \rightarrow \mathrm {D} + X\) decay kinematics from the EvtGen package [37], and the efficiencies for feed-down D mesons reported in Fig. 2. The values of \(f_{\mathrm{prompt}}\) range between 0.8 and 0.96 depending on D-meson species and \(p_{\mathrm{T}}\).

3.2 Analysis without D-meson decay vertex reconstruction

Fig. 3
figure 3

Invariant-mass distributions of \(\mathrm{D}^0 \rightarrow {\mathrm{K}}^-\pi ^+\) candidates (and charge conjugates) for \(0<p_{\mathrm{T}}<0.5~\mathrm {GeV}/c\). The left panel displays the invariant-mass distribution of all opposite-sign \(\hbox {K}\pi \) pairs (or unlike sign, ULS in the legend) together with the background distribution estimated with the track-rotation technique. The right panel shows the invariant-mass distributions after subtraction of the background from the track-rotation technique. The blue solid line shows the total fit function as described in the text and the grey dashed line is the residual background after the subtraction of the background from the track-rotation technique

A different analysis method, not based on geometrical selections of the displaced decay-vertex topology, was developed for the two-body decay \(\mathrm{D}^0 \rightarrow {\mathrm{K}}^-\pi ^+\) (and its charge conjugate) in order to extend the measurement of the cross section down to \(p_{\mathrm{T}}=0\) [19]. Indeed, the poor track impact parameter resolution at very low \(p_{\mathrm{T}}\) and the small Lorentz boost limit the effectiveness of the selections based on the displaced decay-vertex topology. Furthermore, geometrical selections based on the displacement of the \({{\mathrm{D}}^0}\)-meson decay vertex tend to enhance the contribution of feed-down D mesons, increasing the related systematic uncertainty. This alternative analysis technique is mainly based on particle identification and on the estimation and subtraction of the combinatorial background.

The \({{\mathrm{D}}^0}\) candidates were formed combining pairs of kaons and pions tracks with opposite charge sign, \(|\eta |<0.8\), and \(p_{\mathrm{T}}>0.3~\mathrm {GeV}/c\). Track selection and pion and kaon identification were performed with the same strategy used in the analysis with decay-vertex reconstruction described in Sect. 3.1. The resulting \({{\mathrm{D}}^0}\) and \(\overline{{{\mathrm{D}}^0}}\) candidates were selected by applying the same fiducial acceptance selection \(|y|<y_{\mathrm{fid}}(p_{\mathrm{T}})\) adopted for the analysis with decay-vertex reconstruction. The invariant-mass distribution of \(\hbox {K}\pi \) pairs was obtained in fourteen transverse momentum intervals, in the range \(0<p_{\mathrm{T}}<12~\mathrm {GeV}/c\). The background distribution was estimated with the track-rotation technique. For each \({{\mathrm{D}}^0}\) (and \(\overline{{{\mathrm{D}}^0}}\)) candidate, up to 19 combinatorial-background-like candidates were created by rotating the kaon track by different angles in the range between \(\frac{\pi }{10}\) and \(\frac{19\pi }{10}\) radians in azimuth. The left hand panel of Fig. 3 shows the invariant-mass distribution of opposite-sign \(\hbox {K}\pi \) pairs together with that of the background estimated with the track-rotation technique in the interval \(0<p_{\mathrm{T}}<0.5~\mathrm {GeV}/c\).

After subtracting the background distribution from the opposite-sign \(\hbox {K}\pi \) invariant-mass distribution, the \({{\mathrm{D}}^0}\)-meson raw signal (sum of particle and antiparticle contributions) was extracted from the resulting distribution via a fit to the background-subtracted invariant-mass distribution, as reported in Fig. 3 (right panel) for the interval \(0<p_{\mathrm{T}}<0.5~\mathrm {GeV}/c\). In the fit function, the signal was modelled with a Gaussian term, while the residual background with second-order polynomial function. The statistical significance of the signal extracted in \(0<p_{\mathrm{T}}<0.5~\mathrm {GeV}/c\) (\(0.5<p_{\mathrm{T}}<1~\mathrm {GeV}/c\)) is \(S/\sqrt{S+B}=5.2~(8.0)\).

The \(({{\mathrm{Acc}}}\times \varepsilon )\) correction factors of prompt and feed-down \({{\mathrm{D}}^0}\) mesons were determined from the same Monte Carlo simulations as those used for the analyses with decay-vertex reconstruction. The \(({{\mathrm{Acc}}}\times \varepsilon )\) obtained with the two different analyses are compared in Fig. 4. For the analysis that does not exploit the selections on the \({{\mathrm{D}}^0}\)-meson decay vertex, the efficiency is higher by a factor of about 30 (3) at low (high) \(p_{\mathrm{T}}\) and almost independent of \(p_{\mathrm{T}}\). The mild increase with the increasing \(p_{\mathrm{T}}\) is mainly determined by the geometrical acceptance of the detector. Unlike in the analysis with decay-vertex reconstruction, the efficiency is the same for prompt \({{\mathrm{D}}^0}\) and for feed-down \({{\mathrm{D}}^0}\), as expected when no selection is made on the displacement of the \({{\mathrm{D}}^0}\)-meson decay vertex from the interaction point.

Fig. 4
figure 4

Product of acceptance and efficiency of \(\mathrm{D}^0 \rightarrow {\mathrm{K}}^-\pi ^+\) (and charge conjugates)

The prompt fraction to the \({{\mathrm{D}}^0}\)-meson raw yield, \(f_{\mathrm{prompt}}\), was estimated with the same FONLL-based approach used for the analysis with decay-vertex. The resulting \(f_{\mathrm{prompt}}\) values decrease with increasing \(p_{\mathrm{T}}\), from a value of about 0.95 for \(p_{\mathrm{T}}<4~\mathrm {GeV}/c\) to about 0.90 in the interval \(8<p_{\mathrm{T}}<12~\mathrm {GeV}/c\) and are larger compared to the analysis with decay-vertex reconstruction, due to the fact that the feed-down component is not enhanced by the topological selection criteria.

3.3 Measurement of the fraction of prompt D mesons

In order to cross-check the values obtained with the FONLL-based method of Sect. 3.1, the fractions of prompt \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons in the raw yields, \(f_{\mathrm{prompt}}\), were measured exploiting the different shapes for the distributions of the transverse-plane impact parameter to the primary vertex (\(d_0\)) of prompt and feed-down D mesons. The prompt fraction was estimated via an unbinned maximum-likelihood fit of the \(d_0\) distribution of \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates with invariant mass \(|M-M_{\mathrm {D}}|<2 \sigma \) (where \(\sigma \) is the standard deviation of the Gaussian function describing the D-meson signal in the invariant-mass fits), using the fit function

$$\begin{aligned} F(d_0)= & {} S\cdot \left[ (1-f_{\mathrm{prompt}}) F^{\mathrm{feed}\hbox {-}\mathrm{down}} (d_0) \right. \nonumber \\&\quad \left. +\, f_{\mathrm{prompt}} F^{\mathrm{prompt}} (d_0) \right] + B\cdot F^{\mathrm{backgr}}(d_0)\,. \end{aligned}$$
(2)

In this function, S and B are the signal raw yield and background in the selected invariant-mass range, fixed to the values obtained from the invariant-mass fit; \(F^{\mathrm{prompt}} (d_0)\), \(F^{\mathrm{feed}\hbox {-}\mathrm{down}} (d_0)\), and \(F^{\mathrm{backgr}}(d_0)\) are the functions describing the impact-parameter distributions of prompt and feed-down D mesons and background, respectively. The function \(F^{\mathrm{prompt}}\) is a detector resolution term modelled with a Gaussian and a symmetric exponential term. The function \(F^{\mathrm{feed}\hbox {-}\mathrm{down}}\) is the convolution of a sum of two symmetric exponential functions (\(F^{\mathrm{feed}\hbox {-}\mathrm{down}}_\mathrm{true}\)), which describe the intrinsic impact-parameter distribution of secondary D mesons from beauty-hadron decays, and the detector resolution term (\(F^{\mathrm{prompt}}\)). All the parameters of the \(F^{\mathrm{prompt}}\) and \(F^{\mathrm{feed}\hbox {-}\mathrm{down}}_\mathrm{true}\) functions were fixed in the data fit to the values obtained by fitting the distributions from Monte Carlo simulations, except for the Gaussian width of the detector-resolution term, which was kept free in order to compensate a possible discrepancy between the impact-parameter resolution in the data and in the simulation. The distribution describing the combinatorial background was parameterised with a function composed of a Gaussian and symmetric exponential term (\(F^{\mathrm{backgr}}\)). The parameters were fixed to those obtained by fitting the impact-parameter distribution of background candidates in the side bands of the signal peak in the invariant-mass distributions. Figure 5 (left) shows examples of fits to the impact-parameter distributions of \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons in the transverse-momentum intervals \(3<p_{\mathrm{T}}<4~\mathrm {GeV}/c\) and \(5<p_{\mathrm{T}}<6~\mathrm {GeV}/c\), respectively. For this study, wider \(p_{\mathrm{T}}\) intervals were adopted compared to the analysis, due to the poor quality of the fit when reducing the sample. The \({{\mathrm{D}}^0}\) candidates used in the impact-parameter fit were selected with the same criteria described in Sect. 3.1. For the \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons, the impact-parameter selection, used to extract the raw yield from the invariant-mass distribution, was not applied for this study. In this case, the prompt fraction, \(f_{\mathrm{prompt}}\), was obtained by integrating the functions obtained from the fit in the restricted impact-parameter range used in the analysis.

Fig. 5
figure 5

Left: examples of fits to the impact-parameter distributions of \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) candidates. The curves show the fit functions describing the prompt, feed-down, and background contributions, as well as their sum, as described in the text. Right: fraction of prompt \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-mesons raw yield as a function of \(p_{\mathrm{T}}\) compared to the values obtained with the FONLL-based approach. The results from the data-driven method are shown as square markers with the error bars (boxes) representing the statistical (systematic) uncertainty. The central values of \(f_{\mathrm{prompt}}\) from the FONLL-based approach are shown by the dashed line and their uncertainty by the red boxes

The prompt fraction measured with the fits to the impact-parameter distributions of D-meson candidates has three main sources of systematic uncertainty, namely (i) the assumption on the shape of the impact-parameter distribution for each contribution (prompt D mesons, feed-down D mesons, and combinatorial background); (ii) the uncertainty on the signal and background yields extracted from the invariant-mass fits; and (iii) the consistency of the procedure, evaluated with a Monte Carlo closure test. These uncertainties were estimated with the procedures described in Ref. [19]. The total systematic uncertainty on \(f_{\mathrm{prompt}}\) with the data-driven approach ranges, depending on \(p_{\mathrm{T}}\), are between 1 and 9% for the \({{\mathrm{D}}^0}\) meson, and between 4 and 17% for the \({{\mathrm{D}}^+_{\mathrm{s}}}\) meson.

The prompt fractions in the raw yields of \({{\mathrm{D}}^0}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons measured with the data-driven method are compared to those calculated with the FONLL-based approach in the right panels of Fig. 5 and found to be compatible within uncertainties. For the interval \(24<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) (\(16<p_{\mathrm{T}}<24~\mathrm {GeV}/c\)), given the poor precision of the impact-parameter fit, it was not possible to determine the data-driven prompt fraction for the \({{\mathrm{D}}^0}\) (\({{\mathrm{D}}^+_{\mathrm{s}}}\)) meson.

4 Systematic uncertainties

Systematic uncertainties on the D-meson cross sections were estimated considering the following sources: (i) extraction of the raw yield from the invariant-mass distributions; (ii) track reconstruction efficiency; (iii) D-meson selection efficiency; (iv) PID efficiency; (v) the shape of the \(p_{\mathrm{T}}\) spectrum generated for D mesons in the simulation; (vi) subtraction of the feed-down from beauty-hadron decays. In addition, the uncertainties on the branching ratios and on the integrated luminosity were considered. A summary of the systematic uncertainties is reported in Table 1 for different \(p_{\mathrm{T}}\) intervals.

The systematic uncertainties on the raw yield extraction were evaluated by repeating the fits several hundred times varying the fit interval and the functional form of the background fit function. The same strategy was performed using a bin-counting method, in which the signal yield was obtained by integrating the invariant-mass distribution after subtracting the background, estimated from a fit to the side-bands only. The systematic uncertainty was defined as the RMS of the distribution of the signal yields obtained from all these variations and ranges between 1 and 9% depending on the D-meson species and \(p_{\mathrm{T}}\) interval. This includes for the \({{\mathrm{D}}^0}\) mesons a contribution of about 1% obtained by varying the ratio of the integral of the reflections to the integral of the signal and the shape of the templates used in the invariant-mass fits. For the background estimation of the \({{\mathrm{D}}^0}\)-meson analysis without decay-vertex reconstruction with the track-rotation technique, different configurations of the rotation angle were used. In addition, three alternative approaches were tested to estimate the background distribution: like-sign (LS) pairs, event mixing, and side-band fit [19]. The raw yield values obtained subtracting these alternative background distributions were found to be consistent with those from the default configuration of the track-rotation method within the uncertainty estimated by varying the fit conditions and therefore no additional systematic uncertainty was assigned.

The systematic uncertainty on the track reconstruction efficiency has two different contributions. The first one is estimated by varying the track-quality selection criteria and the second one is estimated by comparing the probability to match the tracks from the TPC to the ITS hits in data and simulation (matching efficiency). To obtain the matching efficiency, the abundances of primary and secondary particles in data were estimated via template fits to the track impact-parameter distributions, where the relative abundances in the simulation were weighted to match those in data [27, 38]. The estimated uncertainty, a quadratic sum of the two contributions, depends on the D-meson \(p_{\mathrm{T}}\) and it ranges from 3 to 5% for the two-body decay of \({{\mathrm{D}}^0}\) mesons and from 3.5 to 7% for the three-body decays of \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons.

The systematic uncertainty on the D-meson selection efficiency originates from imperfections in the simulation of the D-meson decay kinematics and topology and of the resolutions and alignments of detectors in the simulation. For the analyses with decay-vertex reconstruction, the systematic uncertainty was estimated by repeating the analysis with different sets of selection criteria, resulting in a significant modification of the efficiencies, raw yield, and background values. The systematic uncertainties are largest at low \(p_{\mathrm{T}}\) (up to 5%), where the efficiencies are low and vary steeply with \(p_{\mathrm{T}}\), because of the tighter geometrical selections. For the \({{\mathrm{D}}^+_{\mathrm{s}}}\) meson, for which more stringent selection criteria were used, slightly larger uncertainties were estimated, ranging from 5% at high \(p_{\mathrm{T}}\) to 8% at low \(p_{\mathrm{T}}\). In the case of the \({{\mathrm{D}}^0}\)-meson analysis without decay-vertex reconstruction, the stability of the corrected yield was tested against variations of the single-track \(p_{\mathrm{T}}\) selection and no systematic effect was observed.

Table 1 Summary of relative systematic uncertainties on \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) measurements in different \(p_{\mathrm{T}}\) intervals

To estimate the uncertainty on the PID selection efficiency, the analysis was repeated without PID selection for the three non-strange D-meson species and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons with \(p_{\mathrm{T}}>6~\mathrm {GeV}/c\). The resulting cross sections were found to be compatible with those obtained with the PID selection and therefore no systematic uncertainty was assigned. For \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons with \(p_{\mathrm{T}}<6~\mathrm {GeV}/c\) and the \({{\mathrm{D}}^0}\)-meson analysis without decay-vertex reconstruction, an analysis without applying PID selections could not be performed due to the insufficient statistical significance of the signal. The systematic uncertainty for low-\(p_{\mathrm{T}}\) \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons was therefore estimated by comparing the pion and kaon PID selection efficiencies in the data and in the simulation and combining the observed differences using the \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson decay kinematics [31]. A 3% systematic uncertainty was assigned for \(4<p_{\mathrm{T}}<6~\mathrm {GeV}/c\), and 2.5% for \(p_{\mathrm{T}}<4~\mathrm {GeV}/c\). For the \({{\mathrm{D}}^0}\)-meson analysis without decay-vertex reconstruction, compatible cross sections were obtained when using more stringent PID criteria. Based on this result and on the fact that the PID selections are the same as used in the analysis with decay-vertex reconstruction, no uncertainty due to PID was assigned.

The systematic uncertainty due to the generated D-meson \(p_{\mathrm{T}}\) shape was estimated by using FONLL as an alternative generator with respect to PYTHIA to simulate the D-meson \(p_{\mathrm{T}}\) distribution [15], and was found to be 0–5% for \(p_{\mathrm{T}}<3~\mathrm {GeV}/c\) and negligible at higher \(p_{\mathrm{T}}\). The \(p_{\mathrm{T}}\) shape of both considered distributions were found to be compatible with the measured one within uncertainties. Finally, the systematic uncertainty on the subtraction of feed-down from beauty-hadron decays (i.e. the calculation of the \(f_{\mathrm{prompt}}\) fraction) was estimated by varying the FONLL parameters (b-quark mass, factorisation, and renormalisation scales) as prescribed in Ref. [8]. It ranges between \(^{+1.0}_{-1.2}\)% and \(^{+4.4}_{-6.3}\)% depending on the D-meson species and \(p_{\mathrm{T}}\) interval.

The contributions of these different sources of uncertainties were summed in quadrature to obtain the total systematic uncertainty in each \(p_{\mathrm{T}}\) interval, which varies from 6.5 to 10.0%, 6.5 to 10.5%, 5.4 to 11.3%, and 8.7 to 12.1% for the \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons, respectively. The systematic uncertainty on PID, tracking, and selection efficiencies are mainly correlated among the different \(p_{\mathrm{T}}\) intervals, while the raw-yield extraction uncertainty is mostly uncorrelated. The \(p_{\mathrm{T}}\)-differential cross sections have an additional global normalisation uncertainty due to the uncertainties on the integrated luminosity [32] and on the branching ratios of the considered D-meson decays [30].

5 Results

5.1 Transverse momentum-differential cross sections

The \(p_{\mathrm{T}}\)-differential production cross section for prompt \({{\mathrm{D}}^0}\) mesons in \(|y|<0.5\) in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) was obtained from the analyses with and without decay-vertex reconstruction. The two results are compared in Fig. 6 with the inset showing their ratio in the common \(p_{\mathrm{T}}\) range. In all the figures in this section, the vertical error bars represent the statistical uncertainties and the systematic uncertainties are depicted as boxes around the data points. In each \(p_{\mathrm{T}}\) interval the symbols are positioned horizontally at the center of the bin and the horizontal bars represents the width of the \(p_{\mathrm{T}}\) interval. The two results for prompt \({{\mathrm{D}}^0}\)-meson cross section are found to be consistent within statistical uncertainties, which are independent between the two measurements because of their very different signal-to-background ratios and efficiencies. The most precise measurement of the prompt \({{\mathrm{D}}^0}\)-meson production cross section is obtained using the results of the analysis without decay-vertex reconstruction in the interval \(0<p_{\mathrm{T}}<1~\mathrm {GeV}/c\) and those of the analysis with decay-vertex reconstruction for \(p_{\mathrm{T}}>1~\mathrm {GeV}/c\).

Fig. 6
figure 6

Prompt \({{\mathrm{D}}^0}\)-meson \(p_{\mathrm{T}}\)-differential production cross section in \(|y|<0.5\) in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) measured with and without decay-vertex reconstruction. The inset shows the ratio of the measurements in their common \(p_{\mathrm{T}}\) range. The vertical error bars and the empty boxes represent the statistical and systematic uncertainties, respectively

Fig. 7
figure 7

\(p_{\mathrm{T}}\)-differential production cross section of prompt \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\). Statistical uncertainties (bars) and systematic uncertainties (boxes) are shown. For the \({{\mathrm{D}}^0}\) meson, the results in \(0<p_{\mathrm{T}}<1~\mathrm {GeV}/c\) are obtained from the analysis without decay-vertex reconstruction, while those in \(1<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) are taken from the analysis with decay-vertex reconstruction. The \({{\mathrm{D}}^{*+}}\)-meson cross section is scaled by a factor of 5 for better visibility

The \(p_{\mathrm{T}}\)-differential cross sections for prompt \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson production in \(|y|<0.5\) are depicted in Fig. 7. The prompt \({{\mathrm{D}}^0}\)-meson \(p_{\mathrm{T}}\)-differential cross section is compatible with the one measured by the CMS collaboration at the same centre-of-mass energy in \(|y|<1\) and \(2<p_{\mathrm{T}}<100~\mathrm {GeV}/c\) [20].

Fig. 8
figure 8

\(p_{\mathrm{T}}\)-differential production cross sections for prompt \({{\mathrm{D}}^0}\) meson compared to pQCD calculations: FONLL [7, 8], GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) [39, 40], GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) [6], and \(k_{\mathrm{T}}\)-factorisation [41]. The ratios of the data to the theoretical predictions are shown in the lower part of each panel

Fig. 9
figure 9

\(p_{\mathrm{T}}\)-differential production cross sections for prompt \({{\mathrm{D}}^+}\) meson compared to pQCD calculations: FONLL [7, 8], GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) [39, 40], GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) [6], and \(k_{\mathrm{T}}\)-factorisation [41]. The ratios of the data to the theoretical predictions are shown in the lower part of each panel

Fig. 10
figure 10

\(p_{\mathrm{T}}\)-differential production cross sections for prompt \({{\mathrm{D}}^{*+}}\) meson compared to pQCD calculations: FONLL [7, 8], GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) [39, 40], GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) [6], and \(k_{\mathrm{T}}\)-factorisation [41]. The ratios of the data to the theoretical predictions are shown in the lower part of each panel

Fig. 11
figure 11

\(p_{\mathrm{T}}\)-differential production cross sections for prompt \({{\mathrm{D}}^+_{\mathrm{s}}}\) meson compared to GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) [39, 40], GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) [6], and \(k_{\mathrm{T}}\)-factorisation [41] pQCD calculations. The ratios of the data to the theoretical predictions are shown in the lower part of each panel

In Figs. 8910 and 11 the measured prompt \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson \(p_{\mathrm{T}}\)-differential cross sections are compared with results of pQCD calculations performed with different schemes: FONLL [7, 8] (not available for the \({{\mathrm{D}}^+_{\mathrm{s}}}\) meson), two calculations using the GM-VNFS framework with different prescriptions to regulate the divergences at small transverse momentum, dubbed as GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) [39, 40] and GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) [6], and a calculation based on \(k_{\mathrm{T}}\)-factorisation [41]. The GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) calculations were performed with a different choice of the factorisation and renormalisation scales \({\mu _{\mathrm{F}}}\) and \({\mu _{\mathrm{R}}}\) with respect to the GM-VFNS predictions of Ref. [5] that were compared in Ref. [27] to the cross sections measured at \(\sqrt{s}=7~\mathrm {TeV}\). With this modification of QCD scale, the calculations could be extended to lower \(p_{\mathrm{T}}\). In GM-VFNS(SACOT-\(m_{\mathrm{T}}\)), the divergences of the heavy-quark PDFs and light-parton fragmentation functions at low \(p_{\mathrm{T}}\) are regulated by the heavy-quark mass, thus allowing the calculation of the D-meson cross section down to \(p_{\mathrm{T}}=0\). Note also that the authors of the \(k_{\mathrm{T}}\)-factorisation calculations changed the treatment of the running strong coupling constant \(\alpha _{\mathrm{S}}\) and the gluon distributions [41], with respect to the predictions shown in Ref. [27]. In GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) the value of charm mass is set to \(1.3~\mathrm {GeV}/c^{2}\), while in FONLL, GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) and \(k_{\mathrm{T}}\)-factorisation predictions the mass is set to \(1.5~\mathrm {GeV}/c^{2}\). The four frameworks utilise different sets of PDFs (CTEQ6.6 [42], CTEQ14 [43], NNPDF3.1 [44] and MMHT2014 [45] for FONLL, GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)), GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) and \(k_{\mathrm{T}}\)-factorisation, respectively) and different fragmentation functions. The theoretical uncertainties are estimated by varying the factorisation and renormalisation scales in FONLL, GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) and \(k_{\mathrm{T}}\)-factorisation, while only the renormalisation scale \({\mu _{\mathrm{R}}}\) is varied in GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)). In FONLL and \(k_{\mathrm{T}}\)-factorisation calculations the charm-quark mass is also varied. The uncertainties on the PDFs are included in the GM-VFNS(SACOT-\(m_{\mathrm{T}}\)) and FONLL predictions. The theoretical calculations are performed in the same \(p_{\mathrm{T}}\) intervals as the measurements, except for the first bin of the \({{\mathrm{D}}^0}\) prediction with GM-VFNS(mod-\(\mu _{\mathrm{R,F}}\)) that starts from \(0.1~\mathrm {GeV}/c\). The results of these calculations are shown as filled boxes spanning the theoretical uncertainties and a solid line representing the values obtained with the central values of the pQCD parameters.

The measured cross sections of non-strange D mesons are described within uncertainties by FONLL and the two GM-VFNS calculations. The data lie systematically on the upper edge of the uncertainty band of the FONLL predictions. For the two calculations in the GM-VFNS framework, the central values of the predictions tend to underestimate the data at low and intermediate \(p_{\mathrm{T}}\) and to overestimate them at high \(p_{\mathrm{T}}\). The \(k_{\mathrm{T}}\)-factorisation predictions describe the data at low and intermediate \(p_{\mathrm{T}}\), but overshoots them for \(p_{\mathrm{T}}> 7~\mathrm {GeV}/c\). The \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson production tends to be underestimated by the three pQCD calculations in the measured \(p_{\mathrm{T}}\) range.

The analysis without decay-vertex reconstruction provides also a direct measurement of the inclusive \({{\mathrm{D}}^0}\)-meson cross section because no selections are applied on the decay topology, which alter the fraction of prompt and feed-down D mesons. The inclusive \({{\mathrm{D}}^0}\)-meson cross section is shown in Fig. 12 and compared with results from FONLL calculations [7, 8] with the \(\mathrm {B} \rightarrow \mathrm {D} + X\) decay kinematics from the EvtGen package [37]. The contributions of prompt \({{\mathrm{D}}^0}\)-meson poduction from FONLL and \({{\mathrm{D}}^0}\) mesons from B-meson decays from FONLL+EvtGen are also shown separately. The measured cross sections are described by the calculation within the theoretical uncertainties, with the central value of the prediction lying below the data in all the \(p_{\mathrm{T}}\) intervals, similarly to what observed for prompt D mesons.

The mean \(p_{\mathrm{T}}\) of prompt \({{\mathrm{D}}^0}\) mesons, \({\langle p_{ {\mathrm T} } \rangle }\), was evaluated for \(p_{\mathrm{T}}>\)0 with a fit of the prompt \({{\mathrm{D}}^0}\)-meson cross section, that is measured down to \(p_{\mathrm{T}}= 0\), using a power-law function, as was done in Ref. [27]. The result is:

$$\begin{aligned} {\langle p_{ {\mathrm T} } \rangle }^{\mathrm{prompt}\,\mathrm{D}^0}_{\mathrm{pp},\,5.02\,\mathrm{TeV}} = 2.06 \pm 0.03\,(\mathrm{stat.})\,\pm 0.03\,(\mathrm{syst.})~\mathrm {GeV}/c\,, \end{aligned}$$
(3)

which is slightly smaller than the one computed for pp collisions at \(\sqrt{s}=7~\mathrm {TeV}\) [27]:

$$\begin{aligned} {\langle p_{ {\mathrm T} } \rangle }^{\mathrm{prompt}\,\mathrm{D}^0}_{\mathrm{pp},\,7\,\mathrm{TeV}} = 2.19 \pm 0.06\,(\mathrm{stat.})\,\pm 0.04\,(\mathrm{syst.})~\mathrm {GeV}/c\,. \end{aligned}$$
(4)

The systematic uncertainty on the \({\langle p_{ {\mathrm T} } \rangle }\) was estimated as described in Refs. [19, 27]. The contributions due to the correlated and uncorrelated systematic uncertainties on the measured \(p_{\mathrm{T}}\)-differential cross section were taken into account separately and the contribution due to the choice of the fit function has been estimated by comparing results obtained using different functions and using a method based on direct calculations of \({\langle p_{ {\mathrm T} } \rangle }\) from the data points.

5.2 D-meson cross-section ratios

The ratios of the \(p_{\mathrm{T}}\)-differential cross sections of prompt \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons in pp collisions at \(\sqrt{s}=5.02\) TeV are reported in Fig. 13. In the evaluation of the systematic uncertainties on these ratios, the sources of correlated and uncorrelated systematic effects were treated separately. In particular, the contributions of the yield extraction and cut efficiency were considered as uncorrelated, while those of the feed-down from beauty-hadron decays and the tracking efficiency were treated as fully correlated among the different D-meson species. The measured D-meson cross-section ratios do not show a significant \(p_{\mathrm{T}}\) dependence within the experimental uncertainties, thus suggesting no discernible difference between the fragmentation functions of charm quarks to pseudoscalar (\({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\)) and vector (\({{\mathrm{D}}^{*+}}\)) mesons and to strange and non-strange mesons. The results are compatible within uncertainties with the ratios measured in pp collisions at \(\sqrt{s}=7\) TeV [27].Footnote 1

To study the evolution of prompt D-meson production with the centre-of-mass energy of the collision, the ratios of the production cross sections in pp collisions at \(\sqrt{s}=7\) TeV [27] and \(\sqrt{s}=5.02\) TeV were computed for \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons. The systematic uncertainties on the measured ratios were obtained treating the contribution originating from the subtraction of the feed-down from beauty-hadron decays as correlated, while all the other systematic uncertainties on the cross sections were propagated as uncorrelated between the measurements at the two different energies, except for the uncertainty on the BR, which cancels out in the ratio. The results for \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\) are compared in Fig. 14, on the left panel. The ratios for the different D-meson species are compatible within uncertainties. In the right panel, the \({{\mathrm{D}}^0}\)-meson results are compared to FONLL calculations, which describe consistently the increasing trend as a function of \(p_{\mathrm{T}}\) observed in the data. In the FONLL predictions, the uncertainties originating from scale variations and from PDFs cancel out to a large extent in the ratio [24], thus making the magnitude of the theoretical uncertainties comparable with those of the data.

Fig. 12
figure 12

Inclusive \({{\mathrm{D}}^0}\) mesons (including also \({{\mathrm{D}}^0}\) mesons from beauty-hadron decays) in \(|y|<0.5\) in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\), from the analysis without decay-vertex reconstruction, compared to FONLL pQCD calculations [7, 8] with the \(\mathrm {B} \rightarrow \mathrm {D} + X\) decay kinematics from the EvtGen package [37] (grey boxes). The contributions of prompt \({{\mathrm{D}}^0}\) from FONLL (red) and \({{\mathrm{D}}^0}\) from B-meson decays from FONLL+EvtGen (blue) are also shown separately. The vertical error bars and the empty boxes represent the statistical and systematic uncertainties, respectively

Fig. 13
figure 13

Ratios of D-meson production cross sections as a function of \(p_{\mathrm{T}}\) in pp collisions at \(\sqrt{s}=5.02\) TeV and \(\sqrt{s}=7\) TeV [27]

The rapidity dependence of \({{\mathrm{D}}^0}\)-meson production in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) can be studied from the ratios between our measurements at midrapidity and the LHCb results in different y intervals at forward rapidity [22]. The precise measurement of the \({{\mathrm{D}}^0}\)-meson cross section down to \(p_{\mathrm{T}}=0\) presented in this paper, when analysed together with other results at different centre-of-mass energies and rapidities, can provide sensitivity to the gluon PDF at small values of Bjorken-x (\(10^{-4}\)\(10^{-5}\)) [24]. In Fig. 15 the ratios of the \({{\mathrm{D}}^0}\)-meson production cross sections per unit of rapidity measured with ALICE at mid-rapidity (\(|y|<0.5\)) and by the LHCb collaboration in three rapidity intervals at forward rapidity \(2<y<2.5\) (left panel), \(3<y<3.5\) (middle panel), \(4<y<4.5\) (right panel) [22] are shown as a function of \(p_{\mathrm{T}}\). The error bars and boxes represent the uncertainty obtained from the propagation of the statistical and systematic uncertainties, respectively, from the \(p_{\mathrm{T}}\)-differential cross sections. The systematic uncertainties, including the one on the luminosity determination, were treated as uncorrelated between the ALICE and LHCb results, except for the uncertainty on the BR, which cancels out in the ratio. The central values and the uncertainties of the FONLL calculations are evaluated as described in Ref. [27]. The measured ratios are described by FONLL calculations, shown as red boxes in Fig. 15. Nevertheless the comparison seems to hint at a different slope in data with respect to FONLL, since at low (high) \(p_{\mathrm{T}}\) the data tend to stay above (below) the FONLL central values, in all rapidity intervals.

5.3 Transverse momentum-integrated cross sections and ratios

The visible production cross sections of prompt D mesons were evaluated by integrating the \(p_{\mathrm{T}}\)-differential cross sections over the narrower \(p_{\mathrm{T}}\) intervals of the \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson measurements, in the measured \(p_{\mathrm{T}}\) range. The results are reported in Table 2. The systematic uncertainty was evaluated by propagating all the uncertainties as correlated among \(p_{\mathrm{T}}\) intervals, except for the yield extraction uncertainty which is treated as uncorrelated owing to the bin-by-bin variation, significant especially at low \(p_{\mathrm{T}}\), of S/B and background invariant-mass shape.

Fig. 14
figure 14

Ratios of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\) and \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson production cross sections in pp collisions at \(\sqrt{s}=7\) TeV [27] and \(\sqrt{s}=5.02\) TeV as a function of \(p_{\mathrm{T}}\) (left panel). \({{\mathrm{D}}^0}\) ratio compared to FONLL pQCD calculations [7, 8] (right panel)

Fig. 15
figure 15

Ratios of \({{\mathrm{D}}^0}\)-meson production cross section per unit of rapidity at mid-rapidity (\(|y|<0.5\)) to those measured by the LHCb Collaboration [22] in three rapidity ranges, \(2<y<2.5\) (left panel), \(3<y<3.5\) (middle panel), and \(4<y<4.5\) (right panel), as a function of \(p_{\mathrm{T}}\). The error bars and boxes represent the statistical and systematic uncertainty, respectively. Predictions from FONLL calculations are compared to the data points

Table 2 Visible production cross sections of prompt D mesons in \(|y| < 0.5\) in pp collisions at \(\sqrt{s}= 5.02~\mathrm {TeV}\)

The ratios of the \(p_{\mathrm{T}}\)-integrated yields of the different D-meson species were computed from the cross sections integrated over the common \(p_{\mathrm{T}}\) range. The systematic uncertainties on the ratios were computed treating the BR, yield extraction and cut efficiency uncertainties as uncorrelated among the different species and the other sources as correlated. The results are reported in Table 3.

The measured ratios are compatible within uncertainties with the results at \(\sqrt{s}=2.76~\mathrm {TeV}\) and \(\sqrt{s}=7~\mathrm {TeV}\) [16, 27] and with the measurements of the LHCb collaboration at forward rapidity (\(2.0<y<4.5\)) at three different collision energies \(\sqrt{s}=5.02\), 7, and \(13~\mathrm {TeV}\) [21,22,23].

Table 3 Ratios of the measured \(p_{\mathrm{T}}\)-integrated cross sections of prompt D mesons in \(|y| < 0.5\) in pp collisions at \(\sqrt{s}= 5.02~\mathrm {TeV}\)
Table 4 Production cross sections of prompt D mesons in \(|y| < 0.5\) and full \(p_{\mathrm{T}}\) range in pp collisions at \(\sqrt{s}= 5.02~\mathrm {TeV}\)

The production cross sections per unit of rapidity, \({\mathrm{d}}\sigma /{\mathrm{d}}y\), at mid-rapidity were computed for each D-meson species by extrapolating the visible cross section to the full \(p_{\mathrm{T}}\) range. The extrapolation factor for a given D-meson species was computed using the FONLL central parameters to evaluate the ratio between the total production cross section in \(|y|<0.5\) and that in the experimentally covered phase space. It was verified that the extrapolation factors computed with FONLL were compatible with those resulting from GM-VFNS calculations. The systematic uncertainty on the extrapolation factor was estimated as proposed in Ref. [8], considering sources due to (i) the CTEQ6.6 PDFs uncertainties [42], (ii) the variation of the charm-quark mass and (iii) the renormalisation and factorisation scales in the FONLL calculation. For \({{\mathrm{D}}^0}\) mesons, for which the measurement extends down to \(p_{\mathrm{T}}=0\), the extrapolation factor accounts only for the very small contribution of D mesons with \(p_{\mathrm{T}}>36~\mathrm {GeV}/c\) and therefore its value is very close to unity with negligible uncertainty. The FONLL predictions are not available for \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons, hence in this case the central value of the extrapolation factor was computed as described in Ref. [27], combining the prediction based on the \(p_{\mathrm{T}}\)-differential cross section of charm quarks from FONLL, the fractions \(f({\mathrm{c}\rightarrow {{\mathrm{D}}^+_{\mathrm{s}}}})\) and \(f({\mathrm{c}\rightarrow {\mathrm{D}}_{\mathrm{s}}^{*+}})\) from ALEPH [46], and the fragmentation functions from Ref. [47], which have one parameter, r, that was set to 0.1 as done in FONLL [48]. An additional contribution to the systematic uncertainty was assigned based on the envelope of the results obtained using the FONLL \(p_{\mathrm{T}}\)-differential cross sections of non-strange D mesons to compute the \({{\mathrm{D}}^+_{\mathrm{s}}}\)-meson extrapolation factor. The computed extrapolation factors and the prompt D-meson production cross sections per unit of rapidity \({\mathrm{d}}\sigma /{\mathrm{d}}y\) in \(|y| < 0.5\), are presented in Table 4.

In Ref. [27], the \({\mathrm{c}\overline{\mathrm{c}}}\) production cross section per unit of rapidity at mid-rapidity (\(|y|<0.5\)) and the total charm production cross sections in pp collisions at \(\sqrt{s}=7~\mathrm {TeV}\) were reported. They were computed from the prompt \({{\mathrm{D}}^0}\)-meson production cross section, which was divided by the fraction of charm quarks hadronising into \({{\mathrm{D}}^0}\) mesons, \(f(\mathrm{c}\rightarrow {{\mathrm{D}}^0})=0.542 \pm 0.024\), derived in Ref. [49] by averaging the measurements in \(\hbox {e}^+\hbox {e}^-\) collisions at LEP. However, recent measurements of the \(\mathrm \Lambda ^{+}_{c}\) baryon production cross section in pp collisions at \(\sqrt{s}=7~\mathrm {TeV}\) and in p–Pb collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) [50] show a significant enhancement of the \(\mathrm \Lambda ^{+}_{c}/{{\mathrm{D}}^0}\) ratio for \(p_{\mathrm{T}}>1 \hbox { GeV}/c\) as compared to the values measured in \(\hbox {e}^+\hbox {e}^-\) and ep collisions at lower centre-of-mass energies. This suggests that the fragmentation fractions of charm quarks into charmed baryons in pp collisions at LHC energies might differ significantly from the LEP results reported in Ref. [49] and that measurements of charmed-baryon production cross sections in pp collisions at \(\sqrt{s}=5.02~\mathrm {TeV}\) are needed for an accurate calculation of the charm production cross section.

6 Summary

We have reported the measurement of the inclusive \(p_{\mathrm{T}}\)-differential production cross sections of prompt \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons at mid-rapidity (\(|y|<0.5\)) in pp collisions at a centre-of-mass energy of \(\sqrt{s}=5.02~\mathrm {TeV}\), obtained with the data collected at the end of 2017 with the ALICE detector. The measurement was performed in the transverse-momentum range \(0<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({{\mathrm{D}}^0}\), \(1<p_{\mathrm{T}}<36~\mathrm {GeV}/c\) for \({{\mathrm{D}}^+}\) and \({{\mathrm{D}}^{*+}}\), and \(2<p_{\mathrm{T}}<24~\mathrm {GeV}/c\) for \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons. It is measured in finer \(p_{\mathrm{T}}\) bins with respect to the previous measurements at \(\sqrt{s}=7~\mathrm {TeV}\) [27], providing a more detailed description of the cross-section \(p_{\mathrm{T}}\) shape. The results were compared and found compatible with different pQCD calculations performed with different schemes: FONLL [7, 8], two calculations using the GM-VNFS framework with different prescriptions  [6, 39, 40], and a calculation based on \(k_{\mathrm{T}}\)-factorisation [41]. The ratios of \({{\mathrm{D}}^0}\)-meson production cross sections measured with ALICE and LHCb in different rapidity intervals were compatible with FONLL calculations, indicating a slightly smaller slope in data with respect to theoretical predictions. The ratios of the cross sections of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), and \({{\mathrm{D}}^{*+}}\) mesons at \(\sqrt{s}=7\) TeV [27] and \(\sqrt{s}=5.02\) TeV are consistent with FONLL pQCD calculations. The ratios of the \(p_{\mathrm{T}}\)-differential cross sections of \({{\mathrm{D}}^0}\), \({{\mathrm{D}}^+}\), \({{\mathrm{D}}^{*+}}\), and \({{\mathrm{D}}^+_{\mathrm{s}}}\) mesons were found to be compatible within uncertainties with the D-meson cross-section ratios measured in pp collisions at \(\sqrt{s}=7\) TeV [27]. The new measurement will allow for a more accurate determination of the nuclear modification factor \(R_\mathrm{pA}\) in p–Pb collisions and \(R_{\mathrm{AA}}\) in Pb–Pb collisions at \(\sqrt{s_\mathrm{NN}}=5.02\) TeV, due to the larger statistics available and since it is performed at the same centre-of-mass energy of the other collision systems.