#include #include "TCanvas.h" #include "TRandom.h" #include "TH2.h" #include "TF2.h" #include "TMath.h" #include "TROOT.h" #include "TCanvas.h" #include "TMath.h" #include "TH1.h" #include "TF1.h" #include "TRandom.h" #include "TVirtualFitter.h" TSpectrum2 *s; Int_t npeaks = 30; Double_t fpeaks2(Double_t *x, Double_t *par) { Double_t result = 0.1; for (Int_t p=0;pGetListOfCanvases()->FindObject("c1"); if (!c1) c1 = new TCanvas("c1","c1",10,10,1000,700); ifstream fin("image65_2.txt"); for (int i=0;i>content; if (content>=0.61||content<=0.43) { myhist2->SetBinContent(i+1,j+1,content); source[i][j] = myhist2->GetBinContent(i + 1,j + 1); } } } TSpectrum2 *s = new TSpectrum2(200); //now the real stuff: Finding the peaks Int_t nfound = s->SearchHighRes(source, dest, n,m, 4.2, 3, kTRUE, 1, kFALSE, 1); //searching good and ghost peaks (approximation) Int_t pf,ngood = 0; Float_t *xpeaks = s->GetPositionX(); Float_t *ypeaks = s->GetPositionY(); for (p=0;p nfound) ngood = nfound; //Search ghost peaks (approximation) Int_t nghost = 0; for (pf=0;pfPrint(); printf(" Found=%d, Good=%d, Ghost=%d\n",nfound,ngood,nghost); TPolyMarker *pm = new TPolyMarker(nfound, xpeaks, ypeaks); myhist2->GetListOfFunctions()->Add(pm); pm->SetMarkerStyle(23); pm->SetMarkerColor(kRed); pm->SetMarkerSize(2.); myhist2->Draw("COL"); c1->Update(); } void peaks2(Int_t maxpeaks=50) { s = new TSpectrum2(2*maxpeaks); for (int i=0; i<10; ++i) { npeaks = (Int_t)gRandom->Uniform(5,maxpeaks); findPeak2(); } }