Hi,
I have a couple of questions. If I want to access the values of a branch “branch” at certain entries “entry1” and “entry2”, I commonly do:
TChain *chain = new TChain(“tree”);
chain->Add(filepath);
double p_branch;
chain->SetBranchAddress(“branch”,&p_branch);
chain->GetEntry(entry1); double value1 = p_branch;
chain->GetEntry(entry2); double value2 = p_branch;
cout << value1 << endl; cout << value2 << endl;
But I’ve notices this also works:
TChain *chain = new TChain(“tree”);
chain->Add(filepath);
TLeaf *p_branch = chain->GetLeaf(“branch”);
p_branch->GetBranch()->GetEntry(entry1); double value1 = p_branch->GetValue();
p_branch->GetBranch()->GetEntry(entry2); double value2 = p_branch->GetValue();
cout << value1 << endl; cout << value2 << endl;
My first question is, is there some important difference between these two ways? And also, as can be seen, why branches and leaves sometimes seem to have not a clear difference?
My second question is, I did all this because I want to Draw not one branch vs another but some calculation done in one branch vs another, for this I’m going to create two arrays (filling it with calculated values from the values of the branches) and then plot one vs another. Is there a better way?
Thanks!