TTree->Clone()

Dear experts,

I have a code which should clone 2 trees in 2 separate directory:

  • the 1st clone tree should be a simple clone (without changes).
  • the 2d tree is a clone after a branch has been disable.

When I clone with 10000 entries everything is fine for both clone trees, but when I clone with 200000 evt for ex, the 1st clone tree does not contain the branch that I disable after I cloned it.

This is a piece of code:

1 TTree* itree=(TTree*)idir->Get(“t”);
2 odir =(TDirectory*)ofile->mkdir(idir->GetName()); odir->cd();
3 itree->CloneTree()->Write();

4 itree->SetBranchStatus(“jtpt”,0);
5 TTree* otree = (debug) ? itree->CloneTree(10000) : itree->CloneTree();
6 itree->SetBranchStatus(“jtpt”,1);

What is weird is that both clones are ok when at line 5 I’m clonning with a low entries number:
TTree* otree = (debug) ? itree->CloneTree(10000) : itree->CloneTree();

but when I changed line 5 into:
TTree* otree = (debug) ? itree->CloneTree() : itree->CloneTree(200000);
the clone tree created at line 3 does not contain the branch disable at line 4.

Do you have an explanation for this?

Regards

Dear,

does anyone know what may be wrong?

Regards

Dear experts,

I still do not know why it did not work, but I fixed the problem by changing directory before I clone the 2d tree. Basically instead of:

1 TTree* itree=(TTree*)idir->Get(“t”);
2 odir =(TDirectory*)ofile->mkdir(idir->GetName()); odir->cd();
3 itree->CloneTree()->Write();

4 itree->SetBranchStatus(“jtpt”,0);
5 TTree* otree = (debug) ? itree->CloneTree(10000) : itree->CloneTree();
6 itree->SetBranchStatus(“jtpt”,1);

I did:

1 TTree* itree=(TTree*)idir->Get(“t”);
2 odir =(TDirectory*)ofile->mkdir(“directory_1”); odir->cd();
3 itree->CloneTree()->Write();

4 odir=(TDirectory*)ofile->mkdir(“directory_2”); odir->cd();
5 itree->SetBranchStatus(“jtpt”,0);
6 TTree* otree = (debug) ? itree->CloneTree(10000) : itree->CloneTree();
7 itree->SetBranchStatus(“jtpt”,1);

Regards