37x = ROOT.RooRealVar(
"x", 
"x", lowRange, highRange)
 
   40narrow = ROOT.RooGaussian(
"narrow", 
"", x, ROOT.RooFit.RooConst(0.0), ROOT.RooFit.RooConst(0.8))
 
   41wide = ROOT.RooGaussian(
"wide", 
"", x, ROOT.RooFit.RooConst(0.0), ROOT.RooFit.RooConst(2.0))
 
   42reality = ROOT.RooAddPdf(
"reality", 
"", [narrow, wide], ROOT.RooFit.RooConst(0.8))
 
   44data = reality.generate(x, 1000)
 
   47sigma = ROOT.RooRealVar(
"sigma", 
"", 1.0, 0, 10)
 
   48nominal = ROOT.RooGaussian(
"nominal", 
"", x, ROOT.RooFit.RooConst(0.0), sigma)
 
   50wks = ROOT.RooWorkspace(
"myWorksspace")
 
   52wks.Import(data, Rename=
"data")
 
   55if ROOT.TClass.GetClass(
"ROOT::Minuit2::Minuit2Minimizer"):
 
   63bernsteinCorrection = ROOT.RooStats.BernsteinCorrection(tolerance)
 
   64degree = bernsteinCorrection.ImportCorrectedPdf(wks, 
"nominal", 
"x", 
"data")
 
   67    ROOT.Error(
"rs_bernsteinCorrection", 
"Bernstein correction failed !")
 
   70print(
"Correction based on Bernstein Poly of degree ", degree)
 
   75nominal.fitTo(data, PrintLevel=0)
 
   79corrected = wks[
"corrected"]
 
   84corrected.fitTo(data, PrintLevel=0)
 
   85corrected.plotOn(frame, LineColor=
"r")
 
   91    poly.plotOn(frame, LineColor=
"g", LineStyle=
"--")
 
  100checkSamplingDist = 
True 
  114    samplingDist = ROOT.TH1F(
"samplingDist", 
"", 20, 0, 10)
 
  115    samplingDistExtra = ROOT.TH1F(
"samplingDistExtra", 
"", 20, 0, 10)
 
  116    bernsteinCorrection.CreateQSamplingDist(
 
  117        wks, 
"nominal", 
"x", 
"data", samplingDist, samplingDistExtra, degree, numToyMC
 
  121    samplingDistExtra.SetLineColor(ROOT.kRed)
 
  122    samplingDistExtra.Draw()
 
  123    samplingDist.Draw(
"same")
 
  125c1.SaveAs(
"rs_bernsteinCorrection.png")
 
static void SetDefaultMinimizer(const char *type, const char *algo=nullptr)
Set the default Minimizer type and corresponding algorithms.
 
static void SetDefaultPrintLevel(int level)
Set the default Print Level.