Re: TH1 as TTree branch??

William J Deninger (deninger@uiuc.edu)
Thu, 9 Apr 1998 20:42:29 -0500


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");
}

//______________________
class Show : public TObject
{
...
TH1F *hist;
}

-----Original Message-----
From: Rene Brun <Rene.Brun@cern.ch>
To: William J Deninger <deninger@uiuc.edu>
Cc: Rene Brun <brun@hpbrun.cern.ch>; roottalk <roottalk@hpsalo.cern.ch>
Date: Monday, April 06, 1998 1:46 AM
Subject: Re: TH1 as TTree branch??

>William J Deninger wrote:
>>
>> Does this also apply to classes inheriting TH1F? (Further modification
of
>> my analysis code has brought about this question)
>>
>> William Deninger
>>
>> >
>> >> Hello,
>> >>
>> >> Is it possible to have a TH1F histogram as a data member in a TTree
>> branch? I remember reading something about this, but I wasn't able to
find
>> it in root talk previous.
>
>a TH1F object is a TObject.
>Any TObject can be a branch. Example of a class with several TObject
>
>class Show : public TObject {
> TNamed *fNamed;
> TH1F *fH1;
> TList *fArrayofPulses;
> TObjArray *fSomeArrayofObjects;
>
>
>Rene Brun
>