from __future__ import print_function
import ROOT
tagCat = ROOT.RooCategory("tagCat", "Tagging category")
tagCat.defineType("Lepton")
tagCat.defineType("Kaon")
tagCat.defineType("NetTagger-1")
tagCat.defineType("NetTagger-2")
tagCat.Print()
b0flav = ROOT.RooCategory("b0flav", "B0 flavour eigenstate", {"B0": -1, "B0bar": 1})
b0flav.Print()
x = ROOT.RooRealVar("x", "x", 0, 10)
data = ROOT.RooPolynomial("p", "p", x).generate({x, b0flav, tagCat}, 10000)
btable = data.table(b0flav)
btable.Print()
btable.Print("v")
ttable = data.table(tagCat, "x>8.23")
ttable.Print()
ttable.Print("v")
bttable = data.table({tagCat, b0flav})
bttable.Print("v")
nb0 = btable.get("B0")
print("Number of events with B0 flavor is ", nb0)
fracLep = ttable.getFrac("Lepton")
print("Fraction of events tagged with Lepton tag is ", fracLep)
tagCat.setRange("good", "Lepton,Kaon")
tagCat.addToRange("soso", "NetTagger-1")
tagCat.addToRange("soso", "NetTagger-2")
goodData = data.reduce(CutRange="good")
goodData.table(tagCat).Print("v")