Adding two 1D histograms

Hello!

The hadd can add two root files.
But I want to add two 1D histograms.
Is there a simple command to add two 1D or 2D histograms inside root?

Cheers, Sangryul Ro

root.cern.ch/root/html/TH1.html#TH1:Add

It is quite inconvenient to add two histograms according to
the Web page quoted.
I used the following lines.

TList *list = new TList;
list->Add(hpx2);
list->Add(h25z);
TH1F h = (TH1F)h1->Clone(“h”);
h->Reset();
h.Merge(list);
h->Draw();
h.Fit(“gaus”);

Then, the error message,
Error in TH1D::Merge: Cannot merge histograms - the histograms have different limits and undeflows/overflows are present. The initial histogram is now broken!, is displayed.
The two histograms have the same limits.
The meaning of “undeflows/overflows” is not clear to me.

Cheers

The help of Merge() tells it clearly:

 If overflows are present and limits are different the function will fail.

for underflows and overflows definition see:
root.cern.ch/root/html/TH1.html

Hello!

Is there a way to subtract a 1D histogram from another one?
Hadd can merge root files.
But I need to subtract an indivisual 1D histogram from another 1D histogram.

Cheers, Sangryul Ro

See TH1::Add

Philippe