Re: TProfile::Scale() and bin errors

From: Gero Flucke <flucke_at_mail.desy.de>
Date: Fri, 13 Jan 2006 16:28:32 +0100 (CET)


On Fri, 13 Jan 2006, Maxim Nikulin wrote:

> I'm confused with TProfile::Scale method. I expected that bin errors are
> scaled with the same factor as mean values. I found that TProfile::Scale is
> implemented using TProfile::Add method and cvs log says:
>
> ...
> revision 1.64
> date: 2005/08/09 10:52:20; author: brun; state: Exp; lines: +59 -26
> ...
> -In the operation functions Add, Divide, Multiply with multiplication
> coefficients c1,c2, do not use c1*c1 or c2*c2 when computing
> the resulting errors, but consider c1 and c2 like weigths as it is done
> in the Fill functions. (Thanks Gero Flucke for this remark)
> ...
>
> It seems reasonable for TProfile::Add, but shouldn't the Scale function use
> squared factor for error calculation? Let's imagine that I want to compare 2
> profiles:

<snip>

> Are there any arguments why the points have different errors?

Hi,
indeed, in ROOT 4.04.02 the errors are the same, as one expects. So we have to fix

void TProfile::Add(const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2) {
//...

    for (bin=0;bin<=nbinsx+1;bin++) {

       fArray[bin]             = c1*cu1[bin] +  c2*cu2[bin];
       if (fScaling) {
 	 fSumw2.fArray[bin]      = ac1*ac1*er1[bin] + ac2*ac2*er2[bin];
          fBinEntries.fArray[bin] = en1[bin];
       } else {
          fSumw2.fArray[bin]      = ac1*er1[bin] + ac2*er2[bin];
          fBinEntries.fArray[bin] = ac1*en1[bin] + ac2*en2[bin];
       }

    }
}

and similar in
void TProfile2D::Add(const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2)

Sorry for not thinking about that when suggesting the fix for 'real' adding of profiles...

Cheers

         Gero

PS: I do not understand why there is a check of fScaling in void TProfile[2D]::Add(const TH1 *h1, Double_t c1) This method is not used for scaling and therefore the flag is always kFALSE. In case one wants too keep the code parallel to the other Add, the above fix applies also to this method, of course.

--
-----------------------------------------------------------------------
Gero Flucke                   office: DESY, Bldg. 67b, room 21
Inst. f. Experimentalphysik           fon: +49 (0)40 8998 2955
Universitaet Hamburg                  fax: +49 (0)40 8998 2959
Luruper Chaussee 149
22761 Hamburg, Germany
Received on Fri Jan 13 2006 - 16:28:40 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:56 MET