TTree::Draw with custom binning


here is the problem. I’d like to use TTree::Draw to drow a 2D histogram. That can be done by
Draw(“var1:var2>>h(nx,xmin,xmax,ny,ymin,ymax)”). The problem is that I need a not uniform binning.
Is that any option for that?

Or otherwise I could get a TGraph from the TTree::Draw is there then a way to convert it to a TH2 with custom binning?


You can do it if you create the non-fixed-bin histogram before, then use the >>+ syntax for filling with TTree::Draw.

Search for the string “append data to an existing histogram” at to see the relevant doc section.


Thanks Jean-François! This is exactly what I needed!