TBranch documentation

From: Tioukov Valeri (valeri@d500na1.na.infn.it)
Date: Thu Mar 04 1999 - 17:31:39 MET


Hi rooters,

It seems that there is some inconsistency in the of the TBranch 
explanations on the root site. 

The most complete information I found on
http://root.cern.ch/root/html/TTree.html

here we see: 

----------------------------------------------------------
....

     Various kinds of branches can be added to a tree:
       A - simple structures or list of variables. (may be for C or Fortran structures)
       B - any object (inheriting from TObject). (we expect this option be the most frequent)
       C - a ClonesArray. (a specialized object for collections of same class objects)

.....

  ==> Case B
      ======
     TBranch *branch = tree->Branch(branchname,object, bufsize, splitlevel)
          object is the address of a pointer to an existing object (derived from TObject).
        if splitlevel=1 (default), this branch will automatically be split
          into subbranches, with one subbranch for each data member or object
          of the object itself. In case the object member is a TClonesArray,
          the mechanism described in case C is applied to this array.
        if splitlevel=0, the object is serialized in the branch buffer.

VT> It seems that the above lines are partially incorrect because 

....

   tree->Branch("hpx","TH1F",&hpx,128000,0);

VT> 5 parameters instead of 4 in the explanation of Case B
VT> In fact later we have:

...

TBranch* Branch(const Text_t *name, const Text_t *classname, void *addobj, Int_t bufsize, Int_t splitlevel) 

*-*-*-*-*-*-*-*-*-*-*Create a new TTree BranchObject*-*-*-*-*-*-*-*-*-*-*-*
*-*                  ===============================

    Build a TBranchObject for an object of class classname.
    addobj is the address of a pointer to an object of class classname.
    IMPORTANT: classname must derive from TObject.

    This option requires access to the library where the corresponding class
    is defined. Accessing one single data member in the object implies
    reading the full object.
 
VT> It confirmes the version that it should be 5 parameters in Case B
VT> But now appeared the question about split=1 

--------------------------------------------------------------------------------------

But the worsest thing that it's never specified that the first parameter 
"const Text_t *name"   should be the name of the 3-d parameter 
"void *addobj"         as in all examples like:

   tree->Branch("hpx","TH1F",&hpx,128000,0);

Why by the way? It seems that the information given by the second and 
third parameters should be enough for correct filling.

I spend a lot of time before understand the fact that branch name must be 
the same as the name of my pointer onto the object. 
On the other case the tree filled by zeros without any warnings.

Is it correct or I missed something?

Best regards
Valeri



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