Home | News | Documentation | Download

Scale() and Divide() give different results

Dear Experts,

I would like to Draw some efficiency plots. I try to different methods, I would have expected to get the same results, but seems not to be the case.
I have an histogram “h1” contains electrons passing some selection criteria. and another one “h4” which is the total truth electron events in my MC sample

1st method:

    eff_l =new TH1F(*h1);
    eff_l->Divide(h4);

2nd method:

    eff_l =new TH1F(*h1);
    eff_l->Scale(1/h4->Integral());

Can Anybody elaborate more ? and whether or not should give the same results ?
and which method I should use for my purpose ?

Thanks a lot,

Divide divides the contents of each bin in the “original” (eff_1) by the contents of the corresponding bin (i.e. same bin number) in the second histogram (h4).
With Scale you are multiplying/dividing all bins in eff_1 by one same number (the integral of h4 in your case).
So they do different things and will in general give different results.
The documentation has links to the actual code of Divide and Scale.