Background_incr

Example to illustrate the background estimator (class TSpectrum).

Author: Miroslav Morhac, Olivier Couet
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Sunday, October 02, 2022 at 09:37 AM.

In [1]:
Int_t i;
const Int_t nbins = 1024;
Double_t xmin     = 0;
Double_t xmax     = nbins;
Double_t source[nbins];
gROOT->ForceStyle();

TH1F *d    = new TH1F("d","",nbins,xmin,xmax);

TString dir  = gROOT->GetTutorialDir();
TString file = dir+"/spectrum/TSpectrum.root";
TFile *f     = new TFile(file.Data());
TH1F *back = (TH1F*) f->Get("back1");
back->GetXaxis()->SetRange(1,nbins);
back->SetTitle("Estimation of background with increasing window");
back->Draw("L");

TSpectrum *s = new TSpectrum();

for (i = 0; i < nbins; i++) source[i] = back->GetBinContent(i + 1);
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

Estimate the background

In [2]:
s->Background(source,nbins,6,TSpectrum::kBackIncreasingWindow,
              TSpectrum::kBackOrder2,kFALSE,
              TSpectrum::kBackSmoothing3,kFALSE);

Draw the estimated background

In [3]:
for (i = 0; i < nbins; i++) d->SetBinContent(i + 1,source[i]);
d->SetLineColor(kRed);
d->Draw("SAME L");

Draw all canvases

In [4]:
gROOT->GetListOfCanvases()->Draw()