Rf 3 1 2_Multirangefit

Multidimensional models: performing fits in multiple (disjoint) ranges in one or more dimensions

Author: Clemens Lange, Wouter Verkerke (C++ version)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, January 17, 2022 at 10:00 AM.

In [ ]:
import ROOT

Create 2D pdf and data

Define observables x,y

In [ ]:
x = ROOT.RooRealVar("x", "x", -10, 10)
y = ROOT.RooRealVar("y", "y", -10, 10)

Construct the signal pdf gauss(x)*gauss(y)

In [ ]:
mx = ROOT.RooRealVar("mx", "mx", 1, -10, 10)
my = ROOT.RooRealVar("my", "my", 1, -10, 10)

gx = ROOT.RooGaussian("gx", "gx", x, mx, ROOT.RooFit.RooConst(1))
gy = ROOT.RooGaussian("gy", "gy", y, my, ROOT.RooFit.RooConst(1))

sig = ROOT.RooProdPdf("sig", "sig", gx, gy)

Construct the background pdf (flat in x,y)

In [ ]:
px = ROOT.RooPolynomial("px", "px", x)
py = ROOT.RooPolynomial("py", "py", y)
bkg = ROOT.RooProdPdf("bkg", "bkg", px, py)

Construct the composite model sig+bkg

In [ ]:
f = ROOT.RooRealVar("f", "f", 0.0, 1.0)
model = ROOT.RooAddPdf("model", "model", [sig, bkg], [f])

Sample 10000 events in (x,y) from the model

In [ ]:
modelData = model.generate({x, y}, 10000)

Define signal and sideband regions

Construct the SideBand1,SideBand2, regions

               |
 +-------------+-----------+
 |             |           |
 |    Side     |   Sig     |
 |    Band1    |   nal     |
 |             |           |

--+-------------+-----------+-- | | | Side | | Band2 | | | +-------------+-----------+ |

In [ ]:
x.setRange("SB1", -10, +10)
y.setRange("SB1", -10, 0)

x.setRange("SB2", -10, 0)
y.setRange("SB2", 0, +10)

x.setRange("SIG", 0, +10)
y.setRange("SIG", 0, +10)

x.setRange("FULL", -10, +10)
y.setRange("FULL", -10, +10)

Perform fits in individual sideband regions

Perform fit in SideBand1 region (ROOT.RooAddPdf coefficients will be interpreted in full range)

In [ ]:
r_sb1 = model.fitTo(modelData, Range="SB1", Save=True)

Perform fit in SideBand2 region (ROOT.RooAddPdf coefficients will be interpreted in full range)

In [ ]:
r_sb2 = model.fitTo(modelData, Range="SB2", Save=True)

Perform fits in joint sideband regions

Now perform fit to joint 'L-shaped' sideband region 'SB1|SB2' (ROOT.RooAddPdf coefficients will be interpreted in full range)

In [ ]:
r_sb12 = model.fitTo(modelData, Range="SB1,SB2", Save=True)

Print results for comparison

In [ ]:
r_sb1.Print()
r_sb2.Print()
r_sb12.Print()