Get access to a leaf created from member of a class

Hi,
If I made a class, say, MyClass, this class has some members, say, var1, var2, var3. I use this class to create two branches: Br1, Br2 by

MyClass * v1 = new MyClass;
MyClass * v2 = new MyClass;

tree->Branch("Br1", "MyClass", &v1, 32000, 2);
tree->Branch("Br2", "MyClass", &v2, 32000, 2);

//then fill them in looping events
//write to a file

Okay, then I will try to open this root file in root command line and get access to data stored. If I did

tree->GetLeaf("var1");

, I was returned a pointer, I guess it is a pointer of “Br1.var1” (since I read documentation, it returns the first leaf name of any branch). How to get “Br2.var1”? I understand that if I use TClonesArray to create the branch, then leaf name will be “Br1.var1” or “Br2.var1”, then it is easy to get data by

tree->GetLeaf("Br2.var1")

. Any hints about this? How to set leaf name as the form of “BranchName.MemName” if I created a branch “BranchName” by my class instead of TClonesArray of my class? I guess I missed something about concept of leaf and branch.

Thanks,
Zhiyi.

In case more than one top level branch references the same class, terminate the branch name with a “.” (see documentation), ie do

tree->Branch("Br1.", "MyClass", &v1, 32000, 2); tree->Branch("Br2.", "MyClass", &v2, 32000, 2);
Rene

Thanks, good tip! Yes, I should read the documention more carefully, it is there.

[quote=“brun”]In case more than one top level branch references the same class, terminate the branch name with a “.” (see documentation), ie do

tree->Branch("Br1.", "MyClass", &v1, 32000, 2); tree->Branch("Br2.", "MyClass", &v2, 32000, 2);
Rene[/quote]