Filling a 2-D histogram from two 1-D histograms

I’m needing to fill a 2-D histogram from two 1-D histograms with different
numbers of entries. All the examples I’ve seen show how to do this in a single
loop i.e. the same number of entries. Can I fill x vars in one loop and y vars
in another? Is there a simple one liner for this as in the case of trees:


This is something I need to do quite a bit. I typically keep my data stored in
trees. It would be really handy if it were possible to read in two variables
(using the Draw function) while applying different sets of TCuts to each.
Something along the lines of:

TH2F *hist1 = new TH2F(“hist1”, “title”, xbins, xlow, xhigh, ybins, ylow, yhihgh);
tree1.Draw(“var1:var2 >> hist1”, TCuts_var1, TCuts_var2);

or something similar. Is such a thing possible?


I do not understand your question. When using TTree::Draw you can specify boolean operators between your cuts.