using namespace RooFit; using namespace RooStats; void exercise_2() { //Open the rootfile and get the workspace from the exercise_0 TFile *fInput = new TFile("Workspace_mumufit.root"); RooWorkspace *w = (RooWorkspace*)fInput->Get("w"); w->Print(); // You can set constant parameters that are known // If you leave them floating, the fit procedure will determine their uncertainty // Right now we will fix all the nuisance parameters just to speed up the computing time w->var("meanJpsi")->setConstant(1); w->var("sigmaJpsi")->setConstant(1); w->var("alphaJpsi")->setConstant(1); w->var("nJpsi")->setConstant(1); w->var("NJpsi")->setConstant(1); w->var("meanpsi2S")->setConstant(1); w->var("Nbkg")->setConstant(1); w->var("a1")->setConstant(1); w->var("a2")->setConstant(1); w->var("a3")->setConstant(1); // Configure the model, we need both the S+B and the B only models ModelConfig sbModel = ModelConfig(); sbModel.SetWorkspace(*w); sbModel.SetPdf("totPDF"); sbModel.SetName("S+B Model"); RooRealVar varpoi = (*(w->var("Npsi"))); varpoi.setRange(0.,20.); // this is mostly for plotting RooArgSet poi(varpoi); sbModel.SetParametersOfInterest(RooArgSet(varpoi)); sbModel.Print(); // the B only model ModelConfig bModel = ModelConfig(); bModel.SetWorkspace(*w); bModel.SetPdf("totPDF"); bModel.SetName( (TString::Format("%s_with_poi_0",sbModel.GetName()).Data())); varpoi.setVal(0); bModel.SetSnapshot(poi); bModel.SetParametersOfInterest(RooArgSet(varpoi)); bModel.Print(); // First example is with a frequentist approach FrequentistCalculator fc(*(w->data("data")), bModel, sbModel); fc.SetToys(2500,1500); // Create hypotest inverter passing the desired calculator HypoTestInverter calc(fc); }