Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Background_synt256.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
13void Background_synt256() {
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("back3");
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,
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("SURF2");
42}
#define f(i)
Definition RSha256.hxx:104
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
float xmin
float ymin
float xmax
float ymax
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:412
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:251
Advanced 2-dimensional spectra processing.
Definition TSpectrum2.h:18
@ kBackSuccessiveFiltering
Definition TSpectrum2.h:34
@ kBackIncreasingWindow
Definition TSpectrum2.h:32
Basic string class.
Definition TString.h:136
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1589
Definition file.py:1