Re: [ROOT] Diverting Branch to separate file

From: Dimitri Peressounko (peressou@in2p3.fr)
Date: Tue Mar 27 2001 - 11:54:58 MEST


         Dear Rene, 

I try your example with one more line:
br->SetFile("test.clones.root");  
and obtained exacly the same result as before:

root [0]  TFile * f = new TFile("test.root")
root [1] TTree * t = (TTree*) f->Get("tree")
root [2] t->GetBranch("Clones")->GetFileName()
(const char* 0x403ff98c)""


May be I am missing something? Why GetFileName is empty?

                      Dmitri.


On Tue, 27 Mar 2001, Rene Brun wrote:

> Hi Dimitri,
> 
> TBranch::SetFile acts on one branch only, not on its sub branches.
> In the case of a TClonesArray, one has to loop on all the subbranches as shown
> in the example below.
> Note that in case you have a few entries only, data are buffered in
> the branch baskets. If all the buffers fit in memory, they are written
> in one single block together with the tree header on the master file.
> In this case, the associated files will be empty.
> 
> Rene Brun
> 
> 
> {
>    TFile * f = new TFile("test.root","recreate");
>    TClonesArray *d = new TClonesArray("TObject",10);
>    TTree * t = new TTree("tree","a test");
>    TBranch *br =  t->Branch("Clones",&d,32000);
>    TIter next(br->GetListOfBranches());
>    TBranch *brc;
>    while((brc=(TBranch*)next())) {
>       brc->SetFile("test.clones.root");
>    }
>    for (Int_t i=0;i<1000;i++) {
>       for (Int_t j=0;j<(i%50);j++) {
>          TObject *obj = new ((*d)[j]) TObject();
>          obj->SetUniqueID(100*i+j);
>       }
>       t->Fill();
>    }
>    t->Print();
>    t->Write();
> }
> 
> 
> Dimitri Peressounko wrote:
> > 
> >    Hi, Rooters!
> > 
> > I am trying to divert branch ot TClonesArray to separate file:
> > 
> > root [0] TFile * f = new TFile("test.root","new")
> > root [1] TClonesArray * d = new TClonesArray("TObject",10)
> > root [2] TTree * t = new TTree("tree","a test")
> > root [3] TBranch * br =  t->Branch("Clones",&d,32000);
> > root [4] br->SetFile("test.clones.root")
> > root [5] t->GetBranch("Clones")->GetFileName()
> > (const char* 0x858a01c)"test.clones.root"
> > root [6] t->Fill()
> > (Int_t)4
> > root [7] t->Write()
> > (Int_t)761
> > root [8] .q
> > 
> > Now I am reading back this branch and find, that file = "".
> > 
> > root [0] TFile * f = new TFile("test.root")
> > root [1] TTree * t = (TTree *) f->Get("tree")
> > root [2] t->GetBranch("Clones")->GetFileName()
> > (const char* 0x403ff98c)""
> > 
> > file test.clones.root is not created as well.
> > What I am doing wrong?
> > 
> >              Dmitri
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:40 MET