// root.cern.ch/root/htmldoc/guides/spectrum/Spectrum.html#dimensional-spectra
// root.cern.ch/doc/master/Background__compton_8C.html
// See: M.Morhac et al., Nucl. Instr. Meth. A 401, 113 (1997)
// Example to illustrate the background estimator (class TSpectrum) including
// Compton edges.
//
// Authors: Miroslav Morhac, Olivier Couet
void Background_compton ()
{
Int_t i;
Int_t nbins = 512;
Double_t xmin = 0;
Double_t xmax = nbins;
Double_t* source = new Double_t [nbins];
gROOT->ForceStyle ();
TFile* f = new TFile ("TSpectrum.root");
TH1F* hdata = (TH1F*) f->Get("back3");
hdata->SetTitle ("Estimation of background with Compton edges under peaks");
hdata->GetXaxis()->SetRange (1, nbins);
hdata->Draw ("L");
TSpectrum* Analyser1dim = new TSpectrum ();
for (i = 0; i < nbins; i++) source[i] = hdata->GetBinContent (i+1);
Analyser1dim->Background (
source, nbins, 10, TSpectrum::kBackDecreasingWindow,
TSpectrum::kBackOrder8, kTRUE,
TSpectrum::kBackSmoothing5, kTRUE);
/*
const char* TSpectrum::Background ( ..., bool compton );
bool compton: whether the estimation of Compton edge will be included. (0/1)
See: root.cern.ch/doc/v608/classTSpectrum.html#a7830480612d1ee301964e6c79319f444
*/
TH1F *hbkgnd1 = new TH1F ("hbkgnd1", "", nbins, xmin, xmax);
for (i = 0; i < nbins; i++) hbkgnd1->SetBinContent (i+1, source[i]);
hbkgnd1->SetLineColor (kRed);
hbkgnd1->Draw ("SAME L");
}