13    Double_t fPositionX[100];
 
   14    Double_t fPositionY[100];
 
   17    const Int_t nbins = 1024;
 
   19    Double_t xmax     = nbins;
 
   21    Double_t source[nbins], dest[nbins];
 
   24    TString dir  = gROOT->GetTutorialDir();
 
   25    TString file = dir+
"/spectrum/TSpectrum.root";
 
   26    TFile *f     = 
new TFile(file.Data());
 
   27    TH1F *h = (TH1F*) f->Get(
"back2");
 
   28    h->SetTitle(
"High resolution peak searching, number of iterations = 3");
 
   29    h->GetXaxis()->SetRange(1,nbins);
 
   30    TH1F *d = 
new TH1F(
"d",
"",nbins,xmin,xmax);
 
   33    for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
 
   37    TSpectrum *s = 
new TSpectrum();
 
   39    nfound = s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 3, kTRUE, 3);
 
   40    Double_t *xpeaks = s->GetPositionX();
 
   41    for (i = 0; i < nfound; i++) {
 
   43       bin = 1 + Int_t(a + 0.5);
 
   44       fPositionX[i] = h->GetBinCenter(bin);
 
   45       fPositionY[i] = h->GetBinContent(bin);
 
   48    TPolyMarker * pm = (TPolyMarker*)h->GetListOfFunctions()->FindObject(
"TPolyMarker");
 
   50       h->GetListOfFunctions()->Remove(pm);
 
   53    pm = 
new TPolyMarker(nfound, fPositionX, fPositionY);
 
   54    h->GetListOfFunctions()->Add(pm);
 
   55    pm->SetMarkerStyle(23);
 
   56    pm->SetMarkerColor(kRed);
 
   57    pm->SetMarkerSize(1.3);
 
   59    for (i = 0; i < nbins; i++) d->SetBinContent(i + 1,dest[i]);
 
   60    d->SetLineColor(kRed);
 
   63    printf(
"Found %d candidate peaks\n",nfound);
 
   64    for( i=0;i<nfound;i++) printf(
"posx= %f, posy= %f\n",fPositionX[i], fPositionY[i]);