How make histogram from two histograms with different number bins?

I have two histograms with different number of bins.
h1 = new TH1I(“h1”, “h1”,130, 12, 142);
h2 = new TH1I(“h2”, “h2”,160, 16, 176);
How to make h3 with sum of h1 and h2 .

As I understand it you will need to book h3 with a range containing h1 and h2 ranges.

h3 = new TH1I(“h3”, “h3”, nbins3, 12, 176);

Then you need two loops, one on all h1 bins and one on all h2 bins. For each bin you get its content (Content) and its center (center) and you do:

h3->Fill(center, Content)

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