[ROOT] Branch activation/desactivation and reading trees

From: Patois Yannick (patois@ganil.fr)
Date: Thu Feb 15 2001 - 10:08:44 MET


Hello rooters,

I'm surprised by the behavior of desactivated branchs.
I wrote a small code doing:

for (int i=0;i<100;i++)
{
    A=i;B=10*i;
    if ((i)&&(!(i%10)))
    {printf("%d\n",i);test_tree->SetBranchStatus("B",0);}
    else test_tree->SetBranchStatus("B",1);
    test_tree->Fill();
}

And then I read the tree with all branches on, and I got:
nb    A      B
 0:   0      0
 1:   1     10
 2:   2     20
 3:   3     30
 4:   4     40
 5:   5     50
 6:   6     60
 7:   7     70
 8:   8     80
 9:   9     90
10:  10    110 <-- Mixing event 10 and 11 because B invalid on event 10.
11:  11    120 <-- Mixing 11 and 12
[...]
88:  88    970 <- Mixing 88 and 97
89:  89    980 <- Mixing 89 and 98
90:  90    990 <-- Invalid, B has no more recorded events.
91:  91    990 <-- idem
[...]

I would have expected that all branches would be read at the same rate
they are written, that is, keeping the synchronicity of the Ttree. Like:

nb    A      B
 0:   0      0
[...]
 8:   8     80
 9:   9     90
10:  10     90 <-- invalid, there is no B recorded at event 10.
11:  11    110 <-- Valid, event 11 is A=11 and B=110.
[...]
88:  88    880 <-- ok
89:  89    890 <-- ok
90:  90    900 <-- ok
91:  91    910 <-- ok
[...]

Is there a way to obtain such a behavior ? Wouldnt it be more 'natural'?
I think I can (de)validate branches when reading the same way I did it
when writing and then it should be OK, but it's quite an 'artificial'
way of getting something that should be obvious (not mixing data across
events).

	Yannick



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