Plotting complicated functions in ROOFIT

Hi guys :wink:
I am constructing a model using ROOFIT. I have quite a long formula which I would like to plot the form of on a frame that already has PDFs built from models of data on it. The code to declare the variables used in the functions and to declare the formulas that are combined to give the function that is plotted is as follows:


//Declaring variables 
RooRealVar mk("mk", "Kaon mass", 493.677, 493.677, 493.677); 
RooRealVar mpi("mpi","Pion mass", 139.57018, 139.57018, 139.57018); 
RooRealVar r("r","r", 1940., 1940., 1940.); 
RooRealVar a("a", "a", 1730., 1730., 1730.); 
RooRealVar Gamma_s("Gamma_s", "Gamma_s", 270., 270., 270.);
RooRealVar m_s("m_s", "m_s", 1425., 1425., 1425.); 
    
//Declaring functions
               
RooFormulaVar t("t", "t", "sqrt( (@0*@0*@1*@1 - 1./4.* (  @2*@2- @1*@1 - @0*@0) ) / (@2*@2 - 2*@1*@1- 2*@0*@0))", RooArgList(mk,mpi,mKpi)); 
RooFormulaVar cot_db("cot_db", "cot_db", "(1./(@0*@1))+(@2*@1)/2.", RooArgList(a,t,r));
RooFormulaVar cot_dr("cot_dr", "cot_dr", "(@0*@0 - @1*@1)/(@2*@0)", RooArgList(m_s,mKpi,Gamma_s));
RooFormulaVar term1("term1","term1","@0*@0/(@1*@1)*1./(@2*@2+1.)", RooArgList(mKpi,t,cot_db));
RooFormulaVar term2("term2","term2","1./(@0*@0+1.)*@1*@1*@1*@1", RooArgList(cot_dr,mKpi));
RooFormulaVar term3("term3","term3","@0 * @0 * @0/ @1 * (1./((@2 * @2 + 1.) * (@3 * @3 + 1.)) * (2 * (@2 * @2 - 1.) / ( 2 * @2) * (@2 * @3 + 1.) - 2 * sin(2 * atan(1. / @2)) * (@2 - @3))", RooArgList(mKpi,t,cot_db,cot_dr));
RooGenericPdf p_0_sq("p_0_sq", "p_0_sq", "@0+@1+@2", RooArgList(term1,term2,term3));

I do not know what kind of variable in ROOFIT the final expression p_0_sq needs to be declared as in order for it to be included in the frame. I have tried declaring it as a RooGenericPdf but also as a RooFormulaVar and RooRealVar but none of these work. What am I doing wrong?

I would appreciate any help! :slight_smile:

Thanks :slight_smile: