Commit 14a8cfe3 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Artifically extend ranges in nll scans to include expected best fits.

parent 60cf7ece
......@@ -159,7 +159,7 @@ colors = DotDict(
# color sequence for plots with multiple elements
color_sequence = ["blue", "red", "green", "grey", "pink", "cyan", "orange", "light_green", "yellow"]
color_sequence += 10 * ["black"]
color_sequence += 10 * ["grey"]
# marker sequence for plots with multiple elements
marker_sequence = [20, 21, 22, 23, 24, 25, 26, 32, 27, 33, 28, 34, 29, 30]
......
......@@ -21,7 +21,8 @@ from dhi.tasks.combine import (
CreateWorkspace,
)
from dhi.tasks.snapshot import Snapshot, SnapshotUser
from dhi.util import unique_recarray, extend_recarray, convert_dnll2
from dhi.config import poi_data
from dhi.util import unique_recarray, extend_recarray, convert_dnll2, linspace
class LikelihoodBase(POIScanTask, SnapshotUser):
......@@ -80,6 +81,40 @@ class LikelihoodScan(LikelihoodBase, CombineCommandTask, law.LocalWorkflow, HTCo
else:
blinded_args = "--seed {self.branch} --toys {self.toys}".format(self=self)
# ensure that ranges of scanned parameters contain their SM values (plus one step)
# in order for the likelihood scan to find the expected minimum and compute all deltaNLL
# values with respect that minimum; otherwise, results of different scans cannot be stitched
# together as they were potentially compared against different minima; this could be
# simplified by https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit/pull/686 which
# would only require to set "--setParameterRangesForGrid {self.joined_scan_ranges}"
ext_ranges = []
for p, ranges in self.scan_parameters_dict.items():
# gather data
start, stop, points = ranges[0]
sm_value = poi_data.get(p, {}).get("sm_value", 1.)
step_size = (float(stop - start) / (points - 1)) if points > 1 else 1
assert step_size > 0
# decrease the starting point until the sm value is fully contained
while start >= sm_value:
start -= step_size
points += 1
# increase the stopping point until the sm value is fully contained
while stop <= sm_value:
stop += step_size
points += 1
# store the extended range
ext_ranges.append((start, stop, points))
# compute the new n-D point space
ext_space = self._get_scan_linspace(ext_ranges)
# get the point index of the current branch
ext_point = ext_space.index(self.branch_data)
# recreate joined expressions for the combine command
ext_joined_scan_points = ",".join(map(str, (p for _, _, p in ext_ranges)))
ext_joined_scan_ranges = ":".join(
"{}={},{}".format(name, start, stop)
for name, (start, stop, _) in zip(self.scan_parameter_names, ext_ranges)
)
# build the command
cmd = (
"combine -M MultiDimFit {workspace}"
......@@ -89,12 +124,11 @@ class LikelihoodScan(LikelihoodBase, CombineCommandTask, law.LocalWorkflow, HTCo
" {blinded_args}"
" --algo grid"
" --redefineSignalPOIs {self.joined_pois}"
" --setParameterRangesForGrid {self.joined_scan_ranges}"
" --gridPoints {self.joined_scan_points}"
" --firstPoint {self.branch}"
" --lastPoint {self.branch}"
" --gridPoints {ext_joined_scan_points}"
" --firstPoint {ext_point}"
" --lastPoint {ext_point}"
" --alignEdges 1"
" --setParameterRanges {self.joined_parameter_ranges}"
" --setParameterRanges {ext_joined_scan_ranges}:{self.joined_parameter_ranges}"
" --setParameters {self.joined_parameter_values}"
" --freezeParameters {self.joined_frozen_parameters}"
" --freezeNuisanceGroups {self.joined_frozen_groups}"
......@@ -110,6 +144,9 @@ class LikelihoodScan(LikelihoodBase, CombineCommandTask, law.LocalWorkflow, HTCo
output=self.output().path,
blinded_args=blinded_args,
snapshot_args=snapshot_args,
ext_joined_scan_points=ext_joined_scan_points,
ext_joined_scan_ranges=ext_joined_scan_ranges,
ext_point=ext_point,
)
return cmd
......
......@@ -90,10 +90,10 @@ setup() {
cd "$CMSSW_VERSION/src" && \
eval "$( scramv1 runtime -sh )" && \
scram b && \
git clone --depth 1 --branch parameter_ranges_for_grid https://github.com/riga/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit && \
git clone --depth 1 https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit && \
cd HiggsAnalysis/CombinedLimit && \
git fetch --tags && \
git checkout parameter_ranges_for_grid && \
git checkout tags/v8.2.0 && \
chmod ug+x test/diffNuisances.py && \
scram b -j ${DHI_INSTALL_CORES}
) || return "$?"
......@@ -103,10 +103,10 @@ setup() {
echo "installing standalone combine at $DHI_SOFTWARE/HiggsAnalysis/CombinedLimit"
cd "$DHI_SOFTWARE"
rm -rf HiggsAnalysis/CombinedLimit
git clone --depth 1 --branch parameter_ranges_for_grid https://github.com/riga/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit && \
git clone --depth 1 https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit && \
cd HiggsAnalysis/CombinedLimit && \
git fetch --tags && \
git checkout parameter_ranges_for_grid && \
git checkout tags/v8.2.0 && \
chmod ug+x test/diffNuisances.py && \
source env_standalone.sh "" && \
make -j ${DHI_INSTALL_CORES} && \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment