Using RDataFrame Vary function and save histograms

Hello experts,

i have a question regarding the Vary function and usage of these histograms afterwards. In short, I want to use the Vary function for bootstrapping. Afterwards, I want to save all the histograms in a root file. I am using python. The code for filling the different histograms looks like this

histogram_dictionary[hist_1] = df.Filter(selection).Vary("weight", "Rndweight * weight", [f"weight_{j}" for j in range(1000)].Histo1D((name,name,number of bins, bin0, bin1), "event numbers", "weight"))

And then I want to get and save all the histograms like this:

hx = ROOT.RDF.Experimental.VariationsFor(histogram_dictionary[hist_1])
for i in range(1000):

It appears only the nominal histogram is getting saved (last line) and not all the histograms with different weights. Even though these are computed (at least the code takes longer than without the bootstrapping histograms). To me it seems like I am missing something obvious. I hope you can help me.

Thanks in advance!

You are saving all under the same (empty) name “”; try giving to each its own name.

Thanks for spotting this! I used the empty name, as ROOT then automatically takes the name from GetName function, but I did not realize, that also all the bootstrapping histograms have the same name, so it gets overwritten every time. I changed the names and now it works!