# Peak-to-Background Ratio

**URL:** <https://root-forum.cern.ch/t/peak-to-background-ratio/43198>\
**Category:** Newbie\
**Created:** [January 21, 2021, 1:13pm UTC](https://root-forum.cern.ch/t/peak-to-background-ratio/43198 "2021-01-21T13:13:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lum\_totzin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e9a140/32.png) [@lum\_totzin](https://root-forum.cern.ch/u/lum_totzin)\
**Post date:** [January 21, 2021, 1:13pm UTC](https://root-forum.cern.ch/t/peak-to-background-ratio/43198/1 "2021-01-21T13:13:47Z")

</div>

Good day

I would like to get the peak to background ratio from a spectrum that I obtained in Root. In some analyzing tools this function is already built-in. I am not sure how to go about it in Root.

_ROOT Version:_ 6.18  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 25, 2021, 9:40am UTC](https://root-forum.cern.ch/t/peak-to-background-ratio/43198/2 "2021-01-25T09:40:01Z")

</div>

Hi,

You can fit the peak; then get the fit function’s integral, see [`TF1::Integral()`](https://root.cern/doc/master/classTF1.html#a596e02742b00f1e265cc2dbe4daf20fe).

Fit the background, get _that_ fit function’s integral in the signal region.

Divide, done!

Or you take the bin content in the signal region (which corresponds to signal + background) and divide by the background fit’s function integral in that signal region. That gives you `(b+s)/b`, i.e. that ratio minus 1 is what you’re after.

Cheers, Axel.

---

<div class="post-metadata">

**Author:** ![lum\_totzin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e9a140/32.png) [@lum\_totzin](https://root-forum.cern.ch/u/lum_totzin)\
**Post date:** [January 25, 2021, 11:24am UTC](https://root-forum.cern.ch/t/peak-to-background-ratio/43198/3 "2021-01-25T11:24:00Z")

</div>

Got it thank you very much.
