I am writting a script in which I am getting different 2D histograms and do some calculations (as suggested by Wile_E_Coyote ). After that I am plotting the histograms in Colz text e format. But the main issue is I am drawing different histograms having different entries like tight histo, loose histo, nt2, nt3 etc but it will only plotting tight entries values on all plots.
Secondly when I divide two histograms h1/h2 it give me an error of “unequal bin size division”, and for Nt3 it gives me potential memory leak. Kindly help me to resolve this problem.
I do not understand exactly what you are trying to do, but you are redefining the h2 variable and drawing it in the same canvas that then you draw the original h2 coming from the file.
Info in <TH2D::Add>: Attempt to add histograms with different number of bins - trying to use TH1::Merge
Error in <Merge>: Cannot merge histograms - limits are inconsistent:
first: h1 (4, 10.000000, 100.000000), second: third_tight_mu_pt_eta (100, 0.000000, 300.000000)
And even if I use “h1 (6, 0.000000, 300.000000)”, the same errors are still there.
Histogram with different bins cannot be added or merged. TH1::Merge supports adding histogram with compatible bins, but only for the non-variable case and if there are common bin edges.
For example you can merge h1 (0,1,2,3,4) with h2(0,2,4),
No, as I have said before you cannot add (or merge) a variable size histogram with am histogram with fixed bin size.
The only solution for you is to loop on bins of the histogram with finer binning, grep the content using GetBinContent and then re-set the correct content in the target histogram using SetBinContent
SetBinContent does not manage bin errors’ propagation (nor any “statistics” propagation) at all. That’s why proper “rebin” methods for 2-D and 3-D histograms are really needed.