31workspaceName =
"combined"
32modelConfigName =
"ModelConfig"
41filename =
"results/example_combined_GaussExample_model.root"
43if ROOT.gSystem.AccessPathName(filename):
45 print(
"will run standard hist2workspace example")
46 ROOT.gROOT.ProcessLine(
".! prepareHistFactory .")
47 ROOT.gROOT.ProcessLine(
".! hist2workspace config/example.xml")
48 print(
"\n\n---------------------")
49 print(
"Done creating example input")
50 print(
"---------------------\n\n")
52file = ROOT.TFile.Open(filename)
60w = file.Get(workspaceName)
63mc = w[modelConfigName]
74pl = ROOT.RooStats.ProfileLikelihoodCalculator(data, mc)
75pl.SetConfidenceLevel(confLevel)
76interval = pl.GetInterval()
79firstPOI = mc.GetParametersOfInterest().first()
80limit_lower, limit_upper = interval.LowerLimit(firstPOI), interval.UpperLimit(firstPOI)
81print(f
"\n>>>> RESULT : {confLevel * 100}% interval on {firstPOI.GetName()} is : [{limit_lower}, {limit_upper}]\n")
86 "making a plot of the profile likelihood function ....(if it is taking a lot of time use less points or the "
87 "TF1 drawing option)\n"
89plot = ROOT.RooStats.LikelihoodIntervalPlot(interval)
90plot.SetNPoints(nScanPoints)
92 plot.SetRange(poiXMin, poiXMax)
100 nullparams = ROOT.RooArgSet(
"nullparams")
101 nullparams.addClone(firstPOI)
102 nullparams.setRealValue(firstPOI.GetName(), nullParamValue)
103 pl.SetNullParameters(nullparams)
104 print(
"Perform Test of Hypothesis : null Hypothesis is " + firstPOI.GetName() + str(nullParamValue))
105 result = pl.GetHypoTest()
106 print(
"\n>>>> Hypotheis Test Result ")