Hey everyone,
I’ve worked with TTrees and TChains for weeks now, but I think I’ve never really understood the structure of a TTree.
I understood that a Tree has branches. But what are the entries? So, I have a tree with for example 10 Branches. When I have 5 Entries, does this means for every entry all 10 branches are filled?
I’ve got this question because in a code I wrote, I loop over all Entries, and than fill histograms with values at every entry but I’ve never told root like “take the branch of the entry where the loop is right now”.
I don’t know how to tell root to do that, but the histograms look fine, so does this happen automatically?
The part of the code is here. I’ve done this partly like the loop()-function of the MakeClass.
TChain *sig = new TChain("treename");
sig->AddFile(Form("/path/to/file/File.root");
Long64_t snentries = sig->GetEntries();
/*
tree_sig is object from MakeClass
it gets a TChain as parameter
*/
signal tree_sig(sig);
for (Long64_t jentry=0; jentry<snentries;jentry++) {
Long64_t ientry = tree_sig.LoadTree(jentry);
if (ientry < 0) break;
nb = tree_sig.GetEntry(jentry); nbytes += nb;
if(tree_sig.Branch1_size ==0 && tree_sig.Branch2_size==0){
for(Long64_t i = 0; i<tree_sig.Branch3_size; i++){
histo1_s->Fill(tree_sig.Branch3_1->at(i)); //Branch 3_1 is vector<float>
histo2_s->Fill(tree_sig.Branch3_2->at(i)); //Branch 3_2 is vector<float>
}
}
}
I know that my TChain only ontains one tree - is that the reason why there are no problems? But still my question is, how does the code know from which entry it should take the branches?
Or is my understanding of the entries wrong? This is a very basic question but I don’t have an idea right now, if you could help me, I would be glad
Best regards