Model for hypotest with signal AND background uncertainties

Hello,

I’m trying to use RooStats for my analysis, and some of the tutorials seem to come
tantalizingly close to what I’m doing, but I can’t seem to put the pieces together.
I’m pretty new to all this and the factory interface is a total mystery to me.

Currently I have from code I inherited:

  1. A RooHistPdf to define my signal pdf as a function of one observable, a particle mass.
  TH1* signalShape=(TH1*)(signalfile->Get(finalVarHist)->Clone("ss"));
  RooWorkspace w("myw");
  w.factory("mwr[520,2000]"); // observable is called mwr
  w.defineSet("obs","mwr");
  RooDataHist signals("signals","signals",RooArgList(*w.var("mwr")),signalShape) ;
  RooHistPdf signalPdf("sig_pdf","sig_pdf",RooArgList(*w.var("mwr")),signals);
  w.import(signalPdf); 
  1. The signal yield as the sole parameter of interest
  w.defineSet("poi","sig_yield");
  1. Background fits to exponentials for two background processes ttbar and z+jets
  sprintf(temp,"Exponential::bkg_tt(mwr,%f)", tt_expfit_p1);  w.factory(temp);
  sprintf(temp,"Exponential::bkg_zj(mwr,%f)", zj_expfit_p1);  w.factory(temp);
  1. Background yields as nuisance parameters that have lognormal priors.
    sprintf(temp,"Lognormal::tt_xsec(tt_est[%f],tt_yield,%f)",tt_yield_mc,tt_yield_ferror); w.factory(temp);
    sprintf(temp,"Lognormal::zj_xsec(zj_est[%f],zj_yield,%f)",zj_yield_mc,zj_yield_ferror); w.factory(temp);
    w.var("tt_yield")->setVal(tt_yield_mc);
    w.var("zj_yield")->setVal(zj_yield_mc);
  1. Setting up to do the CLs method (showing the s+b model part):
  w.factory(
"SUM::main_pdf(sig_yield[20,0,3000]*sig_pdf,tt_yield[0.1,1e-5,10]*bkg_tt,zj_yield[0.1,1e-5,10]*bkg_zj)");
    w.factory("PROD::control_pdf(tt_xsec,zj_xsec)");
    w.factory("PROD::main_with_control(main_pdf,control_pdf)");

  ModelConfig sb_model("S+B_model", &w); // signal+background, alternative hypothesis
  sb_model.SetPdf(w.pdf("main_with_control"));
  sb_model.SetParametersOfInterest(*w.set("poi"));
  sb_model.SetNuisanceParameters(*w.set("nuis")); 
...

(Don’t know how much further I need to show…some of what you see may be associated
with dead code, but I can’t tell for sure.)
To this picture I want to add the uncertainty to the total signal yield as a nuisance parameter.

I tried doing this with the signal yield directly but ended up with disaster.
It was suggested to me to use the signal efficiency as a nuisance parameter instead,
but once again, the workspace factory interface has me flummoxed, it all seems like magic.

Any tips, please? Thanks,
-Phil D.