Drawing graph from tree

Dear Rooters,

I would like to draw a graph from the tree.
A simple working example included with this message. It shows that default option is working, however when I try to change binning size to 100 it does not make a plot (commented line in the script).

Could you pleas give me your suggestions what should be change in the script?

Thank you.
27 September, 2010
r_test.cxx (920 Bytes)

By default the created histogram (when you specify one) is attached to the current directory.
When the directory goes out of scope your object is deleted. In fact it is drawn then deleted immediatly.
See chapter on Object Ownership in the Users Guide.
You have 2 solutions
1-you take the ownership by adding at the beginning of your script

TH1::AddDirectory(kFALSE); 2-you do not create your TFile object in the stack but in the heap via new


Thanks Rene,

It works.
I have to learn C++ and Root-manual better.