Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Background_decr.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_spectrum
3 /// \notebook
4 /// Example to illustrate the background estimator (class TSpectrum).
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \authors Miroslav Morhac, Olivier Couet
10 
11 void Background_decr() {
12  Int_t i;
13  const Int_t nbins = 1024;
14  Double_t xmin = 0;
15  Double_t xmax = nbins;
16  Double_t source[nbins];
17  gROOT->ForceStyle();
18 
19  TH1F *d = new TH1F("d","",nbins,xmin,xmax);
20 
21  TString dir = gROOT->GetTutorialDir();
22  TString file = dir+"/spectrum/TSpectrum.root";
23  TFile *f = new TFile(file.Data());
24  TH1F *back = (TH1F*) f->Get("back1");
25  back->SetTitle("Estimation of background with decreasing window");
26  back->GetXaxis()->SetRange(1,nbins);
27  back->Draw("L");
28 
29  TSpectrum *s = new TSpectrum();
30 
31  for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
32 
33  // Estimate the background
34  s->Background(source,nbins,6,TSpectrum::kBackDecreasingWindow,
35  TSpectrum::kBackOrder2,kFALSE,
36  TSpectrum::kBackSmoothing3,kFALSE);
37 
38  // Draw the estimated background
39  for (i = 0; i < nbins; i++) d->SetBinContent(i + 1,source[i]);
40  d->SetLineColor(kRed);
41  d->Draw("SAME L");
42 }