Positions of maximums with TSpectrum

Dear rooters,
I have a problem using TSpectrum.
I’m trying to understand the standart macro: https://root.cern.ch/root/html/tutorials/spectrum/peaks.C.html.
Program works well but when I’m trying to print positions of maximums I’ll get wrong values.
Here is how I try to get positions:

Double_t xp = xpeaks[p]; Int_t bin = h->GetXaxis()->FindBin(xp); Double_t yp = h->GetBinContent(bin); [b]cout<<"Xp= "<<xp<<" Yp="<<yp<<endl;[/b]
And here is the result for [color=#0040BF]peaks(4)[/color]:

Found 4 candidate peaks to fit Xp= 5.39567e+20 Yp=0 Xp= 2.23206e+21 Yp=0 Xp= 8.73532e-313 Yp=577 Xp= 3.60739e-313 Yp=577
The question is how to get these positions correctly?
Thank you for help in advance!
Sergey

Which ROOT version?
Note: ROOT 6 returns “Double_t” peaks’ positions, while ROOT 5 returns “Float_t” peaks’ positions.
Try something like this: // ... #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,00) Double_t *xpeaks; // ROOT 6 #else Float_t *xpeaks; // ROOT 5 #endif xpeaks = s->GetPositionX(); for (p = 0; p < nfound; p++) { Double_t xp = xpeaks[p]; // ROOT 6 or 5 // ... } // ... See also: Illegal pointer to class object back 0x0 165

Dear Pepe Le Pew,
thank you for answer, now it works!

Note that the spectrum tutorials collection has been extended recently:
root.cern.ch/doc/master/group__ … ctrum.html