If you have two histograms h1, and h2, how do you create a third which is a division of the other two?
Assuming TH1* h1, TH1* h2, do
TH1 *h3 = (TH1*)h1->Clone("h3");
h3->Divide(h1,h2);
Rene
1 Like
Rene,
That works perfect but I need to set different axis’ and a different number of bins for h3
preferably I’d like to set h3 as 25 bins from 0 to 50, is it possible to this even though h3 is a clone of h1?
Kyle
[/code]
Kyle,
This code works for all histogram types.
To use the divide function, all histograms (source & target) must have
the same number of bins.
After dividing, you can change the limits if you like, with eg:
h3->GetYaxis()->SetLimits(ymin,ymax)
Rene