using namespace RooStats; void test2HipoInverter(){ const char* infile = "test2.out1.root"; const char* workspaceName = "w"; const char* modelConfigName = "Smodel"; const char* dataName = "data"; ///////////////////////////////////////////////////////////// // First part is just to access the workspace file //////////////////////////////////////////////////////////// // Check if example input file exists TFile *file = TFile::Open(infile); // get the workspace out of the file RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName); // get the modelConfig out of the file and the data ModelConfig* sbModel = (ModelConfig*) w->obj(modelConfigName); RooAbsData* data = w->data(dataName) ; //construct the B hypo (s=0) RooStats::ModelConfig* bModel = (RooStats::ModelConfig*) sbModel->Clone("Bmodel") ; RooRealVar* poi = (RooRealVar*) bModel->GetParametersOfInterest()->first(); poi->setVal(0); bModel->SetSnapshot(*poi); RooStats::AsymptoticCalculator asympCalc(*data, *bModel, *sbModel); asympCalc.SetOneSided(true); RooStats::HypoTestInverter inverter(asympCalc); inverter.SetConfidenceLevel(0.90); inverter.UseCLs(false); inverter.SetVerbose(false); inverter.SetFixedScan(50,10.0,20.0); // set number of points , xmin and xmax RooStats::HypoTestInverterResult* result = inverter.GetInterval(); /*RooStats::FrequentistCalculator freqCalc(*data, *bModel, *sbModel); RooStats::ProfileLikelihoodTestStat* plr = new RooStats::ProfileLikelihoodTestStat(*sbModel->GetPdf()); plr->SetOneSided(true); RooStats::ToyMCSampler* toymcs = (RooStats::ToyMCSampler*) freqCalc.GetTestStatSampler(); toymcs->SetTestStatistic(plr); if (!sbModel->GetPdf()->canBeExtended()) { toymcs->SetNEventsPerToy(1); } freqCalc.SetToys(5000,5000); RooStats::HypoTestInverter inverter2(freqCalc); inverter2.SetConfidenceLevel(0.90); inverter2.UseCLs(true); inverter2.SetVerbose(false); inverter2.SetFixedScan(50,10.0,20.0); // set number of points , xmin and xmax RooStats::HypoTestInverterResult* result2 = inverter2.GetInterval();*/ cout << 100*inverter.ConfidenceLevel() << "% upper limit : " << result->UpperLimit() << endl; std::cout << "Expected upper limits, using the B (alternate) model : " << std::endl; std::cout << " expected limit (median) " << result->GetExpectedUpperLimit(0) << std::endl; std::cout << " expected limit (-1 sig) " << result->GetExpectedUpperLimit(-1) << std::endl; std::cout << " expected limit (+1 sig) " << result->GetExpectedUpperLimit(1) << std::endl; std::cout << " expected limit (-2 sig) " << result->GetExpectedUpperLimit(-2) << std::endl; std::cout << " expected limit (+2 sig) " << result->GetExpectedUpperLimit(2) << std::endl; /* cout << 100*inverter2.ConfidenceLevel() << "% upper limit : " << result2->UpperLimit() << endl; std::cout << "Expected upper limits, using the B (alternate) model : " << std::endl; std::cout << " expected limit (median) " << result2->GetExpectedUpperLimit(0) << std::endl; std::cout << " expected limit (-1 sig) " << result2->GetExpectedUpperLimit(-1) << std::endl; std::cout << " expected limit (+1 sig) " << result2->GetExpectedUpperLimit(1) << std::endl; std::cout << " expected limit (-2 sig) " << result2->GetExpectedUpperLimit(-2) << std::endl; std::cout << " expected limit (+2 sig) " << result2->GetExpectedUpperLimit(2) << std::endl; */ TCanvas* c1 = new TCanvas(); RooStats::HypoTestInverterPlot* plot = new RooStats::HypoTestInverterPlot("HTI_Result_Plot","HypoTest Scan Result",result); plot->Draw("CLb 2CL"); // plot also CLb and CLs+b c1->Draw(); /* TCanvas* c2 = new TCanvas(); RooStats::HypoTestInverterPlot* plot2 = new RooStats::HypoTestInverterPlot("HTI_Result_Plot","HypoTest Scan Result",result2); plot2->Draw("CLb 2CL"); // plot also CLb and CLs+b c2->Draw();*/ }