106def OneSidedFrequentistUpperLimitWithBands(
107 infile="", workspaceName="combined", modelConfigName="ModelConfig", dataName="obsData"
110 confidenceLevel = 0.95
119 filename =
"results/example_combined_GaussExample_model.root"
124 print(f
"will run standard hist2workspace example")
127 print(f
"\n\n---------------------")
128 print(f
"Done creating example input")
129 print(f
"---------------------\n\n")
139 print(f
"StandardRooStatsDemoMacro: Input file {filename} is not found")
153 print(f
"workspace not found")
157 mc =
w.obj(modelConfigName)
163 if not data
or not mc:
165 print(f
"data or ModelConfig was not found")
216 print(f
"Not sure what to do about this model")
219 print(f
"will use global observables for unconditional ensemble")
229 f
"\n95% interval on {firstPOI.GetName()} is : [{interval.LowerLimit(firstPOI)}, {interval.UpperLimit(firstPOI)} ]"
282 print(f
"\nWill use these parameter points to generate pseudo data for bkg only")
296 for imc
in range(nToyMC):
313 print(f
"Not sure what to do about this model")
360 if obsTSatObsUL < toyTSatObsUL:
361 CLb += (1.0) / nToyMC
362 if obsTSatObsUL <= toyTSatObsUL:
363 CLbinclusive += (1.0) / nToyMC
384 # loop over points in belt to find upper limit for this toy data
386 for i in range(histOfThresholds.GetNbinsX() ++i)
387 tmpPoint = (RooArgSet) parameterScan.get(i).clone("temp")
388 print("---------------- ", i)
390 print(f"from hist ", histOfThresholds.GetBinCenter(i+1) )
391 arMax = histOfThresholds.GetBinContent(i+1)
392 # cout << " threshold from Hist = aMax " << arMax<<endl;
393 # double arMax2 = belt->GetAcceptanceRegionMax(*tmpPoint);
394 # cout << "from scan arMax2 = "<< arMax2 << endl; # not the same due to TH1F not TH1D
395 # cout << "scan - hist" << arMax2-arMax << endl;
396 firstPOI.setVal( histOfThresholds.GetBinCenter(i+1))
397 # double thisTS = profile->getVal();
398 thisTS = fc.GetTestStatSampler().EvaluateTestStatistic(toyData,tmpPOI)
400 # cout << "poi = " << firstPOI->getVal()
401 # = ROOT.Double_t() << " max is " << arMax << " this profile = " << thisTS << endl;
402 # cout << "thisTS = " << thisTS<<endl;
404 # NOTE: need to add a small epsilon term for single precision vs. double precision
405# if(thisTS<=arMax + 1e-7){
406# thisUL = firstPOI->getVal();
425 c1.SaveAs(
"OneSidedFrequentistUpperLimitWithBands.png")
430 SamplingDistPlot sampPlot
432 tmpPoint = (RooArgSet) parameterScan.get(indexInScan).clone("temp")
433 firstPOI.setVal( tmpPoint.getRealValue(firstPOI.GetName()) )
434 toymcsampler.SetParametersForTestStat(tmpPOI)
435 samp = toymcsampler.GetSamplingDistribution(tmpPoint)
436 sampPlot.AddSamplingDistribution(samp)
444 band2sigDown = band1sigDown = bandMedian = band1sigUp = band2sigUp =
ROOT.Double_t()
457 print(f
"-2 sigma band ", band2sigDown)
458 print(f
"-1 sigma band {band1sigDown} [Power Constraint)]")
459 print(f
"median of band ", bandMedian)
460 print(f
"+1 sigma band ", band1sigUp)
461 print(f
"+2 sigma band ", band2sigUp)
465 print(f
"CLb strict [P(toy>obs|0)] for observed 95% upper-limit ", CLb)
466 print(
"inclusive [P(toy>=obs|0)] for observed 95% upper-limit ", CLbinclusive)
469OneSidedFrequentistUpperLimitWithBands(
470 infile=
"", workspaceName=
"combined", modelConfigName=
"ModelConfig", dataName=
"obsData"
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Print(Option_t *option="") const override