Getting Values from TTree events


Im trying to get values from a tree wich have several entries , or instances per event. I’m trying to do this as

Double_t energy;

then, if i do

mytree->GetEntry(# place a number)
(int ) 1640

variable energy is always 0, but i know that my tree is not empty.

Thanks in advance.

If you don’t know how to deal with your tree, see how various flavours of automatically generated “analysis skeletons” deal with it.

What is it that you are trying to accomplish?

file=TFile("myfile.root", "read");

if you’re trying to inspect your tree i prefer to use scan.


this will print all the myenergy elements. then you do something similar if you’re trying to draw it with the Draw() function. The syntax will be using -> pointers instead of . operators, since I’m using python (and your using C++).

Thanks for your answers,

What im trying to do is to read certain values from a tree , from certain events. I know that i can read values and print them in screen with Scan , but my idea is to save these values into an array, for example.

What is the ‘type’ of the branch myenergy (see for example the result of TTree::Print).