I am new to ROOT, so this is a very basic question. I have a tree called D0Tree, and it has a branch called “NV0”. There are 50 entries in D0Tree, and NV0 is an integer for each entry. I want to store these integers in an array so I can do some analysis, but I am getting errors. I did something like this:
int nevents = D0Tree->GetEntries();
int NV0array[nevents];
I get the following error:
Error: Failed to evaluate class member ‘NV0’ (D0Tree->NV0)
The problem is somewhere in the for loop, but I don’t know the right way to do it. Thanks for the help.
You have several solutions depending if you simply want to read one single variable or more
1- Use TTree::MakeClass to generate a skeleton analysis code.
do:
D0Tree->MakeClass("T"); //this generates T.h and T.C
edit T.C with inside the loop
NV-Array[j] = NVO;
2- Set the branch address
[code] int nevents = D0Tree->GetEntries();
int NV0array[nevents];
int NVO;
D0Tree->SetBranchAddress(“NV0”,&NV0);
TBranch *bNVO = DOTree->GetBranch(“NVO”);