I have a TTree object with, lets say, a 100 events on it
(tree->Show(0) will show all the leaves for the first event, tree->Show(1) for the second event, and so on).
I would like to access this information through
TLeaf* leaf = tree->GetLeaf(“some_information”)
however, this only get me the first event, so I was wondering how I can do that for any event.
When using for example:
TLeaf* leaf = tree->GetLeaf(“some_information”)
leaf -> GetEntry(1)
I receive an error
"
Error: Can’t call TLeaf::GetEntry(1) in current scope (tmpfile)(1)
Possible candidates are…
(in TLeaf)
*** Interpreter error recovered ***
"
I’m sorry for the trouble, i’m new to root
{
//Create a tree and fill it with some data
TTree *tree = new TTree("tree","Tree");
double value;
tree->Branch("value", &value);
for (int i=0;i<5000;i++) {
value = i;
tree->Fill();
}
tree->ResetBranchAddresses();
//Get the pointer to the leaf.
TLeaf * leaf = tree->GetLeaf("value");
//Get each entry in the tree (first 10) and print it to the screen.
for (int i=0;i<10;i++) {
tree->GetEntry(i);
std::cout << leaf->GetValue() << "\n";
}
}