Hi Bernhard,
The doc of TTree::Branch says:
//
// 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
In your example, replace:
TBranch *branch1 = tree->Branch("event1", "Event", &event1, bufsize,split);
TBranch *branch2 = tree->Branch("event2", "Event", &event2,bufsize,split);
by
TBranch *branch1 = tree->Branch("event1.", "Event", &event1,bufsize,split);
TBranch *branch2 = tree->Branch("event2.", "Event", &event2,bufsize,split);
Rene Brun
Bernhard KETZER wrote:
>
> Hi Rooters,
>
> I am trying to create a tree with several branches containing objects of
> the same class (e.g. Event), but the data in the tree seem to be
> completely corrupted. Here is what I would like to do (I attach the full
> modified MainEvent.cxx at the end).
>
> // Create two Event objects
> Event *event1 = new Event();
> Event *event2 = new Event();
>
> // Create two branches
> TBranch *branch1 = tree->Branch("event1", "Event", &event1,
> bufsize,split);
> TBranch *branch2 = tree->Branch("event2", "Event", &event2,
> bufsize,split);
>
> // Fill the tree
> event1->SetType(1);
> event2->SetType(2);
> ...
>
> // Create and fill track objects
> event1->AddTrack(random1);
> event2->AddTrack(random2);
>
> The tree is filled, but when I look at it, the Track data are screwed
> up. I also tried to add a dot to the branch name, but it didn't improve
> things.
>
> What am I missing?
>
> Best regards,
>
> Bernhard
>
> --------------------------------------------------------------------------------
>
> Name: MainEvent.cxx
> MainEvent.cxx Type: Plain Text (text/plain)
> Encoding: 7bit
>
> Name: Bernhard.Ketzer.vcf
> Bernhard.Ketzer.vcf Type: VCard (text/x-vcard)
> Encoding: 7bit
> Description: Card for Bernhard KETZER
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET