[ROOT] TChain odd access

From: Valeri Tioukov (Valeri.Tioukov@na.infn.it)
Date: Thu May 09 2002 - 16:56:09 MEST


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