here is the error output:

ROOT::Math::Fitter::CalculateHessErrors:0: RuntimeWarning: Error when calculating Hessian

Error in <TDecompLU::DecomposeLUCrout: matrix is singular

Error in <TDecompLU::DecomposeLUCrout: matrix is singular

[#0] ERROR:Eval – SPlot Error: covariance matrix is singular; I can’t invert it!

sig 0.0 bkg 0.0

Check SWeights:

[#0] ERROR:InputArguments – InputVariable not in list of sWeighted variables

Yield of signal is 0.0 . From sWeights it is -1.0

[#0] ERROR:InputArguments – InputVariable not in list of sWeighted variables

S/sigma(S) is 0.0 . From sWeights it is -1.0

here is the code:

f0 = TFile.Open(“p1.root”,“READ”)

t0 = f0.Get(“DecayTree”)

t0.SetBranchStatus(“*”, 0)

t0.SetBranchStatus(“D0_M”, 1)

nentry = t0.GetEntries()

print("total number of candidates: ", nentry)

mass = array(“f”, [0])

f1 = TFile.Open(“simplify.root”, “RECREATE”)

t1 = TTree(“newt”, “new tree”)

t1.Branch(“mass”, mass, “D0_M/D”)

for entry in t0:

mass = entry.D0_M

mass = RooRealVar(“mass”, “D0_M[MeV/c^{2}]”, 1800, 1920)

Data = RooDataSet(“data”, “data”, t1, RooArgSet(mass))

mean = RooRealVar(“mean”, “Mean of Gaussian”, 1865, 1800, 1920)

sigma = RooRealVar(“sigma”, “Width of Gaussian”, 6.64, 0, 50)

gauss = RooGaussian(“gauss”, “gauss”, mass, mean, sigma)

c1 = RooRealVar(“c1”, “coefficient #1”, 6, -100, 100)

bkg = RooPolynomial(“bkg”, “bkg”, mass, RooArgList(c1))

sigfrac = RooRealVar(“sigfrac”, “fraction of signal events”, 0.25, 0, 1)

model = RooAddPdf(“model”, “model”, RooArgList(gauss, bkg), RooArgList(sigfrac))

Fit = model.fitTo(Data, RooFit.Save(kTRUE))

#Fit = model.fitTo(Data, RooFit.Extended(kTRUE), RooFit.Save(kTRUE))

mframe = mass.frame(RooFit.Bins(100))

Data.plotOn(mframe, RooFit.MarkerStyle(20), RooFit.MarkerSize(0.5))

model.plotOn(mframe, RooFit.LineColor(1))

model.plotOn(mframe, RooFit.Components(bkg), RooFit.LineColor(4), RooFit.LineStyle(9))

model.plotOn(mframe, RooFit.Components(gauss), RooFit.LineColor(2), RooFit.LineStyle(2))

mframe.Draw()

# sweighting

nsig = RooRealVar(“nsig”, “number of signal events”, sigfrac.getVal()*nentry, 0, nentry)

nbkg = RooRealVar(“nbkg”, “number of background events”, (1.0-sigfrac.getVal())*nentry, 0, nentry)

newmodel = RooAddPdf(“pdf”, “pdf”, RooArgList(gauss, bkg), RooArgList(nsig, nbkg))

sData = RooStats.SPlot(“sData”, “An SPlot”, Data, newmodel, RooArgList(nsig, nbkg))

print(“sig”, str(nsig.getVal()), “bkg”, str(nbkg.getVal()))

print(“Check SWeights:”)

print(“Yield of signal is”, nsig.getVal(), “. From sWeights it is”, sData.GetYieldFromSWeight(“nsig”))

print("S/sigma(S) is ", nsig.getVal()/nsig.getError(), “. From sWeights it is”, sData.GetYieldFromSWeight(“nsig”))