Problem in adding the histograms

I have written a code to add all the histograms and then normalize the histograms for one set of sample and then plot . But the problem with my code is that it generates the root file having the name of the histograms but not the histograms . Its my request that if you can kindly have a look in to the code . I am attaching the code . If this code works then I guess a lot of problems will be solved .add_histo.C (3.39 KB) .

The input root files has a tree named physics inside which all the variables are there . Thank you very much in advance

What are you trying to do with this statement
TH1F* h1 =(TH1F*)t1->GetBranch(chvar[ivar])->Clone(buf);

t1->GetBranch() returns a TBranch* not a TH1*

Rene

Hey Thank you for your reply . Well what I was trying is to clone the branch in the historgram h1 . Can you tell me what I should do instead . I replaced the TH1F with TBranch , but not sure how combine the various branches after cloning as I was doing for the histograms since Add return TH1F and not TBranch.
My input root file has a tree named physics inside that the desired variables are there but I am not sure what to call it a leaf or a branch . The variables have the icon of leaf .

Hi,

Use the function TTree::Draw to create the histogram. See the User’s Guide chapter on TTree for more details.

Cheers,
Philippe.