File indexing completed on 2024-04-06 12:24:15
0001 using namespace RooFit ;
0002
0003 void testTagProbeFitTreeProducer_Toy(){
0004
0005 TFile out("testTagProbeFitTreeProducer_Toy.root","recreate");
0006 out.mkdir("Test")->cd();
0007
0008 RooRealVar pt("pt","pt",1,10);
0009 RooGenericPdf ptPdf("ptPdf","1/pt",pt);
0010
0011 RooRealVar eta("eta","eta",-2.4,2.4);
0012
0013 RooCategory passing("passing","passing");
0014 passing.defineType("Passed",1);
0015 passing.defineType("Failed",0);
0016
0017 RooRealVar a("a","a",0.9) ;
0018 RooRealVar b("b","b",1) ;
0019 RooRealVar c("c","c",3) ;
0020
0021
0022 RooRealVar efficiency("efficiency", "efficiency", 0.95, 0.0, 1.0);
0023
0024 RooPlot* curve = pt.frame();
0025 efficiency.plotOn(curve);
0026 curve->Write("efficiencyCurve");
0027 RooEfficiency passingPdf("passingPdf", "passingPdf", efficiency, passing, "Passed");
0028
0029 RooRealVar mass("mass", "mass", 2.6, 3.6);
0030 RooRealVar mean("mean", "mean", 3.1, 3.0, 3.2);
0031 RooRealVar sigma("sigma", "sigma", 0.03, 0.01, 0.05);
0032 RooGaussian signal("signal", "signal", mass, mean, sigma);
0033 RooRealVar numSignalAll("numSignalAll", "numSignalAll", 10000., 0., 1e10);
0034 RooExtendPdf signalExt("signalExt", "signalExt", signal, numSignalAll);
0035 RooProdPdf signalPdf("signalPdf", "signalPdf", RooArgSet(signalExt, ptPdf), Conditional(passingPdf,passing));
0036
0037 RooRealVar cPass("cPass", "cPass", 0.1, -1, 1);
0038 RooChebychev backgroundPass("backgroundPass", "backgroundPass", mass, cPass);
0039 RooRealVar numBackgroundPass("numBackgroundPass", "numBackgroundPass", 10000., 0., 1e10);
0040 RooExtendPdf backgroundPassPdf("backgroundPassPdf", "backgroundPassPdf", backgroundPass, numBackgroundPass);
0041
0042 RooRealVar cFail("cFail", "cFail", 0.1, -1, 1);
0043 RooChebychev backgroundFail("backgroundFail", "backgroundFail", mass, cFail);
0044 RooRealVar numBackgroundFail("numBackgroundFail", "numBackgroundFail", 10000., 0., 1e10);
0045 RooExtendPdf backgroundFailPdf("backgroundFailPdf", "backgroundFailPdf", backgroundFail, numBackgroundFail);
0046
0047 RooSimultaneous backgroundPdf("backgroundPdf", "backgroundPdf", passing);
0048 backgroundPdf.addPdf(backgroundPassPdf, "Passed");
0049 backgroundPdf.addPdf(backgroundFailPdf, "Failed");
0050 RooProdPdf backgroundPtPdf("backgroundPtPdf", "backgroundPtPdf", backgroundPdf, ptPdf);
0051
0052 RooCategory mc_true("mcTrue","mcTrue");
0053 mc_true.defineType("True",1);
0054 mc_true.defineType("False",0);
0055
0056 RooSimultaneous model("model", "model", mc_true);
0057 model.addPdf(signalPdf, "True");
0058 model.addPdf(backgroundPtPdf, "False");
0059
0060 RooDataSet* data = model.generate(RooArgSet(mass, pt, eta, passing, mc_true));
0061 data->tree()->Write("fitter_tree");
0062
0063 out.Close();
0064 }
0065