Crash when using RooArgSet

Hi,

I am using ROOT6.04.14 with the piece of code below:

[code]def fun(upper):
v_var_set = ROOT.std.vector(“RooArgSet”)()
for i_bin in range(0, upper):
var_eta = ROOT.RooRealVar(“eta_” + str(i_bin), “”, -10, 10)
var_set = ROOT.RooArgSet(var_eta, “vars_” + str(i_bin) )
v_var_set.push_back(var_set)

v_var_set[0].Print()

fun(4)[/code]

Which crashes. I am not sure why is this happening, can anyone spot what is wrong with it?

Cheers.

Hi,

RooFit plays fast and loose with the meaning of ‘const’. This often works okay by accident in C++, but life time ordering is different in Python, breaking things. B/c of that alone, I can’t recommend using RooFit from Python. Not unless someone goes through the implementation and annotates all python functions, that is.

Anyway, b/c of your loop, the life time of var_eta and var_set differ from v_var_set. Either tell Python not to delete them (using “ROOT.SetOwnership(var_eta, False)” etc.), or store them in a python container for the same life time duration as v_var_set.

Cheers,
Wim

Hi,

Thanks, I understand it now.

Cheers.