Baseline shift seriously affects the accuracy of elemental analyzing when prompt gamma neutron activation analysis (PGNAA) technique is used in industry fields. Baseline is affected by signal pile-ups and environmental factors. We propose a photomultiplier tube (PMT) gating method to eliminate the effects of the environmental factors. The detector system updates the baseline before each single measurement starts. We propose an algorithm to restore the baseline shift caused by signal pile-ups. Test result shows that with the gating method, the hydrogen characteristic peak position fluctuation is reduced by half of the original value. And the resolution does not increased by the using of the gating method.