#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;pSetStats(0); //generate n peaks at random Double_t par[3000]; Int_t p; Double_t** source = new Double_t*[nbinsx]; for (int i=0;i>content; if (content>=0.6||content<=0.45) { 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, 0.1, 0.4, kTRUE, 1, kFALSE, 1); //searching good and ghost peaks (approximation) Int_t pf,ngood = 0; Double_t *xpeaks = s->GetPositionX(); Double_t *ypeaks = s->GetPositionY(); for (p=0;p nfound) ngood = nfound; //Search ghost peaks (approximation) Int_t nghost = 0; for (pf=0;pfDraw("CONT2"); s->Print(); printf("Gener=%d, Found=%d, Good=%d, Ghost=%d\n",npeaks,nfound,ngood,nghost); }