'ADDITION AND CONVOLUTION' RooFit tutorial macro #207 Tools and utilities for manipulation of composite objects
import ROOT
x = ROOT.RooRealVar("x", "x", 0, 10)
mean = ROOT.RooRealVar("mean", "mean of gaussians", 5)
sigma = ROOT.RooRealVar("sigma", "width of gaussians", 0.5)
sig = ROOT.RooGaussian("sig", "Signal component 1", x, mean, sigma)
a0 = ROOT.RooRealVar("a0", "a0", 0.5, 0.0, 1.0)
a1 = ROOT.RooRealVar("a1", "a1", 0.2, 0.0, 1.0)
bkg1 = ROOT.RooChebychev("bkg1", "Background 1", x, [a0, a1])
alpha = ROOT.RooRealVar("alpha", "alpha", -1)
bkg2 = ROOT.RooExponential("bkg2", "Background 2", x, alpha)
bkg1frac = ROOT.RooRealVar("bkg1frac", "fraction of component 1 in background", 0.2, 0.0, 1.0)
bkg = ROOT.RooAddPdf("bkg", "Signal", [bkg1, bkg2], [bkg1frac])
bkgfrac = ROOT.RooRealVar("bkgfrac", "fraction of background", 0.5, 0.0, 1.0)
model = ROOT.RooAddPdf("model", "g1+g2+a", [bkg, sig], [bkgfrac])
y = ROOT.RooRealVar("y", "y", -10, 10)
data = ROOT.RooDataSet("data", "data", {x, y})
model_obs = model.getObservables(data)
ROOT.SetOwnership(model_obs, True)
model_obs.Print("v")
model_params = model.getParameters({x})
ROOT.SetOwnership(model_params, True)
model_params.Print("v")
model_params2 = model.getParameters(data)
ROOT.SetOwnership(model_params2, True)
model_params2.Print()
model_comps = model.getComponents()
ROOT.SetOwnership(model_comps, True)
model_comps.Print("v")
sigma2 = ROOT.RooRealVar("sigma2", "width of gaussians", 1)
sig2 = ROOT.RooGaussian("sig2", "Signal component 1", x, mean, sigma2)
sig1frac = ROOT.RooRealVar("sig1frac", "fraction of component 1 in signal", 0.8, 0.0, 1.0)
sigsum = ROOT.RooAddPdf("sigsum", "sig+sig2", [sig, sig2], [sig1frac])
cust = ROOT.RooCustomizer(model, "cust")
cust.replaceArg(sig, sigsum)
cust_clone = cust.build(ROOT.kTRUE)
ROOT.SetOwnership(cust_clone, True)
cust_clone.Print("t")
[#0] WARNING:InputArguments -- The parameter 'sigma' with range [-inf, inf] of the RooGaussian 'sig' exceeds the safe range of (0, inf). Advise to limit its range.
1) 0x8241e40 RooRealVar:: x = 5 L(0 - 10) "x"
1) 0x847fc10 RooRealVar:: a0 = 0.5 L(0 - 1) "a0"
2) 0x84f2330 RooRealVar:: a1 = 0.2 L(0 - 1) "a1"
3) 0x87f3060 RooRealVar:: alpha = -1 C L(-INF - +INF) "alpha"
4) 0x8782390 RooRealVar:: bkg1frac = 0.2 L(0 - 1) "fraction of component 1 in background"
5) 0x8926120 RooRealVar:: bkgfrac = 0.5 L(0 - 1) "fraction of background"
6) 0x82654f0 RooRealVar:: mean = 5 C L(-INF - +INF) "mean of gaussians"
7) 0x7ef2000 RooRealVar:: sigma = 0.5 C L(-INF - +INF) "width of gaussians"
RooArgSet::parameters = (a0,a1,alpha,bkg1frac,bkgfrac,mean,sigma)
1) 0x8a01230 RooAddPdf:: model[ bkgfrac * bkg + [%] * sig ] = 0.582695/1 "g1+g2+a"
2) 0x898ff20 RooAddPdf:: bkg[ bkg1frac * bkg1 + [%] * bkg2 ] = 0.16539/1 "Signal"
3) 0x891da50 RooChebychev:: bkg1[ x=x coefficients=(a0,a1) ] = 0.8 "Background 1"
4) 0x8948240 RooExponential:: bkg2[ x=x c=alpha ] = 0.00673795 "Background 2"
5) 0x8554880 RooGaussian:: sig[ x=x mean=mean sigma=sigma ] = 1 "Signal component 1"
[#0] WARNING:InputArguments -- The parameter 'sigma2' with range [-inf, inf] of the RooGaussian 'sig2' exceeds the safe range of (0, inf). Advise to limit its range.
[#1] INFO:ObjectHandling -- RooCustomizer::build(model): tree node sig will be replaced by sigsum
[#1] INFO:ObjectHandling -- RooCustomizer::build(model) Branch node RooAddPdf::model cloned: depends on a replaced parameter
[#1] INFO:ObjectHandling -- RooCustomizer::build(model) Branch node sig is already replaced
0x8e664a0 RooAddPdf::model_cust = 0.582695/1 [Auto,Clean]
0x898ff20/V- RooAddPdf::bkg = 0.16539/1 [Auto,Clean]
0x891da50/V- RooChebychev::bkg1 = 0.8 [Auto,Dirty]
0x8241e40/V- RooRealVar::x = 5
0x847fc10/V- RooRealVar::a0 = 0.5
0x84f2330/V- RooRealVar::a1 = 0.2
0x8782390/V- RooRealVar::bkg1frac = 0.2
0x8948240/V- RooExponential::bkg2 = 0.00673795 [Auto,Dirty]
0x8241e40/V- RooRealVar::x = 5
0x87f3060/V- RooRealVar::alpha = -1
0x8926120/V- RooRealVar::bkgfrac = 0.5
0x8cd8990/V- RooAddPdf::sigsum = 1/1 [Auto,Clean]
0x8554880/V- RooGaussian::sig = 1 [Auto,Dirty]
0x8241e40/V- RooRealVar::x = 5
0x82654f0/V- RooRealVar::mean = 5
0x7ef2000/V- RooRealVar::sigma = 0.5
0x209c5a0/V- RooRealVar::sig1frac = 0.8
0x8f54960/V- RooGaussian::sig2 = 1 [Auto,Dirty]
0x8241e40/V- RooRealVar::x = 5
0x82654f0/V- RooRealVar::mean = 5
0x40132d0/V- RooRealVar::sigma2 = 1
- Date
- February 2018
- Authors
- Clemens Lange, Wouter Verkerke (C version)
Definition in file rf207_comptools.py.