{ gSystem.Load("JansEvent_cc"); JansEvent *j = new JansEvent(); f = TFile ("x.root"); tin = (TTree*)f.Get("bugMe"); tin.SetBranchAddress("event",&j); fout = new TFile("xPy.root", "recreate"); t = new TTree("bugMe", "Sample events"); t.Branch("event", "JansEvent", &j, 32000, 99); int iEv = 0; int iWritten = 0; while (iWritten<5) { tin.GetEvent(iEv); printf("%d%s\n",j.bList.GetEntries(), "entries"); j.bList.Clear(); printf("%d%s\n",j.bList.GetEntries(), "entries"); B_Parameters *b = (B_Parameters*)j.bList[0]; printf("%d\n",b->gamma.uid); for(int i =0; ibList.GetEntries();++i){ //iB in j.bList: b = (B_Parameters*)j.bList[i]; printf("%d\n",b->gamma.uid); } iEv += 1; if (j.bList.GetEntries() > 2) j->bList.RemoveAt(1); j.bList.Clear(); t.Fill(); iWritten += 1; } t.Write(); fout.Close(); delete fout; delete tin; }