TTree::Draw 2d histogram with weight?

Hi all.

I have a tree (t) with three variables (var1, var2, var3) and I want to plot var3 in a 2d histogram (drawoption colz) var1 versus var2. I’d like to do this with draw as I otherwise have to rewrite a lot in my code (the proper way would be with h.fill(var1, var2, var3) with var3 the weight and h the TH2F with Sumw2 set). Is there a good way to do this directly with Draw into a TH2F? Or should I be drawing to a TH3F and then project along the var3 axis?

Thank you for any suggestions.

tree->Draw(“var2:var1”, “var3”, “colz”); … ree:Draw@2

Thank you. It works.