Remove a TLeaf

Hi,

I have a custom class that I store into a TTree. There is one member in the class I do not want to store in the tree. I only know of two possible options.

  1. Add the individual class members by hand i.e. hard code it.
    This seems way too cumbersome since I have over 30 class member and I just don’t want to keep about 5 of them.

  2. Use the “//!” option in the class definition.

class Custom : public TObject {
  public:
    Custom() {;}
    ~Custom() {;}
    
    int keep;
    int notkeep;  //!     <-- don't want to use this
  ClassDef(Custom, 1)
}

This doesn’t help because I also want to make another tree that keeps the variable I threw away from the original tree.

Is there a 3rd option? Preferably, I would make a branch for the whole class. Then remove one or more resulting TLeafs from the tree before I start filling the tree.

Surge

Hi,

You could try to find the TBranch corresponding to the member ‘notkeep’ in the list GetListOfBranches of the top level branch (the one containing/created with ‘Custom’), remove it from there and delete it.

Cheers,
Philippe.