Understand Entries in leafs and Getting error while accessIT

Hello all,

I am filling the branch only 622 times while the entries in the leaf showing value 194375. I could not understand it why? When I do tree->Print(); even then it is showing 622 entries corresponding to each branches.
I am filling branches like

TClonesArray *Llep0 = new TClonesArray("TLorentzVector"); TClonesArray &aLlep0 = *Llep0; new(aLlep0[BKGnumber]) TLorentzVector(bkgReader.at(0), //PG px bkgReader.at(1), //PG py bkgReader.at(2), //PG pz bkgReader.at(3) //PG E );
You can have a look at tree at the link bit.ly/14s6nD0 .

Next Problem: When I am trying to access the leaf from the tree then I am getting the segmentation fault. at the last line of

[code] TFile *lhe = new TFile(“lhe.root”, “READ”);
if (!(lhe && lhe->IsOpen())) { delete lhe; return -1; }

TTree *tree;
lhe->GetObject(“tree”, tree);
if (!tree) { delete lhe; return -2; }

tree->SetMakeClass(1); // all branches in decomposed object mode
tree->SetBranchStatus("*", 0); // disable all branches

Int_t Llep0_ = -1;
tree->SetBranchStatus(“Llep0”, 1); // activate “Llep0”
tree->SetBranchAddress(“Llep0”, &Llep0_);
The code that I was using for it is Analyze_LHE.C (1.22 KB). Please suggest what may be I am doing wrong.

Thanks & regards,
Ram Krishna

194375 = (2 + 623) * 622 / 2
P.S. See also the ${ROOTSYS}/tutorials/tree/tcl.C example macro.
Analyze_LHE.C (1.5 KB)

Thank you very much Coyote. Now code is working. :smiley:

But I could not understand how you gave the number of entries: [quote=“Wile E. Coyote”]194375 = (2 + 623) * 622 / 2[/quote]. I didn’t get why you used 2 & 623 (622 is the number of entries?)?

Also I tried to understand this with the link you provided (i.e. root.cern.ch/root/html534/tutor … tcl.C.html), but could not get.

It seems to me that you have a “finite arithmetic progression” of the number of “Llep0” slots (with a “common difference” of 1).
There are 622 entries in the “tree”.
The first “tree” entry has 2 slots in “Llep0”, …, and finally the last “tree” entry has 623 slots in “Llep0”.
So, the “arithmetic series” (i.e. the sum of all members) is 622 * (2 + 623) / 2 = 194375
BTW. It seems to me that, for each “tree” entry, the very first slot in “Llep0” (i.e. “Llep0_->At(0)”) is always empty.