Wrong histogram or wrong fitting

I have a histogram which is generated not by the regular filling (instead, by SetBinContent). I try to fit it with a Gaussian function defined by myself. I have tried v5.20 and v5.23. In v5.20, it seems that fitting did nothing, and showed pre-set parameters. I also tried pre-defined function ‘gaus’ in root, it works well. In v5.23, I was told that

“Warning in : Fit data is empty”

. I know the reason may be from my histogram, but I am not sure what is wrong there. My histogram and macros for test are attached.
test_fit.root (3.78 KB)
test_fit.C (291 Bytes)

You have called TH1::Sumw2 on your histogram and set the bin contents directly, so your errors are all null.
Try replacing

h->Fit(f, "", "", 0, 100); by

h->Fit(f, "w", "", 0, 100);