47 rs_numberCountingCombination_expected()
49 rs_numberCountingCombination_observed()
51 rs_numberCountingCombination_observedWithTau()
55def rs_numberCountingCombination_expected():
71 s = np.array([20.0, 10.0])
72 b = np.array([100.0, 100.0])
73 db = np.array([0.0100, 0.0100])
81 f = ROOT.RooStats.NumberCountingPdfFactory()
82 wspace = ROOT.RooWorkspace()
91 f.AddModel(s, 2, wspace,
"TopLevelPdf",
"masterSignal")
96 f.AddExpData(s, b, db, 2, wspace,
"ExpectedNumberCountingData")
106 mu = wspace.var(
"masterSignal")
107 poi = ROOT.RooArgSet(mu)
108 nullParams = ROOT.RooArgSet(
"nullParams")
109 nullParams.addClone(mu)
111 nullParams.setRealValue(
"masterSignal", 0)
115 plc = ROOT.RooStats.ProfileLikelihoodCalculator(
116 wspace[
"ExpectedNumberCountingData"], wspace[
"TopLevelPdf"], poi, 0.05, nullParams
120 htr = plc.GetHypoTest()
122 print(f
"-------------------------------------------------")
123 print(f
"The p-value for the null is ", htr.NullPValue())
124 print(f
"Corresponding to a significance of ", htr.Significance())
125 print(f
"-------------------------------------------------\n\n")
138 paramsOfInterest = nullParams
139 plc.SetParameters(paramsOfInterest)
140 lrint = plc.GetInterval()
141 lrint.SetConfidenceLevel(0.95)
146 lower = lrint.LowerLimit(mu)
147 upper = lrint.UpperLimit(mu)
149 c1 = ROOT.TCanvas(
"myc1",
"myc1")
150 lrPlot = ROOT.RooStats.LikelihoodIntervalPlot(lrint)
151 lrPlot.SetMaximum(3.0)
155 c1.SaveAs(
"rs_numberCountingCombination.png")
158 print(
"signal = ", lower)
159 print(
"signal = ", upper)
166 paramsOfInterest.setRealValue(
"masterSignal", 0.0)
167 print(f
"-------------------------------------------------")
168 print(f
"Consider this parameter point:")
169 paramsOfInterest.first().
Print()
170 if lrint.IsInInterval(paramsOfInterest):
171 print(f
"It IS in the interval.")
173 print(f
"It is NOT in the interval.")
174 print(f
"-------------------------------------------------\n\n")
177 paramsOfInterest.setRealValue(
"masterSignal", 2.0)
178 print(f
"-------------------------------------------------")
179 print(f
"Consider this parameter point:")
180 paramsOfInterest.first().
Print()
181 if lrint.IsInInterval(paramsOfInterest):
182 print(f
"It IS in the interval.")
184 print(f
"It is NOT in the interval.")
185 print(f
"-------------------------------------------------\n\n")
195 # Here's an example of what is in the workspace
197 RooWorkspace(NumberCountingWS) Number Counting WS contents
201 (x_0,masterSignal,expected_s_0,b_0,y_0,tau_0,x_1,expected_s_1,b_1,y_1,tau_1)
205 RooProdPdf.joint[ pdfs=(sigRegion_0,sideband_0,sigRegion_1,sideband_1) ] = 2.20148e-08
206 RooPoisson.sigRegion_0[ x=x_0 mean=splusb_0 ] = 0.036393
207 RooPoisson.sideband_0[ x=y_0 mean=bTau_0 ] = 0.00398939
208 RooPoisson.sigRegion_1[ x=x_1 mean=splusb_1 ] = 0.0380088
209 RooPoisson.sideband_1[ x=y_1 mean=bTau_1 ] = 0.00398939
213 RooAddition.splusb_0[ set1=(s_0,b_0) set2=() ] = 120
214 RooProduct.s_0[ compRSet=(masterSignal,expected_s_0) compCSet=() ] = 20
215 RooProduct.bTau_0[ compRSet=(b_0,tau_0) compCSet=() ] = 10000
216 RooAddition.splusb_1[ set1=(s_1,b_1) set2=() ] = 110
217 RooProduct.s_1[ compRSet=(masterSignal,expected_s_1) compCSet=() ] = 10
218 RooProduct.bTau_1[ compRSet=(b_1,tau_1) compCSet=() ] = 10000
222 RooDataSet.ExpectedNumberCountingData(x_0,y_0,x_1,y_1)
224 embedded pre-calculated expensive components
225 -------------------------------------------
229def rs_numberCountingCombination_observed():
244 s_c = (ctypes.c_double *
len(s))(*s)
252 f = NumberCountingPdfFactory()
254 f.AddModel(s_c, 2, wspace,
"TopLevelPdf",
"masterSignal")
258 mainMeas = [123.0, 117.0]
259 mainMeas_c = (ctypes.c_double *
len(mainMeas))(*mainMeas)
260 bkgMeas = [111.23, 98.76]
261 bkgMeas_c = (ctypes.c_double *
len(bkgMeas))(*bkgMeas)
262 dbMeas = [0.011, 0.0095]
263 dbMeas_c = (ctypes.c_double *
len(bkgMeas))(*dbMeas)
264 f.AddData(mainMeas_c, bkgMeas_c, dbMeas_c, 2, wspace,
"ObservedNumberCountingData")
274 mu = wspace.var(
"masterSignal")
277 nullParams.addClone(mu)
279 nullParams.setRealValue(
"masterSignal", 0)
283 plc = ProfileLikelihoodCalculator(
284 wspace.data(
"ObservedNumberCountingData"), wspace.pdf(
"TopLevelPdf"), poi, 0.05, nullParams
287 wspace.var(
"tau_0").
Print()
288 wspace.var(
"tau_1").
Print()
291 htr = plc.GetHypoTest()
292 print(f
"-------------------------------------------------")
293 print(f
"The p-value for the null is ", htr.NullPValue())
294 print(f
"Corresponding to a significance of ", htr.Significance())
295 print(f
"-------------------------------------------------\n\n")
298 # observed case should return:
299 -------------------------------------------------
300 The p-value for the null is 0.0351669
301 Corresponding to a significance of 1.80975
302 -------------------------------------------------
310 paramsOfInterest = nullParams
311 plc.SetParameters(paramsOfInterest)
312 lrint = plc.GetInterval()
313 lrint.SetConfidenceLevel(0.95)
316 print(
"signal = ", lrint.LowerLimit(mu))
317 print(
"signal = ", lrint.UpperLimit(mu))
326def rs_numberCountingCombination_observedWithTau():
341 s_c = (ctypes.c_double * 2)(*s)
349 f = NumberCountingPdfFactory()
351 f.AddModel(s_c, 2, wspace,
"TopLevelPdf",
"masterSignal")
355 mainMeas = [123.0, 117.0]
356 sideband = [11123.0, 9876.0]
358 mainMeas_c = (ctypes.c_double * 2)(*mainMeas)
359 sideband_c = (ctypes.c_double * 2)(*sideband)
360 tau_c = (ctypes.c_double * 2)(*tau)
361 f.AddDataWithSideband(mainMeas_c, sideband_c, tau_c, 2, wspace,
"ObservedNumberCountingDataWithSideband")
371 mu = wspace.var(
"masterSignal")
374 nullParams.addClone(mu)
376 nullParams.setRealValue(
"masterSignal", 0)
380 plc = ProfileLikelihoodCalculator(
381 wspace.data(
"ObservedNumberCountingDataWithSideband"), wspace.pdf(
"TopLevelPdf"), poi, 0.05, nullParams
385 htr = plc.GetHypoTest()
386 print(f
"-------------------------------------------------")
387 print(f
"The p-value for the null is ", htr.NullPValue())
388 print(f
"Corresponding to a significance of ", htr.Significance())
389 print(f
"-------------------------------------------------\n\n")
392 # observed case should return:
393 -------------------------------------------------
394 The p-value for the null is 0.0352035
395 Corresponding to a significance of 1.80928
396 -------------------------------------------------
404 paramsOfInterest = nullParams
405 plc.SetParameters(paramsOfInterest)
406 lrint = plc.GetInterval()
407 lrint.SetConfidenceLevel(0.95)
410 print(
"signal = ", lrint.LowerLimit(mu))
411 print(
"signal = ", lrint.UpperLimit(mu))
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
void Print(GNN_Data &d, std::string txt="")
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Persistable container for RooFit projects.