The characteristic gamma-ray spectrum of TNT in the soil induced by DT neutrons is measured by the PFTNA demining system. The GEANT4 toolkit is used to simulate the whole experimental procedure. The simulated spectra are compared with the experimental spectra, and they are mainly consistent. The share of the background sources such as neutrons and gamma is obtained and the contribution that the experimental apparatus to the background, such as shielding, detector sleeve and moderator, is analyzed. The effective gamma signal(from soil and TNT) is 29% of the full spectrum signal, and the background signal, more than 68%, this is mainly produced by shielding and the detector sleeve. By gradually optimizing the shielding and the cadmium sheet of the detector sleeve, the share of the effective gamma signal increases to 47%, and the background signal reduces to 18%.