library: libTree #include "TBranchElement.h"

# TBranchElement

class description - source file - inheritance tree (.pdf)

## class TBranchElement : public TBranch

| Inheritance Chart:

`TObject`

<-

`TNamed`

`TAttFill`

<-

`TBranch`

<-

`TBranchElement`

        private:

                            Bool_t CheckBranchID()
          TVirtualCollectionProxy* GetCollectionProxy()
                           TClass* GetCurrentClass()
                             Int_t GetDataMemberOffset(const TClass* cl, const char* name)
                             Int_t GetDataMemberOffsetEx(TClass* par_cl, TString& parentName, Int_t off)
                           TClass* GetParentClass()
                              void InitializeOffsets()
                            Bool_t IsMissingCollection() const

        public:

                              TBranchElement()
                              TBranchElement(const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0)
                              TBranchElement(const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1)
                              TBranchElement(const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1)
                      virtual ~TBranchElement()
                virtual Int_t Branch(const char* folder, Int_t bufsize = 32000, Int_t splitlevel = 99)
             virtual TBranch* Branch(const char* name, void* address, const char* leaflist, Int_t bufsize = 32000)
             virtual TBranch* Branch(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 99)
                 virtual void Browse(TBrowser* b)
                         void BuildTitle(const char* name)
               static TClass* Class()
                virtual Int_t Fill()
                 virtual void FillLeaves(TBuffer& b)
              TBranchElement* GetBranchCount() const
              TBranchElement* GetBranchCount2() const
                       UInt_t GetCheckSum()
          virtual const char* GetClassName() const
          virtual const char* GetClonesName() const
                virtual Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0)
          virtual const char* GetIconName() const
                        Int_t GetID() const
               TStreamerInfo* GetInfo()
                virtual Int_t GetMaximum() const
                        Int_t GetNdata() const
                        char* GetObject() const
          virtual const char* GetParentName() const
                        Int_t GetStreamerType() const
                        Int_t GetType() const
          virtual const char* GetTypeName() const
                     Double_t GetValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const
                virtual void* GetValuePointer() const
              virtual TClass* IsA() const
                       Bool_t IsBranchFolder() const
               virtual Bool_t IsFolder() const
               virtual Bool_t Notify()
                 virtual void Print(Option_t* option = "") const
                         void PrintValue(Int_t i) const
                 virtual void ReadLeaves(TBuffer& b)
                 virtual void Reset(Option_t* option = "")
                 virtual void ResetAddress()
                 virtual void SetAddress(void* addobj)
                 virtual void SetAutoDelete(Bool_t autodel = kTRUE)
                 virtual void SetBasketSize(Int_t buffsize)
                 virtual void SetBranchCount(TBranchElement* bre)
                 virtual void SetBranchCount2(TBranchElement* bre)
                 virtual void SetBranchFolder()
                 virtual void SetClassName(const char* name)
                         void SetParentClass(TClass* clparent)
                 virtual void SetParentName(const char* name)
                 virtual void SetType(Int_t btype)
                 virtual void SetupAddresses()
                 virtual void ShowMembers(TMemberInspector& insp, char* parent)
                 virtual void Streamer(TBuffer& b)
                         void StreamerNVirtual(TBuffer& b)
                virtual Int_t Unroll(const char* name, TClass* cltop, TClass* cl, Int_t basketsize, Int_t splitlevel, Int_t btype)

### Data Members

        protected:

                           TString fClassName      Class name of referenced object
                           TString fParentName     Name of parent class
                           TString fClonesName     Name of class in TClonesArray (if any)
          TVirtualCollectionProxy* fCollProxy      ! collection interface (if any)
                            UInt_t fCheckSum       CheckSum of class
                             Int_t fClassVersion   Version number of class
                             Int_t fID             element serial number in fInfo
                             Int_t fType           branch type
                             Int_t fStreamerType   branch streamer type
                             Int_t fMaximum        Maximum entries for a TClonesArray or variable array
                             Int_t fSTLtype        !STL container type
                             Int_t fNdata          !Number of data in this branch
                   TBranchElement* fBranchCount    pointer to primary branchcount branch
                   TBranchElement* fBranchCount2   pointer to secondary branchcount branch
                    TStreamerInfo* fInfo           !Pointer to StreamerInfo
                             char* fObject         !Pointer to object at *fAddress
                             char* fBranchPointer  !Pointer to object for a master branch
                            Bool_t fInit           !Initialization flag for branch assignment
                            Bool_t fInitOffsets    !Initialization flag to not endlessly recalculate offsets
                         TClassRef fCurrentClass   !Reference to current (transient) class definition
                         TClassRef fParentClass    !Reference to class definition in fParentName
                         TClassRef fBranchClass    !Reference to class definition in fClassName
                             Int_t fParentOffset   !Parent branch offset
                            Int_t* fBranchOffset   !Sub-Branch offsets with respect to current transient class
                           Bool_t* fBranchTypes    !Sub-Branch types (TBranchElement or not)

        public:

          static const enum TBranchElement:: kWarn
          static const enum TBranchElement:: kBranchFolder
          static const enum TBranchElement:: kDeleteObject

