Skip to content

Commit ef10548

Browse files
committed
simplify
1 parent e860563 commit ef10548

File tree

1 file changed

+2
-44
lines changed

1 file changed

+2
-44
lines changed

madanalysis/misc/run_recast.py

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from madanalysis.IOinterface.library_writer import LibraryWriter
5050
from madanalysis.misc.histfactory_reader import HF_Background, HF_Signal, get_HFID
5151

52-
from .statistical_models import initialise_statistical_models
52+
from .statistical_models import initialise_statistical_models, compute_poi_upper_limits
5353

5454
try:
5555
import spey
@@ -1266,7 +1266,7 @@ def compute_cls(self, analyses, dataset):
12661266
for model_type, record in zip(model_types, [None, "cov_subset", "pyhf"]):
12671267
models = statistical_models[model_type]
12681268
if models:
1269-
regiondata = self.compute_poi_upper_limits(
1269+
regiondata = compute_poi_upper_limits(
12701270
regiondata,
12711271
models,
12721272
dataset.xsection,
@@ -2143,48 +2143,6 @@ def extract_cls(
21432143

21442144
return regiondata
21452145

2146-
def compute_poi_upper_limits(
2147-
self,
2148-
regiondata: dict,
2149-
stat_models: dict,
2150-
xsection: float,
2151-
is_extrapolated: bool,
2152-
record_to: str = None,
2153-
) -> dict: # pylint: disable=too-many-arguments
2154-
"""
2155-
Compute upper limit on cross section.
2156-
2157-
Args:
2158-
regiondata (``dict``): data for each region
2159-
regions (``list[str]``): list of regions
2160-
xsection (``float``): cross section
2161-
lumi (``float``): luminosity
2162-
is_extrapolated (``bool``): extrapolated luminosity
2163-
record_to (``str``): record to a specific section in regiondata
2164-
2165-
Returns:
2166-
``dict``:
2167-
regiondata
2168-
"""
2169-
self.logger.debug("Compute signal CL...")
2170-
if record_to is not None and record_to not in regiondata.keys():
2171-
regiondata[record_to] = {}
2172-
tags = (
2173-
[[APRIORI], ["exp"]]
2174-
if is_extrapolated
2175-
else [[APOSTERIORI, OBSERVED], ["exp", "obs"]]
2176-
)
2177-
2178-
for tag, label in zip(*tags):
2179-
for reg, stat_model in stat_models.items():
2180-
s95 = stat_model.poi_upper_limit(expected=tag) * xsection
2181-
self.logger.debug(f"{record_to}:: region {reg} s95{label} = {s95:.5f} pb")
2182-
if record_to is None:
2183-
regiondata[reg]["s95" + label] = "%-20.7f" % s95
2184-
else:
2185-
regiondata[record_to][reg]["s95" + label] = "%-20.7f" % s95
2186-
return regiondata
2187-
21882146
def write_cls_output(
21892147
self, analysis, regions, regiondata, errordata, summary, xsflag, lumi
21902148
):

0 commit comments

Comments
 (0)