Logo ROOT  
Reference Guide
SearchHR1.C File Reference

Detailed Description

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

Found 11 candidate peaks
posx= 351.500000, posy= 5492.546875
posx= 289.500000, posy= 4819.614258
posx= 645.500000, posy= 5924.250000
posx= 445.500000, posy= 5238.460938
posx= 540.500000, posy= 5092.015625
posx= 600.500000, posy= 5099.656250
posx= 873.500000, posy= 4961.125000
posx= 927.500000, posy= 4711.515625
posx= 705.500000, posy= 4609.722656
posx= 987.500000, posy= 4136.967773
posx= 777.500000, posy= 4112.816406
void SearchHR1() {
Double_t fPositionX[100];
Double_t fPositionY[100];
Int_t fNPeaks = 0;
Int_t i,nfound,bin;
const Int_t nbins = 1024;
Double_t xmax = nbins;
Double_t source[nbins], dest[nbins];
TString dir = gROOT->GetTutorialDir();
TString file = dir+"/spectrum/TSpectrum.root";
TFile *f = new TFile(file.Data());
TH1F *h = (TH1F*) f->Get("back2");
h->SetTitle("High resolution peak searching, number of iterations = 3");
TH1F *d = new TH1F("d","",nbins,xmin,xmax);
for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
TSpectrum *s = new TSpectrum();
nfound = s->SearchHighRes(source, dest, nbins, 8, 2, kTRUE, 3, kTRUE, 3);
Double_t *xpeaks = s->GetPositionX();
for (i = 0; i < nfound; i++) {
bin = 1 + Int_t(a + 0.5);
fPositionX[i] = h->GetBinCenter(bin);
fPositionY[i] = h->GetBinContent(bin);
TPolyMarker * pm = (TPolyMarker*)h->GetListOfFunctions()->FindObject("TPolyMarker");
if (pm) {
delete pm;
pm = new TPolyMarker(nfound, fPositionX, fPositionY);
for (i = 0; i < nbins; i++) d->SetBinContent(i + 1,dest[i]);
printf("Found %d candidate peaks\n",nfound);
for( i=0;i<nfound;i++) printf("posx= %f, posy= %f\n",fPositionX[i], fPositionY[i]);
#define d(i)
Definition: RSha256.hxx:102
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:45
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
@ 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
float xmin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
#define gROOT
Definition: TROOT.h:404
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
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:574
A PolyMarker is defined by an array on N points in a 2-D space.
Definition: TPolyMarker.h:31
Advanced Spectra Processing.
Definition: TSpectrum.h:18
Basic string class.
Definition: TString.h:136
static constexpr double s
Definition: file.py:1
TArc a
Definition: textangle.C:12
Miroslav Morhac, Olivier Couet

Definition in file SearchHR1.C.