Getting Values from TTree events

Hi,

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;
mytree->SetBranchAddress(“myenergy”,&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");
tree=file.Get("tree")

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

tree.Scan("myenergy","","colsize=20")

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).