Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Background_gamma256.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 void Background_gamma256() {
14  Int_t i, j;
15  const Int_t nbinsx = 64;
16  const Int_t nbinsy = 64;
17  Double_t xmin = 0;
18  Double_t xmax = (Double_t)nbinsx;
19  Double_t ymin = 0;
20  Double_t ymax = (Double_t)nbinsy;
21  Double_t** source = new Double_t*[nbinsx];
22  for (i=0;i<nbinsx;i++)
23  source[i]=new Double_t[nbinsy];
24  TString dir = gROOT->GetTutorialDir();
25  TString file = dir+"/spectrum/TSpectrum2.root";
26  TFile *f = new TFile(file.Data());
27  auto back = (TH2F*) f->Get("back2");
28  gStyle->SetOptStat(0);
29  auto *s = new TSpectrum2();
30  for (i = 0; i < nbinsx; i++){
31  for (j = 0; j < nbinsy; j++){
32  source[i][j] = back->GetBinContent(i + 1,j + 1);
33  }
34  }
35  s->Background(source,nbinsx,nbinsy,8,8,TSpectrum2::kBackIncreasingWindow,TSpectrum2::kBackSuccessiveFiltering);
36  for (i = 0; i < nbinsx; i++){
37  for (j = 0; j < nbinsy; j++)
38  back->SetBinContent(i + 1,j + 1, source[i][j]);
39  }
40  back->Draw("SURF2");
41 }