The $NDeltato NN$ cross sections, which take into account the $Delta$-mass dependence of M-matrix and momentum $p_{NDelta}$, are applied on the calculation of pion production within the framework of the UrQMD model. Our study shows that UrQMD calculations with the $Delta$-mass dependent $NDeltato NN$ cross sections enhance the pion multiplicities and decrease the $pi^-/pi^+$ ratios. By analyzing the time evolution of the pion production rate and the density in the overlapped region for Au+Au at the beam energy of 0.4A GeV, we find that the pion multiplicity probes the symmetry energy in the region of 1-2 times normal density. The process of pion production in the reaction is tracked including the loops of $NNleftrightarrow NDelta$ and $Deltaleftrightarrow Npi$, our calculations show that the sensitivity of $pi^-/pi^+$ to symmetry energy is weakened after 4-5 N-$Delta$-$pi$ loops in the pion production path, while the $pi^{-}/pi^{+}$ ratio in reactions at near threshold energies remains its sensitivity to the symmetry energy. By comparing the calculations to the FOPI data, we obtain a model dependent conclusion on the symmetry energy and the symmetry energy at two times normal density is $S(2rho_0)$=38-73 MeV within $1sigma$ uncertainties. Under the constraints of tidal deformability and maximum mass of neutron star, the symmetry energy at two times normal density is reduced to $48-58$ MeV and slope of symmetry energy $L=54-81$ MeV, and it is consistent with the constraints from ASY-EOS flow data.