Logo ROOT  
Reference Guide
Background_gamma256.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Example to illustrate the background estimator (class TSpectrum2).

#include <TSpectrum2.h>
void Background_gamma256() {
Int_t i, j;
const Int_t nbinsx = 64;
const Int_t nbinsy = 64;
Double_t xmax = (Double_t)nbinsx;
Double_t ymax = (Double_t)nbinsy;
Double_t** source = new Double_t*[nbinsx];
for (i=0;i<nbinsx;i++)
source[i]=new Double_t[nbinsy];
TString dir = gROOT->GetTutorialDir();
TString file = dir+"/spectrum/TSpectrum2.root";
TFile *f = new TFile(file.Data());
auto back = (TH2F*) f->Get("back2");
auto *s = new TSpectrum2();
for (i = 0; i < nbinsx; i++){
for (j = 0; j < nbinsy; j++){
source[i][j] = back->GetBinContent(i + 1,j + 1);
}
}
for (i = 0; i < nbinsx; i++){
for (j = 0; j < nbinsy; j++)
back->SetBinContent(i + 1,j + 1, source[i][j]);
}
back->Draw("SURF2");
}
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:45
double Double_t
Definition: RtypesCore.h:59
float xmin
Definition: THbookFile.cxx:95
float ymin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
float ymax
Definition: THbookFile.cxx:95
#define gROOT
Definition: TROOT.h:404
R__EXTERN TStyle * gStyle
Definition: TStyle.h:414
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:257
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
static constexpr double s
Definition: file.py:1
Authors
Miroslav Morhac, Olivier Couet

Definition in file Background_gamma256.C.