using namespace RooStats; #define DO_TOYS_TOT int mNWorkers=10; void poissonRuns_HipoInverter_minimal(){ const char* infile_tot = "poissonRuns.out_tot.root"; const char* workspaceName_tot = "w2"; const char* modelConfigName_tot = "Smodel_tot"; const char* dataName_tot = "data_tot"; ///////////////////////////////////////////////////////////// // First part is just to access the workspace file //////////////////////////////////////////////////////////// // Check if example input file exists TFile *file_tot = TFile::Open(infile_tot); // get the workspace out of the file RooWorkspace* w2 = (RooWorkspace*) file_tot->Get(workspaceName_tot); // get the modelConfig out of the file and the data ModelConfig* sbModel_tot = (ModelConfig*) w2->obj(modelConfigName_tot); RooAbsData* data_tot = w2->data(dataName_tot) ; //construct the B hypo (s=0) RooStats::ModelConfig* bModel_tot = (RooStats::ModelConfig*) sbModel_tot->Clone("Bmodel_tot") ; RooRealVar* poi_tot = (RooRealVar*) bModel_tot->GetParametersOfInterest()->first(); poi_tot->setVal(0); bModel_tot->SetSnapshot(*poi_tot); RooStats::AsymptoticCalculator asympCalc_tot(*data_tot, *bModel_tot, *sbModel_tot); asympCalc_tot.SetOneSided(true); RooStats::HypoTestInverter inverter_tot(asympCalc_tot); inverter_tot.SetConfidenceLevel(0.90); inverter_tot.UseCLs(true); inverter_tot.SetVerbose(false); inverter_tot.SetFixedScan(500,1.0,200.0); // set number of points , xmin and xmax RooStats::HypoTestInverterResult* result_tot = inverter_tot.GetInterval(); #ifdef DO_TOYS_TOT RooStats::FrequentistCalculator freqCalcTot(*data_tot, *bModel_tot, *sbModel_tot); RooStats::ProfileLikelihoodTestStat* plr_tot_fr = new RooStats::ProfileLikelihoodTestStat(*sbModel_tot->GetPdf()); plr_tot_fr->SetOneSided(true); RooStats::ToyMCSampler* toymcs_tot = (RooStats::ToyMCSampler*) freqCalcTot.GetTestStatSampler(); toymcs_tot->SetTestStatistic(plr_tot_fr); if (!sbModel_tot->GetPdf()->canBeExtended()) { toymcs_tot->SetNEventsPerToy(1); } ProofConfig pc_tot(*w2, mNWorkers, "", kFALSE); toymcs_tot->SetProofConfig(&pc_tot); // enable proof freqCalcTot.SetToys(12000,12000); RooStats::HypoTestInverter inverter_tot_fr(freqCalcTot); inverter_tot_fr.SetConfidenceLevel(0.90); inverter_tot_fr.UseCLs(false); inverter_tot_fr.SetVerbose(false); inverter_tot_fr.SetFixedScan(100,0.,200.0); // set number of points , xmin and xmax RooStats::HypoTestInverterResult* result_tot_fr = inverter_tot_fr.GetInterval(); #endif cout<<"TOTAL"<UpperLimit() << endl; std::cout << "Expected upper limits, using the B (alternate) model : " << std::endl; std::cout << " expected limit (median) " << result_tot->GetExpectedUpperLimit(0) << std::endl; std::cout << " expected limit (-1 sig) " << result_tot->GetExpectedUpperLimit(-1) << std::endl; std::cout << " expected limit (+1 sig) " << result_tot->GetExpectedUpperLimit(1) << std::endl; std::cout << " expected limit (-2 sig) " << result_tot->GetExpectedUpperLimit(-2) << std::endl; std::cout << " expected limit (+2 sig) " << result_tot->GetExpectedUpperLimit(2) << std::endl; #ifdef DO_TOYS_TOT cout << 100*inverter_tot_fr.ConfidenceLevel() << "% upper limit : " << result_tot_fr->UpperLimit() << endl; std::cout << "Expected upper limits, using the B (alternate) model : " << std::endl; std::cout << " expected limit (median) " << result_tot_fr->GetExpectedUpperLimit(0) << std::endl; std::cout << " expected limit (-1 sig) " << result_tot_fr->GetExpectedUpperLimit(-1) << std::endl; std::cout << " expected limit (+1 sig) " << result_tot_fr->GetExpectedUpperLimit(1) << std::endl; std::cout << " expected limit (-2 sig) " << result_tot_fr->GetExpectedUpperLimit(-2) << std::endl; std::cout << " expected limit (+2 sig) " << result_tot_fr->GetExpectedUpperLimit(2) << std::endl; #endif TCanvas* c1_tot = new TCanvas(); RooStats::HypoTestInverterPlot* plot_tot = new RooStats::HypoTestInverterPlot("HTI_Result_Plot_tot","HypoTest Scan Result tot",result_tot); plot_tot->Draw("CLb 2CL"); // plot also CLb and CLs+b c1_tot->Draw(); #ifdef DO_TOYS_TOT TCanvas* c2_tot = new TCanvas(); RooStats::HypoTestInverterPlot* plot_tot_fr = new RooStats::HypoTestInverterPlot("HTI_Result_Plot","HypoTest Scan Result tot fr",result_tot_fr); plot_tot_fr->Draw("CLb 2CL"); // plot also CLb and CLs+b c2_tot->Draw(); #endif }