import ROOT
x = ROOT.RooRealVar("x", "x", 0, 10)
a = ROOT.RooArgusBG("a", "argus(x)", x, ROOT.RooFit.RooConst(
10), ROOT.RooFit.RooConst(-1))
data = a.generate(ROOT.RooArgSet(x), 10000)
xRegion = ROOT.RooThresholdCategory(
"xRegion", "region of x", x, "Background")
xRegion.addThreshold(4.23, "Background")
xRegion.addThreshold(5.23, "SideBand")
xRegion.addThreshold(8.23, "Signal")
xRegion.addThreshold(9.23, "SideBand")
data.addColumn(xRegion)
xframe = x.frame(ROOT.RooFit.Title(
"Demo of threshold and binning mapping functions"))
data.plotOn(xframe)
data.plotOn(
xframe,
ROOT.RooFit.Cut("xRegion==xRegion::SideBand"),
ROOT.RooFit.MarkerColor(
ROOT.kRed),
ROOT.RooFit.LineColor(
ROOT.kRed))
x.setBins(10, "coarse")
xBins = ROOT.RooBinningCategory("xBins", "coarse bins in x", x, "coarse")
xbtable = data.table(xBins)
xbtable.Print("v")
xb = data.addColumn(xBins)
xb.setRange(
"alt",
"x_coarse_bin1,x_coarse_bin3,x_coarse_bin5,x_coarse_bin7,x_coarse_bin9")
dataSel = data.reduce(ROOT.RooFit.CutRange(
"alt"), ROOT.RooFit.EventRange(0, 5000))
dataSel.plotOn(xframe, ROOT.RooFit.MarkerColor(ROOT.kGreen),
ROOT.RooFit.LineColor(ROOT.kGreen))
c = ROOT.TCanvas("rf405_realtocatfuncs", "rf405_realtocatfuncs", 600, 600)
xframe.SetMinimum(0.01)
ROOT.gPad.SetLeftMargin(0.15)
xframe.GetYaxis().SetTitleOffset(1.4)
xframe.Draw()
c.SaveAs("rf405_realtocatfuncs.png")