How to fill 2d histo with function?

Use the functions from TH2 here (Also note that TH2 derives from TH1. You can unfold the TH1 section.)

Make a TF2 from your fit function, and then use myHistogram->Add(myTF2, -1) to subtract the function from the histogram.