[ROOT] Re: TreePlayer parser confusion?

From: troy d. straszheim (troy@resophonic.com)
Date: Mon Dec 20 2004 - 01:53:41 MET


This happens with root_v4.02.00.

I also noticed that MakeClass() generates erroneous code in this case.
Calling t->MakeClass("C") produces (in the generated header file)

class C {
public :
   // Declaration of leave types
   C               *plot_my_i.;
   Int_t           plot_my_i_B<void>_i;
   C               *against_my_i.;
   Int_t           against_my_i_B<void>_i;

   // List of branches
   TBranch        *b_plot_my_i_B<void>_i;   //!
   TBranch        *b_against_my_i_B<void>_i;   //!
};

It appears, in fact, that Tree::MakeClass always produces illegal code
when the class has been branched with a trailing dot on the branch
name, templates or not:

struct C { int i; };
void makeclass() 
{
  C c, *cp(&c);
  TTree *t = new TTree("mytree", "foo", 10000);
  t->Branch("my_c.", "C", &cp);
  t->Fill();
  t->MakeClass("C");
}

This produces a C.h that contains 
   C               *my_c.;


Thanks,

troy .d straszheim




troy d. straszheim writes:
 > 
 > Hi roottalk:  
 > 
 > I'm trying to compare some classes in trees.  This code shows the problem:
 > 
 > #include <TTree.h>
 > #include <TFile.h>
 > 
 > template <class T>
 > struct B { int i; };
 > 
 > struct C : B<void> { };
 > 
 > void plot_my_i() 
 > {
 >   C c, *cp(&c);
 >   
 >   TTree *t = new TTree("mytree", "Icecube", 10000);
 > 
 >   t->Branch("plot_my_i.", "C", &cp);
 >   t->Branch("against_my_i.", "C", &cp);
 > 
 >   for (int i=0; i<100; i++)
 >     {
 >       c.i=i*13;
 >       t->Fill();
 >     }
 >   t->Draw("plot_my_i.B<void>.i:against_my_i.B<void>.i");
 >   t->StartViewer();
 > }
 > 
 > So when a class further up in the inheritance hierarchy is a template,
 > the angle-brackets get into the branch path, the treeplayer sees them
 > as comparisions and things dont work.  I have tried intermediate
 > typedefs to outsmart rootcint:
 > 
 > template <class T> struct B { int i; };
 > typedef B<void> B_void;
 > struct C : B_void { };
 > 
 > but rootcint goes around them and the typedeffed name does not appear
 > in the branch path.  Any ideas?  
 > 
 > Thanks,
 > 
 > troy d. straszheim
 > 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET