TTree write problem

Hi,
I’m developing a multithread application using a TList of TTree
as shared data container between two different threads;

the first thread adds TTree to TList:


while( … ) {

  list->Add(new TTree("T1", "Fazia data event"));
  t1 = (TTree *) list->Last();
  t1->Branch("b", "FzEvent", &ev1, 16000, 2);

  for(int j=0; j<10; j++) {

     ev1->SetRegid(1);
     ev1->SetBlkid(1);
     ev1->SetFeeid(2);
     ev1->SetTelid(2);
     ev1->SetDetid(1);
     ev1->SetGttag(3412);
     ev1->SetDettag(3390);
     ev1->SetTs(t);
     ev1->SetEc(j);
     ev1->SetDtype(n);

     for(int i=0; i<1000; i++)
        ev1->AddData((ULong_t)10 * gRandom->Rndm());

     t1->Fill();

     ev1->Clear();
  }

}

while a second thread read TList elements (TTree) and
invoke the Write() method:


filename << RUNTAG << ‘-’ << t << ‘-’ << STEPTAG << “.root”;
TFile f(filename.str().c_str(), “recreate”, “xyz”);
TTree *t2;
UInt_t nevent = 0;

while( t2 = (TTree *) list->First() ) {

  t2->Write();

  nevent = t2->GetEntries();

  cout << "# of events : " << nevent << endl;

  for (Int_t i=0; i<nevent; i++) {

     t2->GetEntry(i);
     cout << "Event Counter for event # " << i << " -> " <<  ev1->GetEc() << " TTree num: " << ev1->GetDtype() << endl;
  }

  list->Remove(t2);

}

f.Close();

(I’m using ROOT 5.32/00)

the ROOT file is wrote correctly but instead of a single TTree "T1"
I read in the file a lot of TTree objects “T1;1”, “T1;2”, "T1;3"
and so on… how can I avoid this problem ?

I would like to read a single “T1” TTree from ROOT file…

Thanks in advance,
Gennaro

[url]Aux;1 aux;2 aux3;

Thanks a lot !

Regards,
Gennaro