So, the behavior is exactly as intended. The flow is:
oldfile.GetObject("ntuple", oldtree);
...
auto newtree = oldtree->CloneTree();
where the request is here “explicitly” to slow copy a TTree
named “ntuple”, and which has, in the original case and the modified hsimple case, more entries that the AutoSave limit. This means that during the execution of CloneTree
a cycle for the TTree
named “ntuple” is (of course) created.
Calling TTree::SetObject
(better version of SetNameTitle
but same result here), will change the name of the live object (and we see that with the name of the key/cycle written by TFile::Write
) but will not (and should not) retroactively change the name of the existing cycles in the file. So
KEY: TNtuple ntuple;1 Demo ntuple
KEY: TNtuple PolSig;1 PolSig
depicts accurately what has happened:
- a
TNtuple
named “ntuple” was auto-saved - a
TNtuple
named “PolSig” was saved.
To modify the behavior you can change the name of the TNtuple
*before* cloning it:
oldtree->SetObject("PolSig","PolSig");
auto newtree = oldtree->CloneTree();
*or* avoid the call to AutoSave
(and save a lot of time! ) by using the fast cloning.
auto newtree = oldtree->CloneTree(-1, "fast");
newtree->SetObject("PolSig","PolSig");
but still even in that case I would rename the object before cloning.
Cheers,
Philippe.