CODE to attempt a gaussian energy broadning of a spectrum

5 visualizzazioni (ultimi 30 giorni)
Respected MATLAB experts,
I am trying to perform a gaussian broadning on a energy spectrum. The final result should convert "specrum.png" to a similar form of "Exp.png". The method is explained in the "snap.jpg". In "snap.jpg" each bin is converted in a gaussian where the "μ" is the mean, and sigma of the gaussian is a polynomial function dependent on the energy i.e. x-axis (see code). Here each bin is converted to a gaussian in a for loop and I want that the second bin gaussian includes a pileup from the gaussian of first bin. Similarly, the third gaussian should include the pileup from second and first.
W_NAIF.mat is the data file which I want to process (Unbroadned spectrum).
The I am using for this is below:
E=linspace(0,10,1026); % Energy bins
for i=1:1026
sigma(i) = (-0.00789) + (0.06769)*E(i) + (0.021159)*(E(i)^2); % Sigma polynomial function
gaussFilter(i) = (1/sqrt(2*pi* (sigma(i)^2)))*exp(-((E(i)-0.5)))/(2*(sigma(i)^2)); % Gaussian function
gaussFilter(i) = gaussFilter(i) / sum (gaussFilter(i));
AAA=W_NAIF/sum(W_NAIF);
newSPECU(i) = conv(AAA(i),gaussFilter(i));
end
figure(1);
stairs(E,newSPECU);
set(gca,'YScale','log');
xlabel('Energy Deposited (MeV)');
ylabel('Counts');
title('Geant4 Gamma energy spectra (NaI NEAR - Tap Water)');
grid minor;
grid on;
ylim([1 1e6]);
Any help in this regard is hugely appreciated.
Thanks!
Best Regards,
Sanchit Sharma

Risposte (0)

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by