Exclude a branch when saving a TTree

Hi,

I have a TTree with many branches. One branch is “special”: I’m using it only to re-index the TTree. After that operation, I’m no longer interested by this “special” branch. In particular, when writing the TTree in a ROOT file, I would like to exclude this “special” branch and not to save it on disk.

I tried to de-activate the branch with SetBranchstatus(). It’s not working.

Any idea?
Thank you.

Hi,

[quote]I tried to de-activate the branch with SetBranchstatus().[/quote]This is part of the right thing to do.

SetBranchStatus does not (of course) remove the branch from an existing file. Nonetheless, it will indicate to CloneTree that the branch should not be brought forward.

[quote] It’s not working.[/quote]What exactly did you try?

Cheers,
Philippe.

Hi,

I don’t want to clone the tree. I want to save it on disk excluding a branch. To be more explicit, here is an example:

[code]TTree *mytree = new TTree(“mytree”,“mytree”);
int var1, var2;
mytree->Branch(“branch1”, &var1, “branch1/I”);
mytree->Branch(“branch2”, &var2, “branch2/I”);

// … I’m filling my tree …

TFile *myfile = new TFile(“myfile.root”,“RECREATE”);
myfile->cd();
mytree->Write();
myflie->Close();[/code]

Before writing the tree on disk, I want to exclude one branch, say branch2. I tried

but it does not work. the branch is saved.

Thank you.