Re: TH1 as TTree branch??

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Apr 16 1998 - 16:34:15 MEST


William J Deninger wrote:
> 
> Rene,
> How is one able to view via the TBrowser the "sum" of all histograms stored
> in a tree tree. Is it even possible?
> 
> Thanks again, William
> 
> //______________________
> // incorrect attempt
> //______________________
> {
> // open root file
>  TFile f= new TFile("test.root", "recreate");
>  f->SetCompressionLevel(1);
> 
> // create canvas.. for viewing stuff
>  TCanvas *c1 = new TCanvas("c1","canvas");
>  c1->cd();
> 
> // create tree
>  TTree *tree = new TTree("tree","test");
>  tree->SetAutoSave(64000000); // 64MB autosave
> 
> // create event tree branch
>  TSimple *simple = new TSimple;
>  TH1F *hist = new TH1F("hist","test histogram",100,0,100);
>  simple->hist = hist;
> 
>  tree->Branch("simple","TSimple",&simple,16000,1);
> 
> // loop filling tree with 100 items
>  Int_t i;
>  for (i=0; i<100; i++) { hist->Fill( (Float_t) i); tree->Fill(); }
> 
> // create browser
>  bb = new TBrowser;
>  tree->Draw("hist");
> }

You can  execute commands like:
   tree->Draw("hist.GetEntries()")
   tree->Draw("hist.GetMean()")
   tree->Draw("hist.GetBinContent(5)")

you can invoke any member function of the object in the branch.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET