Plotting NLL vs POI from constrained fit

I’m trying to run a simple example with signal and background with background constrained from a (Gaussian) subsidiary measurement. I want to plot the NLL vs signal strength in the end, to compare it with the NLL from a measurement without a constraint term. The fit runs fine, but when trying to plot the NLL I get errors from integration, saying my pdf is zero. Any ideas? I feel I’m missing something trivial. I get the error from the plotOn at the very end

void ex10_test()
  // Make an empty workspace that exports its contents to CINT
  RooWorkspace *w = new RooWorkspace("w",kTRUE) ;

  TCanvas* c = new TCanvas("c", "c", 900, 600);

  // create variables
  w->factory("S[20]") ; // signal prediction
  w->factory("B[20,0,100]") ; // bkg prediction (floating, to be constrained by subsidiary measurement)
  w->factory("mu[1, 0, 5]"); // nominal=1

  // Declare the model observable (i.e. the quantity we measure, in this case an event count)
  w->factory("Poisson::model(N[100], expr:Nexp('mu*S+B', mu, S, B))");

  RooDataSet dataR("data","data",*w->var("N")) ;
  RooDataSet* data = &dataR;
  w->var("N")->setVal(45) ; // perform a single experiment, where we measure 45 events (? I think)

  // Now we construct a Gaussian subsidiary measurement:
  w->factory("Gaussian::subsidiary(Bnom[20],B,sigmaB[5])") ;
  // Gaussian::name(variable, mean, sigma)

  RooPlot* frameSub = w->var("Bnom")->frame(0, 50, 50);

  // construct a new model that is the product of the
  // original model and the subsidiary measurement

  // perform fit

  // latex.DrawLatexNDC(.5,.7,Form("#mu = %.3f #pm %.3f", w->var("mu")->getValV(), w->var("mu")->getError())); //#mu = {} #pm {}");

  // Have a look at all the objects created in the workspace
  w->Print("t") ;

  // add negative log likelihood to 2nd plot
  cout << "\n>>>>>> About to compute negative log-likelihood of fit including subsidiary measurement " << endl;
  // Draw -logL vs. mu,
  RooPlot* frameNLL = w->var("mu")->frame(0, 2); //, 2);
  RooAbsReal* nll = w->pdf("model2")->createNLL(*data) ;
  if (!nll) {cout << "ERROR: didn't get -logL. exiting." << endl; return; }

//	Plot the nll on a frame with the signal strength parameter
  nll->plotOn(frameNLL) ;

@moneta can you help?

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