12 void Background_smooth() {
14 const Int_t nbins = 4096;
16 Double_t xmax = nbins;
17 Double_t source[nbins];
20 TH1F *d1 =
new TH1F(
"d1",
"",nbins,xmin,xmax);
21 TH1F *d2 =
new TH1F(
"d2",
"",nbins,xmin,xmax);
23 TString dir = gROOT->GetTutorialDir();
24 TString file = dir+
"/spectrum/TSpectrum.root";
25 TFile *f =
new TFile(file.Data());
26 TH1F *back = (TH1F*) f->Get(
"back1");
27 back->SetTitle(
"Estimation of background with noise");
28 back->SetAxisRange(3460,3830);
31 TSpectrum *s =
new TSpectrum();
33 for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
34 s->Background(source,nbins,6,TSpectrum::kBackDecreasingWindow,
35 TSpectrum::kBackOrder2,kFALSE,
36 TSpectrum::kBackSmoothing3,kFALSE);
37 for (i = 0; i < nbins; i++) d1->SetBinContent(i + 1,source[i]);
38 d1->SetLineColor(kRed);
41 for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
42 s->Background(source,nbins,6,TSpectrum::kBackDecreasingWindow,
43 TSpectrum::kBackOrder2,kTRUE,
44 TSpectrum::kBackSmoothing3,kFALSE);
45 for (i = 0; i < nbins; i++) d2->SetBinContent(i + 1,source[i]);
46 d2->SetLineColor(kBlue);