Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Background_gamma64.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_spectrum
3 /// \notebook
4 /// Example to illustrate the background estimator (class TSpectrum2).
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \authors Miroslav Morhac, Olivier Couet
10 
11 #include <TSpectrum2.h>
12 
13 #include <TSpectrum2.h>
14 void Background_gamma64() {
15  Int_t i, j;
16  const Int_t nbinsx = 64;
17  const Int_t nbinsy = 64;
18  Double_t xmin = 0;
19  Double_t xmax = (Double_t)nbinsx;
20  Double_t ymin = 0;
21  Double_t ymax = (Double_t)nbinsy;
22  Double_t ** source = new Double_t*[nbinsx];
23  for (i=0;i<nbinsx;i++)
24  source[i]=new Double_t[nbinsy];
25  TString dir = gROOT->GetTutorialDir();
26  TString file = dir+"/spectrum/TSpectrum2.root";
27  TFile *f = new TFile(file.Data());
28  auto back = (TH2F*) f->Get("back1");
29  gStyle->SetOptStat(0);
30  auto s = new TSpectrum2();
31  for (i = 0; i < nbinsx; i++){
32  for (j = 0; j < nbinsy; j++){
33  source[i][j] = back->GetBinContent(i + 1,j + 1);
34  }
35  }
36  s->Background(source,nbinsx,nbinsy,4,4,TSpectrum2::kBackDecreasingWindow,TSpectrum2::kBackSuccessiveFiltering);
37  for (i = 0; i < nbinsx; i++){
38  for (j = 0; j < nbinsy; j++)
39  back->SetBinContent(i + 1,j + 1, source[i][j]);
40  }
41  back->Draw("SURF1");
42 }