Re: [ROOT] ROOT-Error in histogram subtraction

From: Marc-Andre Pleier (Marc-Andre.Pleier@mpi-hd.mpg.de)
Date: Fri Sep 07 2001 - 12:25:36 MEST


Hi David,

I think you didn't get my point.
I'm NOT talking about the number of entries of a histogram -
this "feature" I know already from PAW.

What I'm talking about are the MEAN AND RMS.
When you subtract two identical plots, it doesn't make any sense
to get a mean or rms different from 0. (see again my example below)

If you subtract two histograms, their values for sumw (stats[0]) and sumwx
(stats[2]) are added for the resulting histogram instead of being
subtracted.
This will thus result in a wrong mean value.
The way ROOT behaves right now, you can get two identical histograms
having different MEAN and RMS.

I tried this for ROOT-versions
3.01/06    29 August 2001 and
2.24/05       25 May 2000.

If there's a good reason for this, I'd really like to know.

Cheers,
Marc-Andre.

P.S.: Here again my example...

   form1 = new TFormula("form1","abs(sin(x)/x)");
   sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
   sqroot->SetParameters(10,4,1,20);
   h1f = new TH1F("h1f","Test random numbers",200,0,10);
   h1f->SetFillColor(45);
   h1f->FillRandom("sqroot",10000);
   h1f->Draw();
   h1f->Add(h1f, -1.);
   h1f->Draw();

-----------------------------------------------------------------------------
  Marc-Andre Pleier                             Tel. : +0049 6221 516506
  MPI Kernphysik                                Fax  : +0049 6221 516603
  Postfach 103980                               Email: Marc-Andre.Pleier
  D-69029 Heidelberg                                   @mpi-hd.mpg.de
-----------------------------------------------------------------------------


On Thu, 6 Sep 2001, David d'Enterria wrote:

> Hi Marc-Andre,
>
> Marc-Andre Pleier wrote:
>
> > I just found out there seems to be a bug in ROOT when you subtract histograms:
> > Instead of subtracting the values in the stats array (sumw, sumwx), they are
> > added
>
> This is a known old "feature" of ROOT :-)
> http://root.cern.ch/root/roottalk/roottalk99/1883.html
> http://root.cern.ch/root/roottalk/roottalk01/2560.html
>
> Best regards,
>
> --
>  David D'ENTERRIA  -  Marie-Curie PostDoc Fellow  -  TAPS·PHENIX·ALICE
>  Groupe Photons SUBATECH                        tel: +33 2 51 85 85 60
>  4, A. Kastler BP 20722 · 44307 Nantes          fax: +33 2 51 85 84 24
>  http://www-subatech.in2p3.fr/~photons        mailto:enterria@in2p3.fr
>  ---------------------------------------------------------------------
>  Phenix Group (Bld. 510C)
>  Brookhaven National Lab. Upton, NY 11973, USA    fax: +1 631 344 3253
>  http://www.phenix.bnl.gov/~enterria           mailto:denterri@bnl.gov
>  ---------------------------------------------------------------------
>
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET