Contribution of various components of cosmic rays on an HPGe gamma spectrometer were studied by Geant4. The simulated total spectrum shows good agreement with the measurement background spectrum from 3 MeV up to 50 MeV. Muonic component dominates with 86% of background. Muons secondary particle shower contributes mostly to the spectrum in the energy region of below 3 MeV.