A study of direct and indirect pion production in π+p interactions at 16 GeV/c