I have a TTree and would like to make a 1D histogram where the numbers in one column (integers) will be used for the X values for the bins in a 1D histogram and the entries in another column will be used for the entry value in the corresponding histogram bin. Can someone recommend an easy way to do this?
That format creates a 2D histogram with each entry in the tree doing an hfill at the X and Y location. What I’m looking for is a 1D location with the X bin value given by one tree column and the contents of that bin given by the other column.
I don’t think you can do this with a simple Draw command. You would need to create a histogram, set the branches, loop through all entries, and use either a weighted Fill or SetBinContent for each entry.
Have you tried:
that will connect te (x,y) points with a line.
This looks to be the only solution. I was hoping for something simpler but I did exactly what you suggested and that solved my problem.
I am sure what you mean but what about;
[remove unintentional extra text in 3rd parameter]
Sorry for the confusion about which comment I was replying to. I got what I wanted by looping over entries. I could not get the “L” option in tree->Draw to give me a 1D histogram.
the “L” was not intentional
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.