  The spectra measurements of charged hadrons produced in the shower of a
parton originating in the same hard scattering with a leptonically decaying Z
boson, are reported in lead-lead (PbPb) and proton-proton (pp) collisions at a
nucleon-nucleon center-of-mass energy of 5.02 TeV. Both PbPb and pp data sets
are recorded by the CMS experiment at the LHC, and correspond to an integrated
luminosity of 1.7 nb$^{-1}$ and 320 pb$^{-1}$, respectively. Hadronic collision
data with one reconstructed Z boson candidate with the transverse momentum
$p_\mathrm{T} \gt$ 30 GeV/$c$ are analyzed. The Z boson constrains the initial
energy and direction of the associated parton. In heavy ion events, azimuthal
angular distributions of charged hadrons with respect to the direction of a Z
boson are sensitive to modifications of the in-medium parton shower and medium
response. Compared to reference data from pp interactions, the results for
central PbPb collisions indicate a modification of the angular correlations.
The measurements of the fragmentation functions and $p_\mathrm{T}$ spectra of
charged particles in Z boson events, which are sensitive to medium
modifications of the parton shower longitudinal structure, are also reported.
Significant modifications in central PbPb events compared to pp reference data
are also found for these observables.
