I am trying to calculate the full width at half maximum of a specific peak in my histogram (I have several at different energies.)
Is there a way to do this just for a specific peak in a multipeak hist?
I found these lines of code, but they seem to get the FWHM of the whole histogram.
int bin1 = h1->FindFirstBinAbove(h1->GetMaximum()/2);
int bin2 = h1->FindLastBinAbove(h1->GetMaximum()/2);
double fwhm = h1->GetBinCenter(bin2) - h1->GetBinCenter(bin1);
cout<< "FWHM " << fwhm <<endl;
Hi, the best way to achieve this is to fit each peak with a Gaussian function. To know how to do it, you can adapt the myfit.C tutorial. The FWHM value is computed from the standard deviation
I already had gaussian fits for the peaks as shown in the following code:}
TF1 *g1 = new TF1("m1","gaus",Pi,Pf);
TF1 *g2 = new TF1("m2","gaus",Pi1,Pf1);
TF1 *g3 = new TF1("m3","gaus",Pi3,Pf3);
TF1 *total = new TF1("mstotal", "gaus(0)+gaus(3)+gaus(6)",Pi3,Pf);
I’ve seen that the FWHM = sigma(sqrt(8ln2)), but how do I extract the sigma from the saved function?
by the way, m1 is the gaussian from the peak I want.
after the fit to have the sigma just do,
double sigma = g1->GetParameter(2);