Error in filling TTree branch

Dear developers,

I am running a script and it is giving an error
" Error in TTree::Fill: Failed filling branch:AnaTree.VetoMu_idTight, nbytes=-1, entry=8679
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)
Kindly help me to resolve this error.
I am send you my script and root file.

output1_ajeeb_Veto.root (28.2 KB) (6.2 KB)



I think the error message is pretty clear. Kust create the file and then the tree and not vice versa.


You call “t->Fill();” but this is not a new TTree. It was read from a file and you retrieve its contents using “t->GetEntry(i);”.

No this is strange, because i am creating a file first then the tree. As in my script (10.5 KB)

Your code is full of errors… For example, you declare:

float VetoMu_px, VetoMu_py, VetoMu_pz, VetoMu_en, VetoMu_pt, VetoMu_eta, VetoMu_phi, VetoMu_iso, VetoMu, VetoMu_charge, VetoMu_ismuon, VetoMu_idTight;

And then, you access:

if (m1 == 0) tmp1.SetPxPyPzE(VetoMu_px[m1], VetoMu_py[m1], VetoMu_pz[m1], VetoMu_en[m1]);

This cannot work… (just try with ACLiC)

Dear Wile,

Can you please elaborate it. What I have to change

Hi bellenot,

I am getting these branches from the tree then make their Lorentz vector (in the step you mentioned).

Yes, I know, but you cannot declare a variable as float VetoMu_px and then try to use it as an array (of floats) VetoMu_px[m1]

Right, Then what I do to run this script.

First, you should try with ACLiC:

root [0] .x

And fix the errors reported by the compiler…

Right,many thanks to you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.