Error bars for weighted histograms

I am filling 1D histograms with weights and want to know the error in each bin, I do TH1F::GetBinError() which returns the squrae root of the contents of the bin, this is true for w(i) = 1 case, but not when the weights are different than 1. any ideas how I can get the correct errors?

You forgot to call TH1::Sumw2
see documentation of TH1::GetBinError … etBinError