Differential cross sections are presented for the prompt and non-prompt production of the hidden-charm states X(3872) and ψ(2S), in the decay mode J/ψπ$^{+}$ π$^{-}$, measured using 11.4 fb$^{-1}$ of pp collisions at $ sqrt{s}=8 $ TeV by the ATLAS detector at the LHC. The ratio of cross-sections X(3872)/ψ(2S) is also given, separately for prompt and non-prompt components, as well as the non-prompt fractions of X(3872) and ψ(2S). Assuming independent single effective lifetimes for non-prompt X(3872) and ψ(2S) production gives $ {R}_B=frac{mathrm{mathcal{B}}left(Bto X(3872)+mathrm{any}right)mathrm{mathcal{B}}left(X(3872)to J/psi {pi}^{+}{pi}^{-}right)}{mathrm{mathcal{B}}left(Bto psi (2S)+mathrm{any}right)mathrm{mathcal{B}}left(psi (2S)to J/psi {pi}^{+}{pi}^{-}right)}=left(3.95pm 0.32left(mathrm{s}mathrm{tat}right)pm 0.08left(mathrm{s}mathrm{y}mathrm{s}right)right)times {10}^{-2} $ separating short- and long-lived contributions, assuming that the short-lived component is due to B$_{c}$ decays, gives R$_{B}$ = (3.57 ± 0.33(stat) ± 0.11(sys)) × 10$^{-2}$, with the fraction of non-prompt X(3872) produced via B$_{c}$ decays for p$_{T}$(X(3872)) > 10 GeV being (25 ± 13(stat) ± 2(sys) ± 5(spin))%. The distributions of the dipion invariant mass in the X(3872) and ψ(2S) decays are also measured and compared to theoretical