Fitting Poisson

Getting memory leak after trying to fit histogram data to poisson function
{

f=new TF1(“f”, “TMath::Poisson(x,[0])”, 0, 16);

h=new TH1D("h", "Histogram", 100, 0, 16);
h->Fill(2,3);
h->Fill(3, 13);
h->Fill(4, 22);
h->Fill(5, 26);
h->Fill(6, 31);
h->Fill(7, 45);
h->Fill(8, 46);
h->Fill(9, 42);
h->Fill(10, 26);
h->Fill(11, 18);
h->Fill(12, 14);
h->Fill(13, 8);
h->Fill(14, 5);
h->Fill(15, 2);	


c= new TCanvas();
h->Draw("hist");
h->Fit("f", "R");
f->Draw("SAME");

}


You need to give an initial value to the parameter/s of the fit function. Search for SetParameter in ROOT: TF1 Class Reference
Also, your data are not normalised, so you should multiply f by an additional (‘amplitude’) parameter, of course giving it an initial value too.

Thank you.