21 void rf514_RooCustomizer() {
26 RooRealVar E(
"Energy",
"Energy",0,3000);
28 RooRealVar meanG(
"meanG",
"meanG", 100., 0., 3000.);
29 RooRealVar sigmaG(
"sigmaG",
"sigmaG", 3.);
30 RooGaussian gauss(
"gauss",
"gauss", E, meanG, sigmaG);
32 RooRealVar pol1(
"pol1",
"Constant of the polynomial", 1, -10, 10);
33 RooPolynomial linear(
"linear",
"linear", E, pol1);
35 RooRealVar yieldSig(
"yieldSig",
"yieldSig", 1, 0, 1.E4);
36 RooRealVar yieldBkg(
"yieldBkg",
"yieldBkg", 1, 0, 1.E4);
38 RooAddPdf model(
"model",
"S + B model",
39 RooArgList(gauss,linear),
40 RooArgList(yieldSig, yieldBkg));
42 std::cout <<
"The proto model before customisation:" << std::endl;
47 RooCategory sample(
"sample",
"sample");
48 sample.defineType(
"Sample1");
49 sample.defineType(
"Sample2");
50 sample.defineType(
"Sample3");
58 RooArgSet allCustomiserNodes;
64 RooCustomizer cust(model, sample, newLeafs, &allCustomiserNodes);
65 cust.splitArg(meanG, sample);
74 RooRealVar mass(
"M",
"M", 1, 0, 12000);
75 RooFormulaVar yield1(
"yieldSig_Sample1",
"Signal yield in the first sample",
"M/3.360779", mass);
76 RooFormulaVar yield2(
"yieldSig_Sample2",
"Signal yield in the second sample",
"M/2", mass);
77 allCustomiserNodes.add(yield1);
78 allCustomiserNodes.add(yield2);
81 cust.splitArg(yieldSig, sample);
85 auto pdf1 = cust.build(
"Sample1");
86 auto pdf2 = cust.build(
"Sample2");
87 auto pdf3 = cust.build(
"Sample3");
90 std::cout <<
"\nPDF 1 with a yield depending on M:" << std::endl;
92 std::cout <<
"\nPDF 2 with a yield depending on M:" << std::endl;
94 std::cout <<
"\nPDF 3 with a free yield:" << std::endl;
97 std::cout <<
"\nThe following leafs have been created automatically while customising:" << std::endl;
102 auto& meanG1 =
static_cast<RooRealVar&
>(allCustomiserNodes[
"meanG_Sample1"]);
104 auto& meanG2 =
static_cast<RooRealVar&
>(allCustomiserNodes[
"meanG_Sample2"]);
107 std::cout <<
"\nThe following leafs have been used while customising"
108 <<
"\n\t(partial overlap with the set of automatically created leaves."
109 <<
"\n\ta new customiser for a different PDF could reuse them if necessary.):" << std::endl;
110 allCustomiserNodes.Print(
"V");