Rename branches

Hi, I have a bunch of cuts using an obsolete branch which I want to use on a new branch (which is equivalent).

As the cuts are on the old branch they cannot be used on the file, so I need to link the old branch name (obn) with the new branch name (nbn)

TBranch obn = (TBranch)gDirectory->Get(“nbn”);

Seems to work, but obn still not reconised. Cloning or renaming give simliarly dead ends

TBranch *obn=nbn->Clone();
or
nbn->SetName(“nbn”);
[-> illegal pointer to class object]

I can do this another way, but wondered if there was a simpler approach.

Cheers, Ben.

Hi Ben,

Unless the old name is re-use, you can simply use:mytree->SetAlias("oldname","newname");

Cheers,
Philippe.

Ps. TBranch *obn = (TBranch*)gDirectory->Get("nbn"); can not possibly work, TBranch object are never directly in a TDirectory, they are always in a TTree.

Cheers Phillipe! Exactly.