The dependence of the ratio between the B$_\mathrm{s}^0$ and B$^+$ hadron production fractions, $f_\mathrm{s} / f_\mathrm{u}$, on the transverse momentum ($p_\mathrm{T}$) and rapidity of the B mesons is studied using the decay channels B$_\mathrm{s}^0$$\to$ J$/\psi\,\phi$ and B$^+$$\to$ J$/\psi$ K$^+$. The analysis uses a data sample of proton-proton collisions at a center-of-mass energy of 13 TeV, collected by the CMS experiment in 2018 and corresponding to an integrated luminosity of 61.6 fb$^{-1}$. The $f_\mathrm{s} / f_\mathrm{u}$ ratio is observed to depend on the B $p_\mathrm{T}$ and to be consistent with becoming asymptotically constant at large $p_\mathrm{T}$. No rapidity dependence is observed. The ratio of the B$^0$ to B$^+$ hadron production fractions, $f_\mathrm{d} / f_\mathrm{u}$, measured using the B$^0$$\to$ J$/\psi$ K$^{*0}$ decay channel, is found to be consistent with unity and independent of $p_\mathrm{T}$ and rapidity, as expected from isospin invariance.
A test of lepton flavor universality in B$^{\pm}$$\to$ K$^{\pm}\mu^+\mu^-$ and B$^{\pm}$$\to$ K$^{\pm}$e$^+$e$^-$ decays, as well as a measurement of differential and integrated branching fractions of a nonresonant B$^{\pm}$$\to$ K$^{\pm}\mu^+\mu^-$ decay are presented. The analysis is made possible by a dedicated data set of proton-proton collisions at $\sqrt{s}$ = 13 TeV recorded in 2018, by the CMS experiment at the LHC, using a special high-rate data stream designed for collecting about 10 billion unbiased b hadron decays. The ratio of the branching fractions $\mathcal{B}$(B$^{\pm}$$\to$ K$^{\pm}\mu^+\mu^-$) to $\mathcal{B}$(B$^{\pm}$$\to$ K$^{\pm}$e$^+$e$^-$) is determined from the measured double ratio $R$(K) of these decays to the respective branching fractions of the B$^\pm$$\to$ J/$\psi$K$^\pm$ with J/$\psi$$\to$$\mu^+\mu^-$ and e$^+$e$^-$ decays, which allow for significant cancellation of systematic uncertainties. The ratio $R$(K) is measured in the range 1.1 $\lt q^2 \lt$ 6.0 GeV$^2$, where $q$ is the invariant mass of the lepton pair, and is found to be $R$(K) = 0.78$^{+0.47}_{-0.23}$, in agreement with the standard model expectation $R$(K) $\approx$ 1. This measurement is limited by the statistical precision of the electron channel. The integrated branching fraction in the same $q^2$ range, $\mathcal{B}$(B$^{\pm}$$\to$ K$^{\pm}\mu^+\mu^-$) = (12.42 $\pm$ 0.68) $\times$ 10$^{-8}$, is consistent with the present world-average value and has a comparable precision.