Dividing etc... histos

Nick van Eijndhoven (Nick@fys.ruu.nl)
Wed, 14 May 1997 15:14:34 +0200 (MET DST)


Dear friends,
I have two TH1F* objects h1 and h2 and would like to get the ratio
of the two histos into a third one with the correct error calculation
(i.e. Sumw2() option).

If I do :

TH1F h3=(*h1);
h3.Sumw2();
h3.Divide(h1,h2,1,1);
h3.Draw();

I get the correct result (i.e. h3 drawn with correct error bars).

However, now I would like to use the convenient 'histo operators' and do :

TH1F h3=(*h1)/(*h2);
h3.Draw();

But now h3 is drawn as a histo without error bars, giving me the impression
that the Sumw2() option was not used.
When I do h3.Draw("e1p") I see that indeed the errors are incorrect.

Q : How can I achieve correct error calculation using the 'histo operators' ?

Note : A default won't work, since sometimes in h3=(*h1)+(*h2) one would like
to add without Sumw2() and sometimes with Sumw2() set.

Another point is the following :

I would like to have h3 also defined as TH1F*, but clearly

TH1F* h3=(*h1)/(*h2) will fail.

How to achieve this ?

Cheers,
Nick.
*----------------------------------------------------------------------*
Dr. Nick van Eijndhoven Department of Subatomic Physics
email : nick@fys.ruu.nl Utrecht University / NIKHEF
tel. +31-30-2532331 (direct) P.O. Box 80.000
tel. +31-30-2531492 (secr.) NL-3508 TA Utrecht
fax. +31-30-2518689 The Netherlands
WWW : http://www.fys.ruu.nl/~nick Office : Ornstein lab. 172
----------------------------------------------------------------------
tel. +41-22-7679751 (direct) CERN PPE Division / ALICE exp.
tel. +41-22-7675857 (secr.) CH-1211 Geneva 23
fax. +41-22-7679480 Switzerland
CERN beep : 13+7294 Office : B 160 1-012
*----------------------------------------------------------------------*