Example #1
0
# bands. You can do many things with these objects such as inspect the x/y/ban
# data, pass then to plotutil.plot routine to make pdf plots, ...
# Here, we will just create text files of the plot data. This is useful if you want
# to apply your own plotting routines or present the result in a text Table.
plot_exp.write_txt('bayesian_limits_expected.txt')
if not limit_type == 'expected':
    plot_obs.write_txt('bayesian_limits_observed.txt')

# 2.b. CLs limits
# calculate cls limit plots. The interface is very similar to bayesian_limits. However, there are a few
# more options such as the definition of the test statistic which is usually a likelihood ratio but can differ in
# which parameters are minimized and which constraints / ranges are applied during minimization.
# Here, we stay with the default which fixes beta_signal=0
# for the background only hypothesis and lets it float freely for the signal+background hypothesis.
# See cls_limits documentation for more options.
plot_exp, plot_obs = cls_limits(model, what=limit_type, signal_processes = [['Higgs_125']], debug_cls = True, debug = True)

# as for the bayesian limits: write the result to a text file
plot_exp.write_txt('cls_limits_expected.txt')
if not limit_type == 'expected':
    plot_obs.write_txt('cls_limits_observed.txt')

# 3. compatibility tests:
# make a chi2 test by comparing the chi2 value distribution *after* fitting as obtained from background-only toys with
# a fit performed on data. The "signal_process_group" parameter is usually a list
# of the processes to consider together as the signal (which will be all scaled by beta_signal simultaneously).
# Here, we only include background and just use some arbitrary signal process, set the input beta_signal to zero ("toys:0.0")
# and also fix beta_signal to 0.0 during the fit ("fix:0.0").
p = chi2_test(model, signal_process_group = ['Higgs_125'], input = "toys:0.0", signal_prior = "fix:0.0")
print 'p-value from background-only chi2 test: ', p
Example #2
0
# plot_exp and plot_obs are instances of plotutil.plotdata. they contain x/y values and
# bands. You can do many things with these objects such as inspect the x/y/ban
# data, pass then to plotutil.plot routine to make pdf plots, ...
# Here, we will just create text files of the plot data. This is useful if you want
# to apply your own plotting routines or present the result in a text Table.
plot_exp.write_txt('bayesian_limits_expected.txt')
plot_obs.write_txt('bayesian_limits_observed.txt')

# 2.b. CLs limits
# calculate cls limit plots. The interface is very similar to bayesian_limits. However, there are a few
# more options such as the definition of the test statistic which is usually a likelihood ratio but can differ in
# which parameters are minimized and which constraints / ranges are applied during minimization.
# Here, we stay with the default which fixes beta_signal=0
# for the background only hypothesis and lets it float freely for the signal+background hypothesis.
# See cls_limits documentation for more options.
plot_exp, plot_obs = cls_limits(model, signal_processes = [['zp1000'], ['zp2000'], ['zp3000']])

# as for the bayesian limits: write the result to a text file
plot_exp.write_txt('cls_limits_expected.txt')
plot_obs.write_txt('cls_limits_observed.txt')

# 3. compatibility tests:
# make a chi2 test by comparing the chi2 value distribution *after* fitting as obtained from background-only toys with
# a fit performed on data. The "signal_process_group" parameter is usually a list
# of the processes to consider together as the signal (which will be all scaled by beta_signal simultaneously).
# Here, we only include background and just use some arbitrary signal process, set the input beta_signal to zero ("toys:0.0")
# and also fix beta_signal to 0.0 during the fit ("fix:0.0").
p = chi2_test(model, signal_process_group = ['zp1000'], input = "toys:0.0", signal_prior = "fix:0.0")
print 'p-value from background-only chi2 test: ', p

# if one wants to include some signal in the comparison, one should make toys accordingly with signal, e.g.,