Home | News | Documentation | Download

Difference between SUM and RooAddPdf

Dear experts,

While i was trying to add two pdfs I stumbled upon an issue that I cannot understand. The issue is:
when I define a workspace in RooFit add two pdfs using “SUM” inside the workspace, I get a result that is different wrt accessing the pdfs outside of workspace and add them with RooAddPdf. I checked that is not issue of the SUM function itself but rather of the workspace (same behavior is observed if i put “RooAddPdf” or “AddPdf” in workspace). Naively i would expect that regardless if I use the workspace to add pdfs or not the result must be the same. Is there anything obvious that I am missing (ie change of normalization or something)? Also I just want to note that the wrong result is the one when we use the workspace. I tried to attach both a script to reproduce the issue and the plot, but i cannot. So I am attaching the cp here [*]. Thanks in advance.

Best regards,
George

[*]
import ROOT
from ROOT import RooFit
ROOT.gROOT.SetBatch(True);
ROOT.gROOT.SetStyle(“Plain”);
msgservice = ROOT.RooMsgService.instance()
msgservice.setGlobalKillBelow(RooFit.FATAL)

#define functions and workspace
wspace = ROOT.RooWorkspace(“test_ws”)
wspace.factory(‘x[4.7,5.7]’)
wspace.factory(‘cb_mean_ksk[5.0718, 5.0, 5.15]’)
wspace.factory(‘cb_width_ksk[0.0466, 0.001, 5.0]’)
wspace.factory(‘cb_alpha_ksk[0.26, 0.001, 50.0]’)
wspace.factory(‘cb_n1_ksk[3.22, 0.001, 50.]’)
wspace.factory(“CBShape::cb_ksk(x,cb_mean_ksk,cb_width_ksk,cb_alpha_ksk,cb_n1_ksk)”)

wspace.factory(‘exp_alpha_ksp[-5.44, -20.0, -1.e-2]’)
wspace.factory(‘Exponential::exp_ksp(x,exp_alpha_ksp)’)

wspace.factory(‘frac_prtl[0.448, 0.0, 1]’)

#sum them inside ws
wspace.factory(‘SUM::cb_exp_partial(cb_ksk,frac_prtl*exp_ksp)’)

#sum them with rooaddpdf
cb= wspace.pdf(“cb_ksk”)
exp= wspace.pdf(“exp_ksp”)
cb_exp_partial= wspace.pdf(“cb_exp_partial”)
frc=wspace.var(“frac_prtl”)
yld=ROOT.RooRealVar(“yld”,"",1.0)
add_partial=ROOT.RooAddPdf(“addprtl”,"",ROOT.RooArgList(cb,exp),ROOT.RooArgList(yld,frc))

#plot
x= wspace.var(“x”)
xframe=x.frame()
cb_exp_partial.plotOn(xframe,RooFit.LineColor(6),RooFit.Name(“cb_exp_partial”))
add_partial.plotOn(xframe,RooFit.LineColor(2),RooFit.Name(“addprtl”))
c1=ROOT.TCanvas(“c1”,"",700,700)
xframe.Draw()
legend = ROOT.TLegend(0.65,0.65,0.92,0.85)
legend.AddEntry(xframe.findObject(“addprtl”),“RooAddPdf”,“l”);
legend.AddEntry(xframe.findObject(“cb_exp_partial”),“SUM”,“l”);
legend.Draw(“sames”)

c1.SaveAs(“issue.png”)

Hi,

It looks to me you are using the two different form to build a RooAddPdf. In the workspace you are using the non-extended form passing 1 coefficient, while outside the workspace you are using the extended case passing 2 coefficients. See ROOT: RooAddPdf Class Reference

Lorenzo

Dear Lorenzo,

Thanks for the prompt reply. Indeed this was the issue.

Best regards,
George

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.