43 filename =
"results/example_combined_GaussExample_model.root"
44 fileExist =
not ROOT.gSystem.AccessPathName(filename)
48 print(f
"will run standard hist2workspace example")
49 ROOT.gROOT.ProcessLine(
".! prepareHistFactory .")
50 ROOT.gROOT.ProcessLine(
".! hist2workspace config/example.xml")
51 print(f
"\n\n---------------------")
52 print(f
"Done creating example input")
53 print(f
"---------------------\n\n")
59 file = ROOT.TFile.Open(filename)
63 print(f
"StandardRooStatsDemoMacro: Input file {filename} is not found")
71 w = file.Get(workspaceName)
73 print(f
"workspace not found")
77 mc = w.obj(modelConfigName)
80 data = w.data(dataName)
83 if not data
or not mc:
85 print(f
"data or ModelConfig was not found")
93 fc = ROOT.RooStats.FeldmanCousins(data, mc)
94 fc.SetConfidenceLevel(0.95)
96 fc.UseAdaptiveSampling(
True)
98 fc.CreateConfBelt(
True)
107 if not mc.GetPdf().canBeExtended():
108 if data.numEntries() == 1:
109 fc.FluctuateNumDataEntries(
False)
111 print(f
"Not sure what to do about this model")
114 interval = fc.GetInterval()
115 belt = fc.GetConfidenceBelt()
118 firstPOI = mc.GetParametersOfInterest().first()
120 f
"\n95% interval on {firstPOI.GetName()} is : [{interval.LowerLimit(firstPOI)}, ",
121 interval.UpperLimit(firstPOI),
129 parameterScan = fc.GetPointsToScan()
130 tmpPoint = ROOT.RooArgSet()
133 histOfThresholds = ROOT.TH1F(
134 "histOfThresholds",
"", parameterScan.numEntries(), firstPOI.getMin(), firstPOI.getMax()
140 for i
in range(parameterScan.numEntries()):
141 tmpPoint = parameterScan.get(i).clone(
"temp")
142 arMax = belt.GetAcceptanceRegionMax(tmpPoint)
143 arMin = belt.GetAcceptanceRegionMax(tmpPoint)
144 poiVal = tmpPoint.getRealValue(firstPOI.GetName())
145 histOfThresholds.Fill(poiVal, arMax)
147 histOfThresholds.SetMinimum(0)
148 c_belt = ROOT.TCanvas(
"c_belt",
"c_belt")
149 histOfThresholds.Draw()
152 c_belt.SaveAs(
"StandardFeldmanCousinsDemo.1.belt.png")