Limits.py
add n_observed as input in observed_limits(). This is needed if we want to provide a sample more with more than n_observed events as input.
option to return llr_raw: unlike llr this does not substract the minimum.
@@ -47,9 +47,12 @@ class AsymptoticLimits(DataAnalyzer):
n_toys_per_theta=10000,
returns="pval",
dof=None,
+ n_observed=None,
):
+ if n_observed is None:
+ n_observed=len(x_observed)
theta_grid, return_values, i_ml = self._analyse(
- len(x_observed),
+ n_observed,
x_observed,
theta_ranges,
resolutions,
@@ -127,7 +130,7 @@ class AsymptoticLimits(DataAnalyzer):
):
logger.debug("Calculating p-values for %s expected events", n_events)
- assert returns in ["pval", "llr"], "returns has to be either 'pval' or 'llr'!"
+ assert returns in ["pval", "llr","llr_raw"], "returns has to be either 'pval','llr' or 'llr_raw'!"
# Observation weights
if obs_weights is None:
@@ -189,6 +192,9 @@ class AsymptoticLimits(DataAnalyzer):
# Combine and get p-values
logger.info("Calculating p-values")
log_r = log_r_kin + log_p_xsec
+ if returns == "llr_raw":
+ return theta_grid, log_r, 0
+
logger.debug("Combined -2 log r: %s", -2.0 * log_r)
log_r, i_ml = self._subtract_ml(log_r)
logger.debug("Min-subtracted -2 log r: %s", -2.0 * log_r)
