Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Src3.C File Reference

Detailed Description

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

Found 13 candidate peaks
posx= 46, posy= 44, value=1962
posx= 39, posy= 4, value=1829
posx= 46, posy= 19, value=1762
posx= 50, posy= 32, value=1745
posx= 23, posy= 56, value=1710
posx= 35, posy= 48, value=1546
posx= 19, posy= 3, value=1524
posx= 39, posy= 58, value=1499
posx= 15, posy= 22, value=1376
posx= 38, posy= 16, value=1170
posx= 4, posy= 21, value=1166
posx= 10, posy= 16, value=1013
posx= 8, posy= 35, value=708
#include <TSpectrum2.h>
void Src3()
{
const Int_t nbinsx = 64;
const Int_t nbinsy = 64;
std::vector<Double_t *> source(nbinsx), dest(nbinsx);
for (Int_t i = 0; i < nbinsx; i++) {
source[i] = new Double_t[nbinsy];
dest[i] = new Double_t[nbinsy];
}
TString dir = gROOT->GetTutorialDir();
TString file = dir + "/spectrum/TSpectrum2.root";
TFile *f = TFile::Open(file.Data());
auto search = (TH2F *)f->Get("search1");
for (Int_t i = 0; i < nbinsx; i++) {
for (Int_t j = 0; j < nbinsy; j++) {
source[i][j] = search->GetBinContent(i + 1, j + 1);
}
}
Int_t nfound = s.SearchHighRes(source.data(), dest.data(), nbinsx, nbinsy, 2, 2, kFALSE, 3, kFALSE, 1); // 3, 10, 100
printf("Found %d candidate peaks\n", nfound);
Double_t *PositionX = s.GetPositionX();
Double_t *PositionY = s.GetPositionY();
search->Draw("CONT");
for (Int_t 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]);
}
for (Int_t i = 0; i < nbinsx; i++) {
delete[] source[i];
delete[] dest[i];
}
}
#define f(i)
Definition RSha256.hxx:104
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
@ kRed
Definition Rtypes.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:38
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:40
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
Definition TFile.h:53
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4070
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:258
Manages Markers.
Definition TMarker.h:22
virtual TMarker * DrawMarker(Double_t x, Double_t y)
Draw this marker with new coordinates.
Definition TMarker.cxx:204
Advanced 2-dimensional spectra processing.
Definition TSpectrum2.h:18
Double_t * GetPositionY() const
Definition TSpectrum2.h:45
Int_t SearchHighRes(Double_t **source, Double_t **dest, Int_t ssizex, Int_t ssizey, Double_t sigma, Double_t threshold, Bool_t backgroundRemove, Int_t deconIterations, Bool_t markov, Int_t averWindow)
This function searches for peaks in source spectrum It is based on deconvolution method.
Double_t * GetPositionX() const
Definition TSpectrum2.h:44
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:378
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:1636
TMarker m
Definition textangle.C:8
Authors
Miroslav Morhac, Olivier Couet

Definition in file Src3.C.