Read a histogram from a file.root and refill its contents into a new hist with different bins


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi ,
I want to read a histogram from a file.root , and then refill its contents into a new histogram ,which is like the below:

     TFile *f1 = new TFile("file.root");//read a file
     TH1D h1* = (TH1D*) f1->Get("mass");// to get a hist
     TH1D *myhist = new TH1D("myhist","myhist",100,50,100);

then I want to get the contents of h1 to fill myhist , how should i do ?
Thanks a lot !

You should loop all the bins. Do GetBinContent on h1 and SetBinContent on myhist

TH1::Rebin
TH1::Merge
TH1::Add

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.