Hi all!
I’m not able to retrieve the name of RooRealVars from a pdf fit, obtained as:
result = pdf_model.fitTo(pseudo_data, RF.Save(R.kTRUE))
The closest thing I found is printing str(result.floatParsFinal().at(1))
, obtaining 'RooRealVar::n_Bp2pipipi_D0b = 1.47685e+06 +/- 1344.09 L(0 - 1e+10) \n'
, so what I’m doing now is:
for idx in range(len(all_decays)):
yield_X = result.floatParsFinal().at(idx).getValV()
erryield_X = result.floatParsFinal().at(idx).getError()
name_X=str(result.floatParsFinal().at(idx))
name_X=name_X.replace("RooRealVar::n_"," ")
name_X=name_X.replace("L(0 - 1e+10)", " ")
print(f"The fitted yield of {name_X} => sigmaN/N = {100*erryield_X/yield_X:.1f}%\n")
for i in range(len(all_decays)):
print(f"The initial yields of {all_decays[i]} = {yields[i]}\n")
with this output:
The fitted yield of Bcp2taup2pipipi = 2467.6 +/- 78.9564
=> sigmaN/N = 3.2%
The fitted yield of Bp2pipipi_D0b = 1.47685e+06 +/- 1344.09
=> sigmaN/N = 0.1%
The fitted yield of Bp2taup2pipipi = 40408.8 +/- 881.765
=> sigmaN/N = 2.2%
The fitted yield of Dp2taup2pipipi = 1.35906e+06 +/- 2285.85
=> sigmaN/N = 0.2%
The fitted yield of Dsp2taup2pipipi = 2.35918e+06 +/- 2634.05
=> sigmaN/N = 0.1%
-------------
The initial yields of Bcp2taup2pipipi = 2461
The initial yields of Bp2taup2pipipi = 38668
The initial yields of Dp2taup2pipipi = 1355818
The initial yields of Dsp2taup2pipipi = 2362444
The initial yields of Bp2pipipi_D0b = 1478159
I would like to reduce it to just one for loop, but as you can see for some reason the order of the yields are different in the fit result. So I need either the order to be the same or at least to be able to retrieve the name of the RooRealVar.
Is there a function for result
that can give me the name of the variable? I haven’t found it here ROOT: RooRealVar Class Reference
I hope my problem is clear!
Cheers,
MD