tagged_mass.setRange("full", 5.0, 5.6) thevars = RooArgSet() thevars.add(tagged_mass) thevars.add(mumuMass) thevars.add(mumuMassE) thevars.add(tagB0) fulldata = RooDataSet('fulldata', 'fulldataset', tData, RooArgSet(thevars)) ## add to the data dataset a random variable, in order to scale it to desired stat nDataEntries = fulldata.sumEntries() randVar = RooRealVar("rand", "rand", 0, 1) p0 = RooPolynomial("px", "px", randVar) rDataset = p0.generate(RooArgSet(randVar), int(nDataEntries)) fulldata.merge(rDataset) ## add to the input tree the combination of the variables, to be used for the cuts on the dimuon mass deltaB0Mfunc = RooFormulaVar("deltaB0M", "deltaB0M", "@0 - @1", RooArgList(tagged_mass, B0Mass)) deltaJMfunc = RooFormulaVar("deltaJpsiM", "deltaJpsiM", "@0 - @1", RooArgList(mumuMass, JPsiMass)) deltaPMfunc = RooFormulaVar("deltaPsiPM", "deltaPsiPM", "@0 - @1", RooArgList(mumuMass, PsiPMass)) deltaB0M = fulldata.addColumn(deltaB0Mfunc) deltaJpsiM = fulldata.addColumn(deltaJMfunc) deltaPsiPM = fulldata.addColumn(deltaPMfunc) thevars.add(deltaB0M) thevars.add(deltaJpsiM) thevars.add(deltaPsiPM)