Logo ROOT  
Reference Guide
Src.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example to illustrate high resolution peak searching function (class TSpectrum2).

Found 5 candidate peaks
posx= 32, posy= 18, value=2164
posx= 29, posy= 42, value=1959
posx= 24, posy= 26, value=1667
posx= 16, posy= 29, value=1631
posx= 20, posy= 46, value=1334
#include <TSpectrum2.h>
void Src() {
Int_t i, j, nfound;
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];
Double_t** dest = new Double_t*[nbinsx];
for (i=0;i<nbinsx;i++)
dest[i]=new Double_t[nbinsy];
TString dir = gROOT->GetTutorialDir();
TString file = dir+"/spectrum/TSpectrum2.root";
TFile *f = new TFile(file.Data());
auto search = (TH2F*) f->Get("search4");
auto *s = new TSpectrum2();
for (i = 0; i < nbinsx; i++){
for (j = 0; j < nbinsy; j++){
source[i][j] = search->GetBinContent(i + 1,j + 1);
}
}
nfound = s->SearchHighRes(source, dest, nbinsx, nbinsy, 2, 5, kTRUE, 3, kFALSE, 3);
printf("Found %d candidate peaks\n",nfound);
Double_t *PositionX = s->GetPositionX();
Double_t *PositionY = s->GetPositionY();
search->Draw("COL");
auto m = new TMarker();
m->SetMarkerStyle(23);
m->SetMarkerColor(kRed);
for (i=0;i<nfound;i++) {
printf("posx= %d, posy= %d, value=%d\n",(Int_t)(PositionX[i]+0.5), (Int_t)(PositionY[i]+0.5),
(Int_t)source[(Int_t)(PositionX[i]+0.5)][(Int_t)(PositionY[i]+0.5)]);
m->DrawMarker(PositionX[i],PositionY[i]);
}
}
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:89
@ kRed
Definition: Rtypes.h:64
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
#define gROOT
Definition: TROOT.h:406
R__EXTERN TStyle * gStyle
Definition: TStyle.h:410
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
Manages Markers.
Definition: TMarker.h:23
Advanced 2-dimensional spectra processing.
Definition: TSpectrum2.h:18
Basic string class.
Definition: TString.h:131
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:1590
static constexpr double s
Definition: file.py:1
auto * m
Definition: textangle.C:8
#define dest(otri, vertexptr)
Definition: triangle.c:1040
Authors
Miroslav Morhac, Olivier Couet

Definition in file Src.C.