TSpectrum: maxpositions has absolutely no effect?

Hallo

I’m using TSpectrum(maxpositions, resolution)
I set max positions to 2, but I still get sometimes 3 or 4 peaks returned by Search(histogram, sigma)

max positions is supposed to define an upper limit for the number of peaks on the histogram, right?

Thanks
TSpectrum.C (1.68 KB)

Just read the posting rules.
Sorry, I’m using root 3.05/07.

But prior to posting this thread, I looked up the reference guide for this version. That also indicates that the maxpositions limits the number of peaks returned by Search(histogram,sigma).

So … why doesn’t it?
The example I’ve uploaded is a bit trivial, but it shows the problem …
Or am I just missing a point somewhere?

Discuss this problem with teh author Miroslav Morhac
fyzimiro@nrmail.jinr.ru

Rene

I can confirm the effect with 4.04, too.

Probably the key is in the source:

//______________________________________________________________________________ TSpectrum::TSpectrum(Int_t maxpositions, Float_t resolution) :TNamed("Spectrum", "Miroslav Morhac peak finder") { Int_t n = TMath::Max(maxpositions, 100); fMaxPeaks = n;
Maybe TMath::Max should be TMath::Min, otherwise at least 100 peaks can be returned.

Janos

BTW:
I think the default contructor

//______________________________________________________________________________
TSpectrum::TSpectrum() :TNamed(“Spectrum”, “Miroslav Morhac peak finder”)
{
Int_t n = 100;
fMaxPeaks = n;
fPosition = new Float_t[n];
fPositionX = new Float_t[n];
fPositionY = new Float_t[n];
fResolution = 1;
fHistogram = 0;
fNPeaks = 0;
}
is against coding standard, as it allocates memory.

You were right Jvegh. The min value is set to 100. Here’s a copy of the email I got from Miro, if anyone is interested:

[quote=“no1else”]You were right Jvegh. The min value is set to 100. Here’s a copy of the email I got from Miro, if anyone is interested:

[/quote]
Thanks for the info, although I still do not see the necessity of this limitation.

Janos

Yeah, neither do I. its certainly messing things up for my code.
Anyway …

[quote=“no1else”]Yeah, neither do I. its certainly messing things up for my code.
Anyway …[/quote]

You know, there are some mystic limitations like for example in TFumili.cxx

TFumili::TFumili(Int_t maxpar) {//----------- FUMILI constructor --------- // maxpar is the maximum number of parameters used with TFumili object // fMaxParam = TMath::Max(maxpar,25); if (fMaxParam>200) fMaxParam=25;

So, if you have two peaks only, you receive a 100 packet of peaks (even if your array is prepared for 2 only (!)), with no upper limit for the peaks.
If you have 3 parameters, you will receive a 25 packet of parameters.
And, all the calculations are done with this number of (mostly, ghost) parameters.
However, you must not order more than 200.

Maybe someone knows why…

Janos

Thanks for reporting the two problems with the maximum number of peaks
in the TSpectrum constructor or the maximum number of parameters
in the TFumili constructor.
Now fixed in teheCVS head.

Rene