Posting this again, hoping for a second chance I’m trying to plot the negative log-likelihood vs signal strength for a constrained fit, the original thread is here: Plotting NLL vs POI from constrained fit. A bit more info this time: the error I get from the plotOn line is of this kind
[#0] ERROR:Integration -- RooNumIntFactory::createIntegrator: No integration method has been defined for an open ended 2-dimensional integral
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]: failed to create valid integrator.
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]:evaluate: cannot initialize numerical integrator
[#0] ERROR:Integration -- RooNumIntFactory::createIntegrator: No integration method has been defined for an open ended 2-dimensional integral
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]: failed to create valid integrator.
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]:evaluate: cannot initialize numerical integrator
[#0] ERROR:Eval -- RooAbsReal::logEvalError(subsidiary) evaluation error,
origin : RooGaussian::subsidiary[ x=Bnom mean=B sigma=sigmaB ]
message : p.d.f normalization integral is zero or negative
server values: x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
[#0] ERROR:Eval -- RooAbsReal::logEvalError(subsidiary) evaluation error,
origin : RooGaussian::subsidiary[ x=Bnom mean=B sigma=sigmaB ]
message : getLogVal() top-level p.d.f evaluates to zero
server values: x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
[#0] ERROR:Integration -- RooNumIntFactory::createIntegrator: No integration method has been defined for an open ended 2-dimensional integral
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]: failed to create valid integrator.
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]:evaluate: cannot initialize numerical integrator
[#0] ERROR:Eval -- RooAbsReal::logEvalError(subsidiary) evaluation error,
origin : RooGaussian::subsidiary[ x=Bnom mean=B sigma=sigmaB ]
message : p.d.f normalization integral is zero or negative
server values: x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
[#0] ERROR:Eval -- RooAbsReal::logEvalError(subsidiary) evaluation error,
origin : RooGaussian::subsidiary[ x=Bnom mean=B sigma=sigmaB ]
message : getLogVal() top-level p.d.f evaluates to zero
server values: x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
[#0] ERROR:Integration -- RooNumIntFactory::createIntegrator: No integration method has been defined for an open ended 2-dimensional integral
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]: failed to create valid integrator.
[#0] ERROR:Integration -- RooRealIntegral::subsidiary_Int[B,Bnom,sigmaB]:evaluate: cannot initialize numerical integrator
[#0] WARNING:Plotting -- At observable [x]=0 RooGaussian::subsidiary[ x=Bnom mean=B sigma=sigmaB ]
p.d.f normalization integral is zero or negative @ x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
getLogVal() top-level p.d.f evaluates to zero @ x=Bnom=20, mean=B=20 +/- 4.9999, sigma=sigmaB=5
Below is the actual code. Any ideas where I’m going wrong?
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);
c->Divide(2);
// 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)
data->add(*w->var("N"));
// Now we construct a Gaussian subsidiary measurement:
w->factory("Gaussian::subsidiary(Bnom[20],B,sigmaB[5])") ;
// Gaussian::name(variable, mean, sigma)
c->cd(1);
RooPlot* frameSub = w->var("Bnom")->frame(0, 50, 50);
w->pdf("subsidiary")->plotOn(frameSub);
frameSub->Draw();
// Finally, we construct a new model that the product of the
// original model and the subsidiary measurement
w->factory("PROD::model2(model,subsidiary)");
// perform fit
w->pdf("model2")->fitTo(*data);
// 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
c->cd(2);
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
//////// ERROR FROM THIS LINE
nll->plotOn(frameNLL) ;
frameNLL->Draw();
}
// TLatex latex;
// latex.SetTextSize(0.065);
// latex.SetTextAlign(13); //align at top
// latex.DrawLatexNDC(.5,.7,Form("#mu = %.3f #pm %.3f", w->var("mu")->getValV(), w->var("mu")->getError())); //#mu = {} #pm {}");
// B was in reality measured from a Gaussian(B, sigmaB).
// The width of this Gaussian will determine the un-
// certainty on mu, which now increases as compared to
// taking B to be a constant number.
// This constructs the small variation of the model of Ex1 (9?)
// instead of Nexp = S+B we do Nexp = mu*S + B
//
// Here S is now the _nominal_ signal expectation, a constant, and where
// mu is the 'signal strength modifier', a floating parameters
// The product mu*S has now the same role as the original S parameter
// of the model of ex1, but we have expressed the floating parameter
// in a different way, that is independent of the predicted signal yield
//
// mu = 1 --> Signal strength is equal to nominal expection
// mu = 0 --> Signal srength is zero
// mu = 2 --> Signal strength is twice the nominal expectation
// Now we will transform the _constant_ background with
// floating background parameter and introduce a subsidiary
// measurement that constrains that floating parameter