Int_t npeaks = 30; double fpeaks(double *x, double *par) { double result = par[0] + par[1]*x[0]; for (Int_t p=0;pRndm()*980; // "mean" par[3*p+4] = 3+2*gRandom->Rndm(); // "sigma" } TF1 *f = new TF1("f",fpeaks,0,1000,2+3*npeaks); f->SetNpx(1000); f->SetParameters(par); auto *c1 = new TCanvas(); h->FillRandom("f",200000); TSpectrum *s = new TSpectrum(2*npeaks); Int_t nfound = s->Search(h,2,"",0.10); TList *functions = h->GetListOfFunctions(); TPolyMarker *pm = (TPolyMarker*)functions->FindObject("TPolyMarker"); double *xp = pm->GetX(); double *yp = pm->GetY(); int n = pm->GetN(); for (int i = 1; iDraw(); } }