function [N] = Nelectrons(y, t, UseSignificance, s, UseMean, mu);
% function [N] = Nelectrons(y, t, UseSignificance, s, UseMean, mu)
%
% calculates the number of electrons in the first pulse at the signal.
%
% is the given signal in 1D array format.
% is time axis in 1D array format.
% is a switch: 0 is for calculation significance function.
% ~~ is significance function of the signal.
% is a switch: 0 is for calculating the signal mean value.
% is the mean value of the signal.
% is number of electrons.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Current state of the project and change history.
%
% Created by: Alexander Vostrikov
% Created on: 07/13/2011
%
% Version: 1.0
% Modified by: Alexander Vostrikov
% Edited on: 07/13/2011
%
% List of Previous Versions:
%
%
% If you type 'help Nelectrons' on the Matlab command window, you will be
% able to see this help documentation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% beginning of code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if UseSignificance == 0
s = significance(y);
UseSignificance = 1;
end
if UseMean == 0
[mu, sigma] = background(y, UseSignificance, s);
end
a = SignificanceCut(s, 6.0);
b = a;
while y(a) > mu
a--;
end
while y(b) > mu
b++;
end
I = 0.0;
for i = a:b
I += (y(i) - mu) * (t(i+1) - t(i));
end
R = 50;
e = 1.6e-19;
N = I / R / e;
end
~~