Expected events of pdf changes after creating NLL

Hello,

I set up a test model consisting of a set of category-specific models wrapped in a RooSimultaneous, with an additional constraint term for a global observable. Here’s the setup code:

[code]RooWorkspace* w = new RooWorkspace(“w”,“w”);

w->factory(“dummy_cat[eemm,eeee,mmmm]”); //dummy channel identifier
w->factory(“dummy_obs[0,1]”); //dummy obs for single-bin pdf
w->factory(“myWeight[0.1,0,100]”); //the event weight in the dataset

w->defineSet(“obs”,“dummy_obs,dummy_cat,myWeight”);

RooDataSet data(“data”,“data”,*w->set(“obs”),“myWeight”);
w->cat(“dummy_cat”)->setIndex(0); //sets to eemm
w->var(“dummy_obs”)->setVal(0.5);
w->var(“myWeight”)->setVal(0.1);
data.add(*w->set(“obs”),0.5);
w->cat(“dummy_cat”)->setIndex(1);
data.add(*w->set(“obs”),0.5);
w->cat(“dummy_cat”)->setIndex(2);
data.add(*w->set(“obs”),0.5);
w->import(data);
w->factory(“dummy_alpha[1,-5,5]”);
w->factory(“dummy_alpha_nom[1]”); //global observable
w->factory(“binwidth1[1]”);
w->factory(“poi[1,0,10]”);

w->factory(“PROD::model(Gaussian::dummy_alpha_constraint(dummy_alpha_nom,dummy_alpha,1),
SIMUL::simPdf(dummy_cat,eemm=ASUM::eemm_model(binwidth1expr::N_eemm('10poidummy_alpha(dummy_obs>0)’,poi,dummy_alpha,dummy_obs)),
eeee=ASUM::eeee_model(binwidth1expr::N_eeee('5poidummy_alpha(dummy_obs>0)’,poi,dummy_alpha,dummy_obs)),
mmmm=ASUM::mmmm_model(binwidth1expr::N_mmmm('4poidummy_alpha(dummy_obs>0)’,poi,dummy_alpha,dummy_obs)) ))”);
[/code]

If I then call:

This gives me the expected answer of ~10 (i.e the value of the N_eemm). However, if instead I do:

And then do the above called to expectedEvents, I end up with ~30. It isn’t clear to me why making the NLL function object would cause the model’s expected event count to change, especially to something that seems wrong.

Can someone explain this behaviour to me? Thanks!
Will

I think I’ve seen why it’s a factor of three larger, but I think this behaviour is unexpected. If I do ‘expectedEvents’ before createNLL, a roobinintegrator is set up that integrates only over the dummy_obs variable, e.g:

[#1] INFO:NumericIntegration -- RooRealIntegral::init(N_eeee_Int[dummy_obs]) using numeric integrator RooIntegrator1D to calculate Int(dummy_obs)

However, if I call ‘createNLL’, it sets up integrators over both variables:

[#1] INFO:NumericIntegration -- RooRealIntegral::init(N_eeee_Int[dummy_cat,dummy_obs]) using numeric integrator RooIntegrator1D to calculate Int(dummy_obs)

I think the former is the desired behaviour, so why does the second one occur?