Study of Z production in PbPb and pp collisions at $ \sqrts_\mathrmNN=2.76 $ TeV in the dimuon and dielectron decay channels