15E = ROOT.RooRealVar(

"Energy",

"Energy", 0, 3000)

17meanG = ROOT.RooRealVar(

"meanG",

"meanG", 100.0, 0.0, 3000.0)

18sigmaG = ROOT.RooRealVar(

"sigmaG",

"sigmaG", 3.0)

19gauss = ROOT.RooGaussian(

"gauss",

"gauss", E, meanG, sigmaG)

21pol1 = ROOT.RooRealVar(

"pol1",

"Constant of the polynomial", 1, -10, 10)

22linear = ROOT.RooPolynomial(

"linear",

"linear", E, pol1)

24yieldSig = ROOT.RooRealVar(

"yieldSig",

"yieldSig", 1, 0, 1.0e4)

25yieldBkg = ROOT.RooRealVar(

"yieldBkg",

"yieldBkg", 1, 0, 1.0e4)

27model = ROOT.RooAddPdf(

"model",

"S + B model", [gauss, linear], [yieldSig, yieldBkg])

29print(

"The proto model before customisation:\n")

34sample = ROOT.RooCategory(

"sample",

"sample", {

"Sample1": 1,

"Sample2": 2,

"Sample3": 3})

41newLeaves = ROOT.RooArgSet()

42allCustomiserNodes = ROOT.RooArgSet()

48cust = ROOT.RooCustomizer(model, sample, newLeaves, allCustomiserNodes)

49cust.splitArg(meanG, sample)

58mass = ROOT.RooRealVar(

"M",

"M", 1, 0, 12000)

59yield1 = ROOT.RooFormulaVar(

"yieldSig_Sample1",

"Signal yield in the first sample",

"M/3.360779", mass)

60yield2 = ROOT.RooFormulaVar(

"yieldSig_Sample2",

"Signal yield in the second sample",

"M/2", mass)

61allCustomiserNodes.add(yield1)

62allCustomiserNodes.add(yield2)

65cust.splitArg(yieldSig, sample)

69pdf1 = cust.build(

"Sample1")

70pdf2 = cust.build(

"Sample2")

71pdf3 = cust.build(

"Sample3")

74print(

"\nPDF 1 with a yield depending on M:\n")

76print(

"\nPDF 2 with a yield depending on M:\n")

78print(

"\nPDF 3 with a free yield:\n")

81print(

"\nThe following leaves have been created automatically while customising:\n")

85meanG1 = allCustomiserNodes[

"meanG_Sample1"]

87meanG2 = allCustomiserNodes[

"meanG_Sample2"]

91 "\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.):"
93allCustomiserNodes.Print(

"V")