Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Background_compton.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_compton() {
13  Int_t i;
14  const Int_t nbins = 256;
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 
22  TString dir = gROOT->GetTutorialDir();
23  TString file = dir+"/spectrum/TSpectrum.root";
24  TFile *f = new TFile(file.Data());
25  TH1F *back = (TH1F*) f->Get("back3");
26  back->SetTitle("Estimation of background with Compton edges under peaks");
27  back->GetXaxis()->SetRange(1,nbins);
28  back->Draw("L");
29 
30  TSpectrum *s = new TSpectrum();
31 
32  for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
33  s->Background(source,nbins,10,TSpectrum::kBackDecreasingWindow,
34  TSpectrum::kBackOrder8,kTRUE,
35  TSpectrum::kBackSmoothing5,kTRUE);
36  for (i = 0; i < nbins; i++) d1->SetBinContent(i + 1,source[i]);
37  d1->SetLineColor(kRed);
38  d1->Draw("SAME L");
39 }