## Class Description

     TBranchElement

     A Branch for the case of an object

TBranchElement(): TBranch(), fCurrentClass(), fParentClass(), fBranchClass()

    *-*-*-*-*-*Default constructor for BranchElement*-*-*-*-*-*-*-*-*-*
    *-*        ====================================

TBranchElement(const char *bname, TStreamerInfo *sinfo, Int_t id, char *pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) :TBranch(), fCurrentClass(), fParentClass(), fBranchClass(sinfo->GetClass())

     Create a BranchElement

     If splitlevel > 0 this branch in turn is split into sub branches

TBranchElement(const char *bname, TClonesArray *clones, Int_t basketsize, Int_t splitlevel, Int_t compress) :TBranch(), fInfo(TClonesArray::Class()->GetStreamerInfo()), fCurrentClass(),fParentClass(), fBranchClass(fInfo->GetClass())

     Create a BranchElement

     If splitlevel > 0 this branch in turn is split into sub branches

TBranchElement(const char *bname, TVirtualCollectionProxy *cont, Int_t basketsize, Int_t splitlevel, Int_t compress) : TBranch(),fCurrentClass(),fParentClass(), fBranchClass(cont->GetCollectionClass())

     Create a BranchElement

     If splitlevel > 0 this branch in turn is split into sub branches

~TBranchElement()

    *-*-*-*-*-*Default destructor for a BranchElement*-*-*-*-*-*-*-*-*-*-*-*
    *-*        =====================================

TBranch* Branch(const char *subname, void *address, const char *leaflist,Int_t bufsize)

      Create a sub-branch of this branch (simple variable case)
      ==================================

         This Branch constructor is provided to support non-objects in
         a Tree. The variables described in leaflist may be simple variables
         or structures.
        See the two following constructors for writing objects in a Tree.

        By default the branch buffers are stored in the same file as the Tree.
        use TBranch::SetFile to specify a different file

Int_t Branch(const char *foldername, Int_t bufsize, Int_t splitlevel)

       This function creates one sub-branch for each element in the folder.
       The function returns the total number of branches created.

TBranch* Branch(const char *subname, const char *classname, void *add, Int_t bufsize, Int_t splitlevel)

      Create a sub-branch of this branch (with a class)
      ==================================

        Build a TBranchElement for an object of class classname.
        addobj is the address of a pointer to an object of class classname.
        The class dictionary must be available (ClassDef in class header).

        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.

        By default the branch buffers are stored in the same file as the parent branch.
        use TBranch::SetFile to specify a different file

        see IMPORTANT NOTE about branch names in TTree::Bronch

       Use splitlevel < 0 instead of splitlevel=0 when the class
       has a custom Streamer

void Browse(TBrowser *b)

void BuildTitle(const char *name)

    set branch/leaf name/title in case of a TClonesArray sub-branch

Int_t Fill()

    *-*-*-*-*-*-*-*Loop on all leaves of this branch to fill Basket buffer*-*-*
    *-*            =======================================================

     The function returns the number of bytes committed to the
     individual branch(es).
     If a write error occurs, the number of bytes returned is -1.
     If no data are written, because e.g. the branch is disabled,
     the number of bytes returned is 0.

void FillLeaves(TBuffer &b)

      Fill buffers of this branch

Int_t GetDataMemberOffset(const TClass *cl, const char *name)

     This function is for internal use only!
     Return the offset if 'name' is found in the list of real data for cl
     Output an error message if the 'name' is NOT found (to prevent reliance on the previous
     implementation.

void SetupAddresses()

     If the branch address had not yet been set,
     we set all addresses starting with the top level parent branch

Int_t GetEntry(Long64_t entry, Int_t getall)

    *-*-*-*-*Read all branches of a BranchElement and return total number of bytes
    *-*      ====================================================================
       If entry = 0 take current entry number + 1
       If entry < 0 reset entry number to 0

      The function returns the number of bytes read from the input buffer.
      If entry does not exist  the function returns 0.
      If an I/O error occurs,  the function returns -1.

      See IMPORTANT REMARKS in TTree::GetEntry

const char* GetIconName() const

     Return icon name depending on type of branch element.

Bool_t CheckBranchID()

     Need to reassign branches in case schema evolution has scrambled leaf list.

TStreamerInfo* GetInfo()

    return pointer to TStreamerinfo object for the class of this branch
    rebuild the info if not yet done

Int_t GetMaximum() const

     Return maximum count value of the branchcount if any

const char* GetTypeName() const

     return type name of element in the branch

Double_t GetValue(Int_t j, Int_t len, Bool_t subarr) const

     Returns branch value. If the leaf is an array, j is the index in the array
     If leaf is an array inside a TClonesArray, len should be the length of the
     array.  If subarr is true, then len is actually the index within the sub-array

void* GetValuePointer() const

     Returns pointer to first data element of this branch
     Currently used only for members of type character

Bool_t IsFolder() const

    *-*-*-*-*Return TRUE if more than one leaf, FALSE otherwise*-*
    *-*      ==================================================

Bool_t IsMissingCollection() const

     In version of ROOT older than 4.00/03, if a collection (TClonesArray
     or stl container) was split but the pointer to the collection was zeroed
     out, nothing was saved.  Hence there is no __easy__ way to detect the
     case.  In newer version, a zero is inserted so that a 'missing' collection
     appears as an empty collection.
     This function helps in detecting this case so that we can recover nicely.

void Print(Option_t *option) const

    *-*-*-*-*-*-*-*-*-*-*-*Print TBranch parameters*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                    ========================

void PrintValue(Int_t lenmax) const

     Prints leaf value

void ReadLeaves(TBuffer &b)

     Read buffers for this branch

void Reset(Option_t *option)

    *-*-*-*-*-*-*-*Reset a Branch*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*            ====================

        Existing buffers are deleted
        Entries, max and min are reset

void ResetAddress()

    *-*-*-*-*-*-*-*Reset the address of the branch*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*            ===============================

TClass* GetParentClass()

     Return a pointer to the current type of the data member corresponding to branch element

TClass* GetCurrentClass()

     Return a pointer to the current type of the data member corresponding to branch element

Int_t GetDataMemberOffsetEx(TClass* par_cl, TString& parentName, Int_t off)

     remove the current data member name

void InitializeOffsets()

void SetAddress(void *add)

    *-*-*-*-*-*-*-*Set address of this branch*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*            ====================

void SetAutoDelete(Bool_t autodel)

    *-*-*-*-*-*-*-*Set the AutoDelete bit
    *-*            ====================
      This function can be used to instruct Root in TBranchElement::ReadBasket
      to not delete the object referenced by a branchelement before reading a
      new entry. By default, the object is deleted.
      If autodel is kTRUE, this existing object will be deleted, a new object
        created by the default constructor, then object->Streamer called.
      If autodel is kFALSE, the existing object is not deleted. Root assumes
        that the user is taking care of deleting any internal object or array
        This can be done in Streamer itself.
      If this branch has sub-branches, the function sets autodel for these
      branches as well.
      We STRONGLY suggest to activate this option by default when you create
      the top level branch. This will make the read phase more efficient
      because it minimizes the numbers of new/delete operations.
      Once this option has been set and the Tree is written to a file, it is
      not necessary to specify the option again when reading, unless you
      want to set the opposite mode.

void SetBasketSize(Int_t buffsize)

     Reset basket size for all subbranches of this branchelement

void SetBranchCount(TBranchElement *bre)

     Set the branch count for this branch

void Streamer(TBuffer &R__b)

     Stream an object of class TBranchElement.

Int_t Unroll(const char *name, TClass *cltop, TClass *cl,Int_t basketsize, Int_t splitlevel, Int_t btype)

     unroll base classes and loop on all elements of class cl

TVirtualCollectionProxy* GetCollectionProxy()

### Inline Functions

            TBranchElement* GetBranchCount() const
            TBranchElement* GetBranchCount2() const
                     UInt_t GetCheckSum()
                const char* GetClassName() const
                const char* GetClonesName() const
                      Int_t GetID() const
                      char* GetObject() const
                const char* GetParentName() const
                      Int_t GetNdata() const
                      Int_t GetType() const
                      Int_t GetStreamerType() const
                     Bool_t IsBranchFolder() const
                     Bool_t Notify()
                       void SetBranchCount2(TBranchElement* bre)
                       void SetBranchFolder()
                       void SetClassName(const char* name)
                       void SetParentClass(TClass* clparent)
                       void SetParentName(const char* name)
                       void SetType(Int_t btype)
                    TClass* Class()
                    TClass* IsA() const
                       void ShowMembers(TMemberInspector& insp, char* parent)
                       void StreamerNVirtual(TBuffer& b)

Last update: root/tree:$Name: $:$Id: TBranchElement.cxx,v 1.175 2005/06/20 14:09:15 pcanal Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *