We present the midrapidity charged pion invariant cross sections and the ratio of $\pi^-$-to-$\pi^+$ production ($5<p_T<13$ GeV/$c$), together with the double-helicity asymmetries ($5<p_T<12$ GeV/$c$) in polarized $p$$+$$p$ collisions at $\sqrt{s} = 200$ GeV. The cross section measurements are consistent with perturbative calculations in quantum chromodynamics within large uncertainties in the calculation due to the choice of factorization, renormalization, and fragmentation scales. However, the theoretical calculation of the ratio of $\pi^-$-to-$\pi^+$ production when considering these scale uncertainties overestimates the measured value, suggesting further investigation of the uncertainties on the charge-separated pion fragmentation functions is needed. Due to cancellations of uncertainties in the charge ratio, direct inclusion of these ratio data in future parameterizations should improve constraints on the flavor dependence of quark fragmentation functions to pions. By measuring charge-separated pion asymmetries, one can gain sensitivity to the sign of $\Delta G$ through the opposite sign of the up and down quark helicity distributions in conjunction with preferential fragmentation of positive pions from up quarks and negative pions from down quarks. The double-helicity asymmetries presented are sensitive to the gluon helicity distribution over an $x$ range of $\sim$0.03--0.16.
Double-helicity asymmetries and statistical uncertainties for $\pi^+$ and $\pi^-$ hadrons. The primary systematic uncertainties, which are fully correlated between points, are $1.4\times10^{-3}$ from relative luminosity and a $^{+7.0\%}_{-7.7\%}$ scaling uncertainty from beam polarization.