# Sigma value for peak finding using TSpectrum

**URL:** <https://root-forum.cern.ch/t/sigma-value-for-peak-finding-using-tspectrum/46283>\
**Category:** Newbie\
**Created:** [August 12, 2021, 10:16am UTC](https://root-forum.cern.ch/t/sigma-value-for-peak-finding-using-tspectrum/46283 "2021-08-12T10:16:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil\_bhathi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nikhil\_bhathi](https://root-forum.cern.ch/u/nikhil_bhathi)\
**Post date:** [August 12, 2021, 10:16am UTC](https://root-forum.cern.ch/t/sigma-value-for-peak-finding-using-tspectrum/46283/1 "2021-08-12T10:16:40Z")

</div>

Hi guys,  
So, I am using TSpectrum class to find the largest peak in a histogram. the code looks like this:

```auto
    TSpectrum *s = new TSpectrum();
    s->Search(hst,2,"nobackground");
    positions=s->GetPositionX();

```

But it doesn’t always work very well, if the highest peak is at 1640, sometimes it will give 1555.  
I think it is because of my choice of sigma, can you guys tell me how to choose a proper sigma for this?

 ![Screenshot from 2021-08-12 15-44-49](https://root-forum.cern.ch/uploads/default/original/3X/6/5/655c1e17269042aca640cad156257ac3ef8111a5.png)

_ROOT Version:_ 6.22/00  
_Platform:_ linux  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [August 12, 2021, 12:53pm UTC](https://root-forum.cern.ch/t/sigma-value-for-peak-finding-using-tspectrum/46283/2 "2021-08-12T12:53:10Z")

</div>

Hi,

you might want to check this:

> [@Need of doc in TSpectrum:Search](https://root-forum.cern.ch/t/need-of-doc-in-tspectrum-search/16791/12):
>
> Hi Vladislav, The following is written in the middle of [section 3.1 of the TSpectrum guide](https://root.cern.ch/root/htmldoc/guides/spectrum/Spectrum.html#dimensional-spectra-3): …The value in the center of the peak value[i] minus the average value in two symmetrically positioned channels (channels i-3\*sigma, i+3\*sigma) must be greater than threshold. Otherwise the peak is ignored…
