Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Background_smooth.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) including
5 /// Compton edges.
6 ///
7 /// \macro_image
8 /// \macro_code
9 ///
10 /// \authors Miroslav Morhac, Olivier Couet
11 
12 void Background_smooth() {
13  Int_t i;
14  const Int_t nbins = 4096;
15  Double_t xmin = 0;
16  Double_t xmax = nbins;
17  Double_t source[nbins];
18  gROOT->ForceStyle();
19 
20  TH1F *d1 = new TH1F("d1","",nbins,xmin,xmax);
21  TH1F *d2 = new TH1F("d2","",nbins,xmin,xmax);
22 
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);
29  back->Draw("L");
30 
31  TSpectrum *s = new TSpectrum();
32 
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);
39  d1->Draw("SAME L");
40 
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);
47  d2->Draw("SAME L");
48 }