TSpectrum gives wrong peak


_ROOT Version: 6.10/09


Dear all,
I am trying to implement the TSpectrum class in an histogram, but the peak that was found is clearly not what it was supposed to be. See attached image. What is going wrong?

{

        TChain ch("Events");
        ch.Add("Skim25_07.root");
        TCanvas *c1 = new TCanvas("c1","momentum",1);
        gStyle->SetOptStat(0);
        TH1F *h1 = new TH1F("h1", "momen", 20, 0, 200);
        Events->Draw("mt_tot>>h1", "mt_tot>0");
        //h1->Fit("gaus");

        Int_t j = 0;
        TSpectrum *sp1 = new TSpectrum();
        sp1->Search(h1,1,"",0.5) ;
        Int_t npeaks = sp1->GetNPeaks() ;
        cout << "Peaks found " << npeaks << endl ;

        Double_t *peaks;
        peaks = sp1->GetPositionX();
        for (j=0 ; j<npeaks ; j++){
        cout << "Peak at = " << peaks[j] << endl ;
        }

        h1->GetYaxis()->SetTitle("# entries");
        h1->GetXaxis()->SetTitle("M_{T}^{total}");

}

Peaks found 1
Peak at = 95

cap

Is 95 right at the border of the bin ?

No, it’s in the middle. The bins are distributed intervals of 10.

I am not sur how TSpectrum identifies peaks but in your case the bins are quite wide and if you look from far away the “peak” goes from roughly 70 to 110 … it could be that the way peaks are computed make Search draw the triangle at a bin close to the maximum but not at the maximum. Imagine the next bin, which is now at 25, would have bin at 40 like the previous one. From far away that would still have been the same “peak” but in that case where should have been drawn the red triangle ? May be there is a parameter somewhere you can tune to define the peak extend along X … I am not sure about it . One should look at the doc.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.