Template for comparing 2 Histograms


In order to compare 2 Histograms i’ve seen a Plot like the following many times

| ooooo | ox o |ox xxxx oooooooo |x xxxxxxxxxxxxx |________________________________ | ... | ... ....................... |._________________________________

The upper Graph shows both Histos, while the lower Graph shows one Histo diveded by the other.

Is there a nice example Root code for that anywhere? I guess its not really complicated (i know how to divide histos), but quite some work to make it look good…

So if anyone has some code, that would be nice.

Thx in advance

You can use a transparent pad for the result of the division. See an example of transparent pad at $ROOTSYS/tutorials/hist/transpad.C


Thx, that will help when I try to create it on my own, but i was hoping for a… well… easy solution :wink:

Use three hists and the “SAME” option for Draw method ?

No this will not work because the scales will be different


[quote]No this will not work because the scales will be different


I mean if he looks for the simplest way, he can forget about his original idea and draw all three hists in one pad:

TH1D * h1 = new TH1D("The Bad", "Angel eyes", 2, -1., 1.);
h1->SetBinContent(1, 10);
h1->SetBinContent(2, 20);
TH1D * h2 = new TH1D("The Ugly", "Tuco", 2, -1., 1.);
h2->SetBinContent(1, 5.);
h2->SetBinContent(2, 4.);
TH1D * h3 = new TH1D("The good", "Blondie", 2, -1., 1.);
h3->Divide(h1, h2);