Re: [ROOT] Save list of objects on Ttree

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Nov 17 2003 - 19:18:25 MET


Hi Pavel,

In addition to previous comments about buffer size, use split level = 1.
Move to a recent version (eg 3.05/07 or 3.10/01)
Here is a working example

void pavel() {
   TFile f_out("pavel.root","recreate");
   TTree *tree = new TTree("tree","2D matrix");

   TList *list = new TList;

   TH1F *h1 = new TH1F("h1","h1 title",100,-3,3);
   h1->FillRandom("gaus");
   TH1F *h2 = new TH1F("h2","h2 title",100,-3,3);
   h2->FillRandom("gaus",20000);
   list->Add(h1);
   list->Add(h2);
   
   tree->Branch(list,32000,1);
   tree->Fill();
   h1->FillRandom("gaus");
   h2->FillRandom("gaus",20000);
   tree->Fill();
   tree->Print();
   tree->Write();
}
   
Rene Brun

Pavel Golubev wrote:
> 
> Hi rooters,
> I have problem to save list of objects (TH2F histograms) on Ttree.
> I am running ROOT Version 3.02/07
> After
> 
> TFile f_out(out_file,"recreate");
> TTree *tree = new TTree("tree","2D matrix");
> 
> TList *list = new TList;
> 
> I create and fill number of TH2F histograms in the TList *list.
> 
> list->Add(hist);
> hist -> Fill(x, y, 1);
> 
> Than I use special branch constructor TTree::Branch(TList*list, Int_t
> bufsize, Int_t splitlevel)
> as suggested on ROOTtalk.
> 
> tree->Branch(list,70000000,2);
> tree->Fill();
> 
> But the output file seem to me does not contain any TH2F histograms.
> Also I get messages "R__zip: source buffer too big".
> Best regards,
> /Pavel



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET