14 Double_t fPositionX[100];
15 Double_t fPositionY[100];
18 const Int_t nbins = 1024;
20 Double_t xmax = nbins;
22 Double_t source[nbins], dest[nbins];
25 TString dir = gROOT->GetTutorialDir();
26 TString file = dir+
"/spectrum/TSpectrum.root";
27 TFile *f =
new TFile(file.Data());
28 TH1F *h = (TH1F*) f->Get(
"back2");
29 h->SetTitle(
"Influence of # of iterations in deconvolution in peak searching");
30 h->GetXaxis()->SetRange(1,nbins);
32 TH1F *d1 =
new TH1F(
"d1",
"",nbins,xmin,xmax);
33 TH1F *d2 =
new TH1F(
"d2",
"",nbins,xmin,xmax);
34 TH1F *d3 =
new TH1F(
"d3",
"",nbins,xmin,xmax);
35 TH1F *d4 =
new TH1F(
"d4",
"",nbins,xmin,xmax);
37 TSpectrum *s =
new TSpectrum();
39 for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
40 nfound = s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 3, kTRUE, 3);
42 Double_t *xpeaks = s->GetPositionX();
43 for (i = 0; i < nfound; i++) {
45 bin = 1 + Int_t(a + 0.5);
46 fPositionX[i] = h->GetBinCenter(bin);
47 fPositionY[i] = h->GetBinContent(bin);
49 TPolyMarker * pm = (TPolyMarker*)h->GetListOfFunctions()->FindObject(
"TPolyMarker");
51 h->GetListOfFunctions()->Remove(pm);
54 pm =
new TPolyMarker(nfound, fPositionX, fPositionY);
55 h->GetListOfFunctions()->Add(pm);
56 pm->SetMarkerStyle(23);
57 pm->SetMarkerColor(kRed);
58 pm->SetMarkerSize(1.3);
62 for (i = 0; i < nbins; i++) d1->SetBinContent(i + 1,dest[i]);
63 d1->SetLineColor(kRed);
66 for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
67 s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 10, kTRUE, 3);
68 for (i = 0; i < nbins; i++) d2->SetBinContent(i + 1,dest[i]);
69 d2->SetLineColor(kBlue);
72 for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
73 s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 100, kTRUE, 3);
74 for (i = 0; i < nbins; i++) d3->SetBinContent(i + 1,dest[i]);
75 d3->SetLineColor(kGreen);
78 for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
79 s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 1000, kTRUE, 3);
80 for (i = 0; i < nbins; i++) d4->SetBinContent(i + 1,dest[i]);
81 d4->SetLineColor(kMagenta);
84 printf(
"Found %d candidate peaks\n",nfound);