Snapshot method overriding specified root file

So in the topic here: Applying cuts to histogram without having a TTree branch

I specified the solution as using the Snapshot method to add a branch to a tree in the root file. However I had one other tree in my root file which was lost. So I wanted to ask is there a way to avoid this? Thanks

ROOT Version: 6.3.0 (PyROOT)


Apology for the trivial first answer: yes, if a different file name is chosen. Do I understand correctly the question?


Hi Danilo,

Thanks for the reply. Yeah that’s what I thought about first, having a different file name. But I wanted to look for a way to keep my original file and make changes to that.

I see. Then a good start is to use a RSnapshotOptions instance passing it to the Snapshot method of RDataFrame (in particular have a look to RSnapshotOptions::fMode).


Ok this worked I created a RSnapshotOptions instance, then did options.fMode = “UPDATE”

Thanks for the help Danilo

So something weird happened. The update method ran fine but when I ran my code a second time after some modifications all the data was gone. I think between the Define method and the Snapshot method I am doing something wrong. I have attached my code below

So the second time I ran the code all the existing branches were gone like J_psi_1S and phi_1020