Hi Valeri, Thanks for reporting this problem with TChain. Now fixed in CVS. The problem is due to the two consecutive calls SetBranchAddress,GetEntries. You can get your test working if you add the line chain->GetEntry(0) just before calling GetEntries(); Rene Brun Valeri Tioukov wrote: > > Hi rooters, > > Why the applied script do not work in case of chains? > > Event - is the Event calss from root/test > > If comment out lines correspondent to chain and uncomment TTree, > everything works fine. > > I use root 3.03/05 (with previous version it was the same) > > Regards, > Valeri > > //---test.C------------------------------------------------------------ > > TFile *f = 0; > //TTree *chain =0; > TChain *chain =0; > > void test() > { > gSystem->Load("libEvent.so"); > > chain = new TChain("T"); > chain->Add("Event.root"); > > //f = new TFile("Event.root"); > //chain = (TTree*)f->Get("T"); > > Event *event = new Event(); // in case of chain new required! Why? > > chain->SetBranchStatus("*",1); > chain->SetBranchStatus("fTracks*",0); > chain->SetBranchAddress("event",&event); > > int entries = chain->GetEntries(); > printf("chain has %d entries\n",entries); > > for(int i=0; i<entries; i++ ) { > chain->GetEntry(i); > printf("entry %d with %d tracks\n",i,event->GetNtrack()); > } > } > //-------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET