Adding histograms

Hi,
I have added five histograms with the command h1->Add(h2) and so on for all five histo’s. The resulting histogram has very few counts. The original histograms each have something like 10^7 counts in total, while the resulting one has only about fifty thousand, but the histogram somehow seems to have the correct “shape”. Does anyone know what is happening? I could not find anything about this in the manual…

Could you send the shortest possible RUNNING script showing the problem?

Rene

Sure,
See the attached script and the input files and the resulting output file (I could not add the last file I merged with the other, but I guess the four others should give an idea).

I am running v. 5.18 on scientific linux for CERN.
cloverh4.root (16 KB)
cloverh3.root (17.8 KB)
cloverh2.root (17.8 KB)
cloverh1.root (16.3 KB)
cloverh.root (16 KB)
mergefiles.C (4.36 KB)

Your 5 files contain all one TCanvas object named “c1”. Each TCanvas contains a TH1F object named “h19”.
In your loop over files, you should read the TCanvas object with

TCanvas *c1 = (TCanvas*)curfile->Get("c1"); then access the histogram in c1 with

TH1 *h = (TH1*)c1->GetPrimitive("h19");
Rene