///////////////////////////////////////////////////////////////// // // rs102_hypotestwithshapes for RooStats project // Author: Kyle Cranmer // // Modified from version of February 29, 2008 // // This tutorial macro shows a typical search for a new particle // by studying an invariant mass distribution. // The macro creates a simple signal model and two background models, // which are added to a RooWorkspace. // The macro creates a toy dataset, and then uses a RooStats // ProfileLikleihoodCalculator to do a hypothesis test of the // background-only and signal+background hypotheses. // In this example, shape uncertainties are not taken into account, but // normalization uncertainties are. // ///////////////////////////////////////////////////////////////// #ifndef __CINT__ #include "RooGlobalFunc.h" #endif #include "RooDataSet.h" #include "RooRealVar.h" #include "RooGaussian.h" #include "RooAddPdf.h" #include "RooProdPdf.h" #include "RooAddition.h" #include "RooProduct.h" #include "TCanvas.h" #include "RooChebychev.h" #include "RooAbsPdf.h" #include "RooFit.h" #include "RooFitResult.h" #include "RooPlot.h" #include "RooAbsArg.h" #include "RooWorkspace.h" #include "RooStats/ProfileLikelihoodCalculator.h" #include "RooStats/HypoTestResult.h" #include // use this order for safety on library loading using namespace RooFit; using namespace RooStats; // see below for implementation void AddModel(RooWorkspace*); void AddData(RooWorkspace*); void DoHypothesisTest(RooWorkspace*); void MakePlots(RooWorkspace*); //____________________________________ void rs102_hypotestwithshapes() { // The main macro. // Create a workspace to manage the project. // add the signal and background models to the workspace // add some toy data to the workspace // inspect the workspace if you wish // wspace->Print(); // do the hypothesis test // make some plots // cleanup } //____________________________________ void AddModel(RooWorkspace* wks){ // Make models for signal (Higgs) and background (Z+jets and QCD) // In real life, this part requires an intellegent modeling // of signal and background -- this is only an example. // set range of observable // make a RooRealVar for the observable ///////////////////////////////////////////// // make a simple signal model. // we will test this specific mass point for the signal // and we assume we know the mass resolution ///////////////////////////////////////////// // make zjj model. Just like signal model // we know Z mass // assume we know resolution too ////////////////////////////////////////////// // make QCD model // let's assume this shape is known, but the normalization is not ////////////////////////////////////////////// // combined model // Setting the fraction of Zjj to be 40% for initial guess. // Set the expected fraction of signal to 20%. // Introduce mu: the signal strength in units of the expectation. // eg. mu = 1 is the SM, mu = 0 is no signal, mu=2 is 2x the SM // Introduce ratio of signal efficiency to nominal signal efficiency. // This is useful if you want to do limits on cross section. // finally the signal fraction is the product of the terms above. // full model // interesting for debugging and visualizing the model // model.printCompactTree("","fullModel.txt"); // model.graphVizTree("fullModel.dot"); } //____________________________________ void AddData(RooWorkspace* wks){ // Add a toy dataset } //____________________________________ void DoHypothesisTest(RooWorkspace* wks){ // Use a RooStats ProfileLikleihoodCalculator to do the hypothesis test. //plc.SetData("data"); // here we explicitly set the value of the parameters for the null. // We want no signal contribution, eg. mu = 0 // RooArgSet* nullParams = new RooArgSet("nullParams"); // nullParams->addClone(*mu); //plc.SetNullParameters(*nullParams); // NOTE: using snapshot will import nullparams // in the WS and merge with existing "mu" // model.SetSnapshot(*nullParams); //use instead setNuisanceParameters // We get a HypoTestResult out of the calculator, and we can query it. HypoTestResult* htr = plc.GetHypoTest(); cout << "-------------------------------------------------" << endl; cout << "The p-value for the null is " << htr->NullPValue() << endl; cout << "Corresponding to a signifcance of " << htr->Significance() << endl; cout << "-------------------------------------------------\n\n" << endl; } //____________________________________ void MakePlots(RooWorkspace* wks) { // Make plots of the data and the best fit model in two cases: // first the signal+background case // second the background-only case. // get some things out of workspace ////////////////////////////////////////////////////////// // Make plots for the Alternate hypothesis, eg. let mu float //plot sig candidates, full model, and individual componenets // cdata->SaveAs("alternateFit.gif"); ////////////////////////////////////////////////////////// // Do Fit to the Null hypothesis. Eg. fix mu=0 // plot signal candidates with background model and components // cbkgonly->SaveAs("nullFit.gif"); }