Hi Yannick,
Here is an extract of the TTree::Branch documentation.
//
// IMPORTANT NOTE about branch names
// In case two or more master branches contain subbranches with
// identical names, one must add a "." (dot) character at the end
// of the master branch name. This will force the name of the subbranch
// to be master.subbranch instead of simply subbranch.
// This situation happens when the top level object (say event)
// has two or more members referencing the same class.
// For example, if a Tree has two branches B1 and B2 corresponding
// to objects of the same class MyClass, one can do:
// tree.Branch("B1.","MyClass",&b1,8000,1);
// tree.Branch("B2.","MyClass",&b2,8000,1);
// if MyClass has 3 members a,b,c, the two instructions above will
generate
// subbranches called B1.a, B1.b ,B1.c, B2.a, B2.b, B2.c
Rene Brun
On Fri, 2 Jun 2000, Patois Yannick wrote:
> Hi,
>
> I got a TTree looking like :
>
> tree--.
> |--branch1--.
> | |--subbranch1a--.
> | : |-- T (leaf)
> | . :
> |
> |--branch2--.
> | |--subbranch2a--.
> | : |-- T (leaf)
> | . :
> :
> .
>
>
> When I run MakeClass, I got variables names like this :
> subbranch1a_T
> subbranch1b_T
>
> It seems OK except that subbranch1a and subbranch1b has the same name.
> There shouldnt be confusion anywhere as one is clearly part of the
> branch1 and the other of branch 2 (in fact not only the name of the
> variable is different, but also theyr type).
>
> But MakeClass ignore that and duplicate the identifiers.
>
> I know that over a certain complexity of the code I probably shouldnt
> use 'MakeClass' and do it myself. Of course, it would be great to have a
> MakeClass which would generate a code using the structured Class instead
> of flatening everything...
>
> But in the meantime, why is MakeClass starting naming objects one lever
> below its root ? One would expect a naming like branch1_subbranch1a_T
> that would be unambiguous.
>
> Maybe I could do it myself except that I dont really understand how ROOT
> connect "subbranch_T", because when I call :
> subbranch_T = fTree->GetBranch("subbranch.T");
> there are two possible matchs, as subbranch1a and subbranch1b has the
> same name.
>
> If I try to start from the root for naming :
> fTree->SetBranchAddress("branch1.subbranch.T",&branch1_subbranch_T);
>
> Error in <TTree::SetBranchAddress>: unknown branch -> branch1.subbranch.T
>
> I use ROOT version 2.23/11 (and tried with 2.24/05) on linux i586.
>
> Yannick
>
> PS: I solved the problem by loading the object itself :
> fTree->SetBranchAddress("branch1",&branch1);
>
> Then I can access to any member of it with branch1->subbranch.T
> Couldnt MakeClass use the same approach ?
>
>
> _/ Yannick Patois _________________ Address (home) __________________
> | irc(undernet): Garp on #france25+ | La Villa des Sciences |
> | email : patois@ganil.fr | 12, avenue de Cambridge |
> | web :http://www.sura.org/~patois/ | 14200 Herouville-Saint-Clair |
> | Tel/Fax-home:+33 (0)2 31 94 50 32 | FRANCE |
> |___________________________________|__________________________________|
>
>
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:27 MET