Addition of two histograms with two different limits

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

Hi !!
I have one root file and from there I am plotting variables from two different trees. While I am drawing individual variables (hist1 and hist2), it is showing me individual plots. But while I am trying to add two histograms by the following commands then it is showing me error. The plot for the “hist6”, I am getting the plot for the “hist1” I am attaching the error also. Can you please tell me how to get rid of this ?

TH1F hist6 = new TH1F("", " ", 50, 0.450, 0.750);
c3 = new TCanvas();
hist6 = (TH1F*) hist1->Clone(“hist6”);
Info in TH1F::Add: Attempt to add histograms with different axis limits - trying to use TH1::Merge
Error in : Cannot merge histograms - limits are inconsistent:
first: hist6 (50, 0.139560, 0.139646), second: (50, 0.450000, 0.550000)

Create your “hist1” and “hist2” with the same “nbinsx”, “xlow” and “xup”.


I had similar issues. May I ask how you created/filled hist1 and hist2?


I have to make my range different because they corresponds to different particles.

You can make the histogram range wide enough so that it covers both particles.

If you want to have different ranges, see: TH1::Merge

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