Problem in adding histogram


I want to add 3 histogarms (which are generated from a function). Unfortunately i get the following error :

Info in <TH1D::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 (92, 44.000000, 136.000000), second: Func (100, 44.000000, 136.000000)"

here I attach my macro:
check1.C (1.7 KB)

h1 has 92 bins instead of 100. Replace:

   TH1D*h1 = new TH1D("h1","h1",92,44,136);


   auto h1 = new TH1D("h1","h1",100,44,136);
1 Like

Or in the case you want to use 92 bins, you have to use set the number of point of your function to 92 with SetNpx()


Then when you will use GetHistogram, the returned histogram will have 92 bins.

1 Like