Peak finding algorithms on TSpectrum(s)

Hi,

I am trying to find some peaks in histogram using TSpectrum. The results I have been getting are rather disappointing:

  1. Normally it does not find the right number of peaks.

  2. When it does managed to find the right number and I asked it for their respective positions, I get some non-sesical values, i.e. most of the values are outside even the range of the histogram!

Let me add that frankly the peaks in my histogram are actually “cathedrals”!

Here is a CC of code… perhaps I am missing something on the parameters.

(…)

TSpectrum2* mySpec = new TSpectrum();

Int_t npeaksFound = mySpec->Search(gSpillCounter_h,1);

Float_t* peakPos = mySpec->GetPositionX();

for(iter<npeakFound) {
cout << peakPos[iter] << endl;
iter++;
}

(…)

Is there any other peak finding algorithm out there?

Thanks!

         Anatael

PS: The documentation associated to TSpectrum(s) is rather unclear…

Please obey some rules to post something at this forum. See:
root.cern.ch/root/roottalk/RoottalkRules.html

In your case, indicate which version you use,
send a small script with a data file.
See example at $ROOTSYS/tutorials/peaks.C

Rene

Hi again,

Please obey some rules to post something at this forum. See:
root.cern.ch/root/roottalk/RoottalkRules.html

Sorry about that, I did not know the were rules… makes lot of sense!

In your case, indicate which version you use,
send a small script with a data file.
See example at $ROOTSYS/tutorials/peaks.C

Magic! I got it working, but I do not understand why…

The answer (to me at least) is on setting option (below) to “new”, as Rene Brun did in this tutorial - instead of the “goff”, which is the default option.

TSpectrum::Search(TH1 * hin, Double_t sigma, Option_t * option, Double_t threshold)

I could not find any trace of such a “new” option in the documentation of the class, but in the tutorials… somewhere!

Thanks very much for your help!

Anatael :laughing: