# Full width at half maximum help?

**URL:** <https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [June 19, 2019, 9:14pm UTC](https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711 "2019-06-19T21:14:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JorgeM](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@JorgeM](https://root-forum.cern.ch/u/JorgeM)\
**Post date:** [June 19, 2019, 9:14pm UTC](https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711/1 "2019-06-19T21:14:08Z")

</div>

Hi!  
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.

```auto
 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;
 

```

J

---

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [June 19, 2019, 9:40pm UTC](https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711/2 "2019-06-19T21:40:50Z")

</div>

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](https://root.cern/doc/master/myfit_8C.html) tutorial. The FWHM value is computed from the standard deviation

---

<div class="post-metadata">

**Author:** ![JorgeM](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@JorgeM](https://root-forum.cern.ch/u/JorgeM)\
**Post date:** [June 19, 2019, 10:55pm UTC](https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711/3 "2019-06-19T22:55:28Z")

</div>

Hi!  
I already had gaussian fits for the peaks as shown in the following code:}

```auto
  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(8_ln_2)), but how do I extract the sigma from the saved function?  
by the way, m1 is the gaussian from the peak I want.

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [June 20, 2019, 5:41am UTC](https://root-forum.cern.ch/t/full-width-at-half-maximum-help/34711/4 "2019-06-20T05:41:55Z")

</div>

Hi,  
after the fit to have the sigma just do,

```auto
double sigma = g1->GetParameter(2);

```

Cheers,  
Stefano
