Re: Can't browse sub objects...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 20 1997 - 10:22:31 MEST


Gordon Watts (Brown University) wrote:
> 
> Hi,
>   I'd be willing to bet good money that this problem and the previous email
> of splitlevel=0 are related.
> 
>   Basically, if I write out a file with an object that contains sub objects
> I can't open the sub objects in the TBrowser window.
> 
>   Extending the example of last time, I add a pointer to an object
> EventInfo into my MLQ_Event. I fill this, and write it out. I then open the
> file and use a tbrowser window to look at the contents of the file. My
> mlq_event appears, along with its contents. If I click on any simple
> varriable, like _temp, a plot appears (as expected) in a previously opened
> canvas. However, the EventInfo object does not appear as a folder. :(
> 
>   BTW. I've been using the Event test as an example... Guess what -- that
> guy totally works. So I'm forgetting some (small?!?) that will make mine
> work. I've been pooring over that example for the past hour and I can't see
> what I've forgotten. If anyone else spots it...
> 

Yes, I understand your problem. When using teh split method, the ROOT
split
algorithm works as follows:
 - if your class contains a subobject (case of EVentHeader header in
test/Event
   example), then ROOT can automatically in turn split this object and
so on.
 - if your class contains a pointer to another object (this is your
case,
   (EventInfo *event), ROOT cannot split this object. Instead, the
subobject
   will be streamed to the branch buffer via the Streamer function.

Concerning the TBrowser. in case of a pointer to an object (your case),
in order to browse your subobject, you must declare your object
browsable
and provide a Browse member function. That means, in your header file,
add
   Bool_t   IsFolder() {return kTRUE;}
   void     Browse(TBrowser *b);

Your Browse member function could look like
  EventInfo::Browse(TBrowser *b) {
      Draw();
  }

You can see examples of Browse functions in the ROOT Tree classes
like TTree, TBranch or TLeafI,etc.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET