Histogram from TTree with the sum in each bin, not the mean

Dear rooters,

I am trying to figure out a way to plot a histogram where each bin shows the sum of the weights in the bin instead of the mean of the weights in the bin.
Since I am using TTree::Draw to plot the histogram, I am wondering if there exists any TTree option or TH1 option or any trick that would allow me to call TTree::Draw(“x”,"",“option”) and have a histogram of the sum of x in each bin, not the mean of x in each bin.

I hope I did not miss anything obvious but as far as I know I can only deal with such thing within macros where I would multiply each bin by its number of entries… not easy to handle!

Thanks a lot in advance,


Try (see the TTree::Draw method description for explanations):
YourTree->Draw(“x”, “x”, “any draw options”); // the “selection expression” is used as a “weight”

Unless you wanted to “normalize” your histogram … then see [url]Different ways of normalizing histograms