# Dividing two 1D histograms

Hi all,

I have been trying to divide, in a for loop, two 1D histograms in the following way:
these are the 1D histograms filled in the for loop:

``````   TH1D *H1[const_size];
TH1D *H2[const_size];
TH1D *ratio[const_size];
``````

Inside the for loop:

``````   [...]
ratio[i] = (TH1D*)H2[i]->Clone(Form("ratio_%d",i));
ratio[i]->Divide(H1[i]));
ratio[i]->SetTitle(Form("ratio_%d", i));
ratio[i]->Write(Form("ratio_%d", i));
``````

Assuming that this is the right way to proceed (is it?), I do not know why, it keeps on plotting on the Y axis the ratio value times ** 10^{-9}**, which is the Y order of magnitude of both H1 and H2 histograms.
I also picked up two histograms from H1 and H2 to divide them outside the for loop and indeed that 10^{-9} does not show up and the ratio value is correct.
What am I doing wrong in the for loop?

Moreover, what is the difference in doing:

``````ratio[i]->Divide(H1[i]));
``````

and

``````ratio[i]->Divide(H1[i], H2[i]));
``````

?

The source code, that you show, seems fine to me.
Neither “Clone” nor “Divide” nor “SetTitle” nor “Write” will draw anything. It seems to me that you see something else drawn (not the “`ratio[i]`”, if the “magnitudes” are wrong).

Bool_t TH1::Divide(const TH1 *h1)

Bool_t TH1::Divide(const TH1 *h1, const TH1 *h2, Double_t c1 = 1, Double_t c2 = 1, Option_t *option = “”)