Cloning TTree leads to corrupted output file

Dear ROOT experts,
I’m running a script which clones a TTree and adds onto it another TBranch.
The new cloned tree and branch are then saved to an output file.

The output file seems corrupted in a weird way — opening it in a TBrowser & clicking on a branch displays its contents but after a few seconds the branch disappears from the list of branches visible under the TTree. Running analysis codes on the output file leads to errors. I’m attaching the code used for this — your help would be deeply appreciated!

One other comment: the (corrupted) output seems to have a backup TTree of the same name, although the code doesn’t create one explicitly. Might be related to some memory allocation issue…(?)

Your help would be deeply appreciated!

Roy
Sample_creation_light.cpp (3.9 KB)


ROOT Version:_ 6.30/02

Hi all,
If it helps for context, please see the output file’s contents — maybe related to a memory corruption. Focus on the two copies of nominal TTree.
Cheers,
Roy

root [1] .ls
TFile**		/storage/agrp/roybr/leptonplusjet_skimmedtrees/fakes/Run2_fakes_datadriven_light.root	
 TFile*		/storage/agrp/roybr/leptonplusjet_skimmedtrees/fakes/Run2_fakes_datadriven_light.root	
  KEY: TTree	nominal;494	nominal [current cycle]
  KEY: TTree	nominal;493	nominal [backup cycle]

Hi Roy,

Thanks for the post. Could you please post a minimal reproducer of this behaviour for us to try out?

Cheers,
Danilo

Hi Danilo,
Thanks for your reply.
I think my original post is misleading (maybe). The output file of the code I provided is read fine with ROOT but not read properly with RDataFrame (the latter made us think that it might be corrupted). Could there be a reason for this?
Cheers,
Roy