# Bug in TH1::Merge

I don’t know if I’m missing something, but I think somethings is wrong:

``````{
TH1F h1;
h1.Fill("10", 0);
h1.Fill("20", 0);
h1.Fill("30", 0);

h1.Fill("10", 1);
h1.Fill("10", 1);
h1.Fill("10", 1);
h1.Fill("20", 1);
h1.Fill("30", 1);
h1.SetName("h1");
h1.Print("ALL");
TCanvas c1("c1", "first"); h1.DrawCopy();
cout << "X axis minimum: " << h1.GetXaxis()->GetXmin() << endl;

TH1F h2;
h2.Fill("10", 0);
h2.Fill("20", 0);
h2.Fill("30", 0);

h2.Fill("10", 1);
h2.Fill("20", 1);
h2.Fill("20", 1);
h2.Fill("30", 1);
h2.SetName("h2");
h2.Print("ALL");
TCanvas c2("c2", "second"); h2.DrawCopy();
cout << "X axis minimum: " << h2.GetXaxis()->GetXmin() << endl;

TH1F h = h1;
TObjArray l;
l.Add(&h2);
h.Merge(&l); // h.Add(&h1) works
h.Print("ALL");
cout << "X axis minimum: " << h.GetXaxis()->GetXmin() << endl;
TCanvas c("sum", "sum"); h.DrawCopy();
}``````

I’m just Merging two TH1F, but the result is wrong! Result =

``````TH1.Print Name  = h1, Entries= 15, Total sum= 9
fSumw[0]=0, x=-6
fSumw[1]=5, x=-2
fSumw[2]=3, x=2
fSumw[3]=1, x=6
fSumw[4]=0, x=10
fSumw[5]=0, x=14
X axis minimum: -4
``````

for example the first bin: 3+1 = 5?

I’m guessing if the problem is this: savannah.cern.ch/bugs/?75902

the point is that I’m using ROOT ROOT 5.28/00b (branches/v5-28-00-patches@38394, Mar 20 2011, 05:49:00 on linuxx8664gcc), but I don’t trust so much the splash screen because my TH1.cxx is different from the svn@38394 one.

Hi,

This bug has not been ported in the 5.28 patches, but it is has been fixed in the trunk since some time
(a couple of months)

Best Regards

Lorenzo