00001
00002
00003 void PrepareWorkspace_GaussOverFlat( TString fileName = "WS_GaussOverFlat.root" )
00004 {
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 using namespace RooFit;
00015 using namespace RooStats;
00016
00017
00018 RooRealVar* mass = new RooRealVar("mass","mass",0,500,"GeV/c^{2}");
00019 mass->setBins(100);
00020 RooArgSet* observables = new RooArgSet(*mass,"observables");
00021
00022
00023 RooAbsPdf* sigPdf = new RooGaussian("sigPdf","signal PDF",*mass,RooConst(200),RooConst(50));
00024 RooAbsPdf* bkgPdf = new RooPolynomial("bkgPdf","background PDF",*mass,RooFit::RooConst(0));
00025
00026
00027 RooRealVar* S = new RooRealVar("S","signal yield",0,0,60);
00028 RooRealVar* B = new RooRealVar("B","background yield",10);
00029 RooAbsPdf* model = new RooAddPdf("model","S+B PDF",RooArgList(*sigPdf,*bkgPdf),RooArgList(*S,*B));
00030
00031
00032 RooAbsPdf* modelBkg = new RooExtendPdf("modelBkg","B-only PDF",*bkgPdf,*B);
00033
00034
00035 RooAbsPdf* priorPOI = new RooPolynomial("priorPOI","flat prior on the POI",*S,RooFit::RooConst(0));
00036 RooArgSet* POI = new RooArgSet(*S,"POI");
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 RooAbsData* data = (RooDataHist*) model->generateBinned(*observables,Name("data"),ExpectedData());
00048
00049
00050
00051
00052
00053
00054
00055 RooWorkspace myWS("myWS");
00056 myWS.import(*data,Rename("data"));
00057 myWS.import(*model,RecycleConflictNodes());
00058 myWS.import(*modelBkg,RecycleConflictNodes());
00059 myWS.import(*priorPOI,RecycleConflictNodes());
00060 myWS.defineSet("observables",*observables,kTRUE);
00061 myWS.defineSet("POI",*POI,kTRUE);
00062
00063
00064 TFile file(fileName,"RECREATE");
00065 file.cd();
00066 myWS.Write();
00067 file.Write();
00068 file.Close();
00069
00070 std::cout << "\nRooFit model initialized and stored in " << fileName << std::endl;
00071 }