44 infile="", workspaceName="combined", modelConfigName="ModelConfig", dataName="obsData"
56 filename =
"results/example_combined_GaussExample_model.root"
57 fileExist =
not ROOT.gSystem.AccessPathName(filename)
61 print(f
"will run standard hist2workspace example")
62 ROOT.gROOT.ProcessLine(
".! prepareHistFactory .")
63 ROOT.gROOT.ProcessLine(
".! hist2workspace config/example.xml")
64 print(f
"\n\n---------------------")
65 print(f
"Done creating example input")
66 print(f
"---------------------\n\n")
72 file = ROOT.TFile.Open(filename)
76 print(f
"StandardRooStatsDemoMacro: Input file {filename} is not found")
84 w = file.Get(workspaceName)
86 print(f
"workspace not found")
90 mc = w.obj(modelConfigName)
93 data = w.data(dataName)
96 if not data
or not mc:
98 print(f
"data or ModelConfig was not found")
104 obs = mc.GetObservables().first()
107 firstPOI = mc.GetParametersOfInterest().first()
109 firstPOI.setVal(muVal)
112 mc.GetPdf().fitTo(data)
116 mc.GetNuisanceParameters().
Print(
"v")
118 print(f
" check expectedData by category")
121 if str(mc.GetPdf().ClassName()) ==
"RooSimultaneous":
122 print(f
"Is a simultaneous PDF")
125 print(f
"Is not a simultaneous PDF")
128 channelCat = simPdf.indexCat()
129 catName = channelCat.begin().first
130 pdftmp = (mc.GetPdf()).getPdf(str(catName))
131 obstmppdftmp.getObservables(mc.GetObservables())
134 print(
"{0}=={0}::{1}".
format(channelCat.GetName(), catName))
135 print(catName,
" ", channelCat.getLabel())
139 Cut=
"{0}=={0}::{1}".
format(channelCat.GetName(), catName),
143 normCount = data.sumEntries(
"{0}=={0}::{1}".
format(channelCat.GetName(), catName))
145 pdftmp.plotOn(frame, Normalization(normCount, ROOT.RooAbsReal.NumEvent), LineWidth=2)
147 print(
"expected events = ", mc.GetPdf().expectedEvents(data.get()))
153 for var
in mc.GetNuisanceParameters():
155 frame.SetYTitle(var.GetName())
156 data.plotOn(frame, MarkerSize(1))
158 mc.GetPdf().plotOn(frame, LineWidth(1))
160 mc.GetPdf().plotOn(frame, LineColor(kRed), LineStyle(kDashed), LineWidth(1))
162 mc.GetPdf().plotOn(frame, LineColor(kGreen), LineStyle(kDashed), LineWidth(1))
163 frameList.append(frame)
167 channelCat = simPdf.indexCat()
168 for tt
in channelCat:
170 if nPlots == nPlotsMax:
175 print(
"on type ", catName,
" ")
177 pdftmp = simPdf.getPdf(str(catName))
180 obstmp = pdftmp.getObservables(mc.GetObservables())
185 for var
in mc.GetNuisanceParameters():
187 if nPlots >= nPlotsMax:
190 c2 = ROOT.TCanvas(
"c2")
192 frame.SetName(f
"frame{nPlots}")
193 frame.SetYTitle(var.GetName())
195 cut =
"{0}=={0}::{1}".
format(channelCat.GetName(), catName)
197 print(catName,
" ", channelCat.getLabel())
205 normCount = data.sumEntries(cut)
207 if str(var.GetName()) ==
"Lumi":
208 print(f
"working on lumi")
209 var.setVal(w.var(
"nominalLumi").getVal())
233 normCount = pdftmp.expectedEvents(obstmp)
234 pdftmp.plotOn(frame, ROOT.RooFit.Normalization(normCount, ROOT.RooAbsReal.NumEvent), LineWidth=2)
236 if str(var.GetName()) ==
"Lumi":
237 print(f
"working on lumi")
238 var.setVal(w.var(
"nominalLumi").getVal() + 0.05)
241 var.setVal(nSigmaToVary)
246 normCount = pdftmp.expectedEvents(obstmp)
249 ROOT.RooFit.Normalization(normCount, ROOT.RooAbsReal.NumEvent),
255 if str(var.GetName()) ==
"Lumi":
256 print(f
"working on lumi")
257 var.setVal(w.var(
"nominalLumi").getVal() - 0.05)
260 var.setVal(-nSigmaToVary)
265 normCount = pdftmp.expectedEvents(obstmp)
268 ROOT.RooFit.Normalization(normCount, ROOT.RooAbsReal.NumEvent),
275 if str(var.GetName()) ==
"Lumi":
276 print(f
"working on lumi")
277 var.setVal(w.var(
"nominalLumi").getVal())
282 frameList.append(frame)
290 c2.SaveAs(f
"StandardHistFactoryPlotsWithCategories.1.{catName}_{obs.GetName()}_{var.GetName()}.png")
296 c1 = ROOT.TCanvas(
"c1",
"ProfileInspectorDemo", 800, 200)
297 nFrames =
len(frameList)
299 nx =
int(sqrt(nFrames))
300 ny = ROOT.TMath.CeilNint(nFrames / nx)
301 nx = ROOT.TMath.CeilNint(sqrt(nFrames))
305 for i
in range(nFrames):
310 c1.SaveAs(
"StandardHistFactoryPlotsWithCategories.2.pdf")
316 infile=
"", workspaceName=
"combined", modelConfigName=
"ModelConfig", dataName=
"obsData"
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
void Print(GNN_Data &d, std::string txt="")