Re: The second branch

Tioukov Valeri (valeri@d500na1.na.infn.it)
Fri, 5 Mar 1999 19:19:01 +0100 (MET)


On Wed, 3 Mar 1999, Rene Brun wrote:

> There is a limitation in split mode. You cannot have two split branches
> referencing the same class. The branch names in this case are not
> correctly generated.
> I hope to have time to support this mode in the coming release.
> Meanwhile use split=0.

Hi Rene,

I prepared several tests illustrating the tree filling in the case of
more then 1 TObjectBranch.

a) T1 1 branch, split 1, noSetAddr
b) T2 2 branches, split 1, noSetAddr
c) T3 2 branches, split 0, noSetAddr
d) T4 2 branches, split 1, SetAddr

http://chorusdq.na.infn.it/r/MainNum.cxx - main program
http://chorusdq.na.infn.it/r/Num.h - objects definition
http://chorusdq.na.infn.it/r/num.root - output file

For my opinion they illustrate some problems not reflected in the
documentation. In this tests TObjN is very simple class consists of 1
number and TObj2N consists of 2 numbers

a) ok

b) then more then 1 branches declared an filled like:

TTree *tree = new TTree("T2","2 branch, split 1, noSetAddr");
TObjN *o1 = 0;
TObj2N *o2 = 0;

int buf=64000, split=1;
tree->Branch("o1" , "TObjN" , &o1 , buf, split);
tree->Branch("o2" , "TObj2N" , &o2 , buf, split);

for (int i=0; i<100; i++){

o1 = new TObjN(i);
o2 = new TObj2N(10000000+10*i);

tree->Fill();

}

the tree filled in a wrong way.

3) this is same as 2) but split=0 - tree filled correctly.

4) the same as 2) but with branch address setting:

TTree *tree = new TTree("T4","2 branch, split 1, SetAddr");

TObjN *o1;
TObj2N *o2;

int buf=64000, split=1;
tree->Branch("branch1" , "TObjN" , &o1 , buf, split);
tree->Branch("branch2" , "TObj2N" , &o2 , buf, split);

for (int i=0; i<100; i++){

o1 = new TObjN(i);
o2 = new TObj2N(10000000+10*i);

tree->SetBranchAddress("branch1", &o1);
tree->SetBranchAddress("branch2", &o2);
tree->Fill();

}

In this case tree filled correctly also in split mode.

According to http://root.cern.ch/root/html/TTree.html:
"In case of dynamic structures changing with each event for example, one
must redefine the branch address before filling the branch again."

It is not so clear for me what does it mean but for shure it is not the
case in my example. The addresses of pointers are stable. In split=0 the
filling is ok. So I do not see the reason why in split=1 it failed.

By the way - I didn'd find any examples on root site where used setting
of branch address in case of tree FILLING.

One more problem: in split mode filling cofused not only in the case
of the same classes, but also in case of the same names of class members
in 2 different classes - d).

In my example TObjN has memeber "num" and TObj2N "num" and "num1".
num is incorrectly filled by the same values for 2 different classes in 2
different branches.

Plaing with trees I note also some badness of plot in the default canvase
in case of big integers: the exponential factor (x10^3) goes out of
screen.

Best regards
Valeri