As an extra complication, some of the new parameters need to be functions of a mass parameter.
#include <iostream>
RooRealVar meanG(
"meanG",
"meanG", 100., 0., 3000.);
RooRealVar pol1(
"pol1",
"Constant of the polynomial", 1, -10, 10);
RooRealVar yieldSig(
"yieldSig",
"yieldSig", 1, 0, 1.E4);
RooRealVar yieldBkg(
"yieldBkg",
"yieldBkg", 1, 0, 1.E4);
std::cout << "The proto model before customisation:" << std::endl;
model.Print("T");
sample["Sample1"] = 1;
sample["Sample2"] = 2;
sample["Sample3"] = 3;
RooCustomizer cust(model, sample, newLeaves, &allCustomiserNodes);
cust.splitArg(meanG, sample);
RooFormulaVar yield1(
"yieldSig_Sample1",
"Signal yield in the first sample",
"M/3.360779", mass);
RooFormulaVar yield2(
"yieldSig_Sample2",
"Signal yield in the second sample",
"M/2", mass);
allCustomiserNodes.
add(yield1);
allCustomiserNodes.
add(yield2);
cust.splitArg(yieldSig, sample);
auto pdf1 = cust.build("Sample1");
auto pdf2 = cust.build("Sample2");
auto pdf3 = cust.build("Sample3");
std::cout << "\nPDF 1 with a yield depending on M:" << std::endl;
pdf1->Print("T");
std::cout << "\nPDF 2 with a yield depending on M:" << std::endl;
pdf2->Print("T");
std::cout << "\nPDF 3 with a free yield:" << std::endl;
pdf3->Print("T");
std::cout << "\nThe following leaves have been created automatically while customising:" << std::endl;
auto& meanG1 =
static_cast<RooRealVar&
>(allCustomiserNodes[
"meanG_Sample1"]);
auto& meanG2 =
static_cast<RooRealVar&
>(allCustomiserNodes[
"meanG_Sample2"]);
std::cout << "\nThe following leaves have been used while customising"
<< "\n\t(partial overlap with the set of automatically created leaves."
<< "\n\ta new customiser for a different PDF could reuse them if necessary.):" << std::endl;
allCustomiserNodes.
Print(
"V");
}
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Efficient implementation of a sum of PDFs of the form.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
RooPolynomial implements a polynomial p.d.f of the form.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
[#0] WARNING:InputArguments -- The parameter 'sigmaG' with range [-inf, inf] of the RooGaussian 'gauss' exceeds the safe range of (0, inf). Advise to limit its range.
The proto model before customisation:
0x7ffe54fb1898 RooAddPdf::model = 750.5/1 [Auto,Clean]
0x7ffe54fb0240/V- RooGaussian::gauss = 0 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x7ffe54fb23a0/V- RooRealVar::meanG = 100
0x7ffe54fb0ce0/V- RooRealVar::sigmaG = 3
0x7ffe54fb2788/V- RooRealVar::yieldSig = 1
0x7ffe54fb0798/V- RooPolynomial::linear = 1501 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x7ffe54fb10c8/V- RooRealVar::pol1 = 1
0x7ffe54fb14b0/V- RooRealVar::yieldBkg = 1
PDF 1 with a yield depending on M:
0x558266f930d0 RooAddPdf::model_Sample1 = 1156.8/1 [Auto,Clean]
0x558266fcd3c0/V- RooGaussian::gauss_Sample1 = 0 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x5582658c6420/V- RooRealVar::meanG_Sample1 = 100
0x7ffe54fb0ce0/V- RooRealVar::sigmaG = 3
0x7ffe54fb36c0/V- RooFormulaVar::yieldSig_Sample1 = 0.29755 [Auto,Clean]
0x7ffe54fb2b70/V- RooRealVar::M = 1
0x7ffe54fb0798/V- RooPolynomial::linear = 1501 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x7ffe54fb10c8/V- RooRealVar::pol1 = 1
0x7ffe54fb14b0/V- RooRealVar::yieldBkg = 1
PDF 2 with a yield depending on M:
0x5582659f1610 RooAddPdf::model_Sample2 = 1000.67/1 [Auto,Clean]
0x558266f917e0/V- RooGaussian::gauss_Sample2 = 0 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x5582658bdb90/V- RooRealVar::meanG_Sample2 = 100
0x7ffe54fb0ce0/V- RooRealVar::sigmaG = 3
0x7ffe54fb3af8/V- RooFormulaVar::yieldSig_Sample2 = 0.5 [Auto,Clean]
0x7ffe54fb2b70/V- RooRealVar::M = 1
0x7ffe54fb0798/V- RooPolynomial::linear = 1501 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x7ffe54fb10c8/V- RooRealVar::pol1 = 1
0x7ffe54fb14b0/V- RooRealVar::yieldBkg = 1
PDF 3 with a free yield:
0x558265995e60 RooAddPdf::model_Sample3 = 750.5/1 [Auto,Clean]
0x5582659a47c0/V- RooGaussian::gauss_Sample3 = 0 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x558264c98d50/V- RooRealVar::meanG_Sample3 = 100
0x7ffe54fb0ce0/V- RooRealVar::sigmaG = 3
0x558264e496f0/V- RooRealVar::yieldSig_Sample3 = 1
0x7ffe54fb0798/V- RooPolynomial::linear = 1501 [Auto,Dirty]
0x7ffe54fb1fb8/V- RooRealVar::Energy = 1500
0x7ffe54fb10c8/V- RooRealVar::pol1 = 1
0x7ffe54fb14b0/V- RooRealVar::yieldBkg = 1
The following leaves have been created automatically while customising:
1) RooRealVar:: meanG_Sample1 = 100
2) RooRealVar:: meanG_Sample2 = 100
3) RooRealVar:: meanG_Sample3 = 100
4) RooRealVar:: yieldSig_Sample3 = 1
The following leaves have been used while customising
(partial overlap with the set of automatically created leaves.
a new customiser for a different PDF could reuse them if necessary.):
1) RooFormulaVar:: yieldSig_Sample1 = 0.29755
2) RooFormulaVar:: yieldSig_Sample2 = 0.5
3) RooRealVar:: meanG_Sample1 = 200
4) RooRealVar:: meanG_Sample2 = 300
5) RooRealVar:: meanG_Sample3 = 100
6) RooRealVar:: yieldSig_Sample3 = 1