Creating a Bar Graph using TH1

I have an (x,y) data set like the following:

1.00,456.21
3.50,12.00
5.00,12123.34
10.00,23498.00

  •   *
    
  •   *
    
  •   *
    

where the first column goes to a maximum of 3000.00 but at irregular intervals. I would like to aggregate the first column into bins and have the height of each bin be the sum of the corresponding values in the second column for each value falling in that bin.

Loading the data into a TTree and then doing a tree->Draw(“col2:co1”) gives me an x,y scatter plot which I can if I want make into a bar graph. I just do not know how to aggregate the values into histogram like bins (although I have written a script to do it outside ROOT). Any help with how to do this would be much appreciated.

Thanks

Try:
tree->Draw(“col2:co1>>MyHisto”)
Search for “>>” in the TTree::Draw method description.