problem in histogram computations

M. Sievers (sieversm@mail.desy.de)
Fri, 29 Jan 1999 11:36:34 +0100 (MET)


Hello,

I have tried posting this via news, but it probably has not
reached you.

I have a problem with arithmetic expressions involving
histograms, as the name of the histograms that gets
assigned to is overwritten.

An example:

*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 2.20/06 18 December 1998 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************

CINT/ROOT C/C++ Interpreter version 5.13.83, Dec 2 1998
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] TH1D one("hone","histo one",10,0,10);
root [1] TH1D two("htwo","histo two",10,0,10);
root [2] TH1D three("hthree","histo three",10,0,10);
root [3] three.Print()
TH1.Print Name= hthree, Total sum= 0
root [4] three = one + two;
root [5] three.Print()
TH1.Print Name= hone, Total sum= 0

The histogram three, with name hthree, is assigned the sum of
one and two, and its name is *changed to that of one*.
The reason seems to be that the TH1::Copy() calls TNamed::Copy().
It could be argued that '=' should make an exact copy of the
right side, but I would argue in favor of dropping the
TNamed::Copy() call from TH1::Copy():
1. two objects will carry the same name from now on, if I
write three to a file, it will overwrite 'hone'.
2. The process is ambiguos: one + two != two + one
3. Anytime I use an intuitive formula as above, I have
to store the histogram name in some variable, do the
computation and set the name again.

It would be great if you could remove the call to TNamed::Copy()
in future versions.

Bye,
Michael

--------------------------------------------------------
Michael Sievers
Michael.Sievers@desy.de
--------------------------------------------------------
Black holes are where God divided by zero.