Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jet Veto Map Selector #5

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
665afc4
Add tasks for the combine workflow to perform fits and plot impacts.
jomatthi Jun 6, 2024
01555d9
Fix broken physics model.
jomatthi Jun 6, 2024
9885c7c
Add predefined extra commands to confirm_and_run script.
jomatthi Jun 11, 2024
678423f
Add wp parameter to topsf.CreateDatacards task that now filters the c…
jomatthi Jun 11, 2024
18ae12a
Add CombineBaseTask that defines common parameters, sandbox, requirem…
jomatthi Jun 11, 2024
21f83e3
Add CreateWorkspaceV2 that runs combine's text2workspace.py given an …
jomatthi Jun 11, 2024
8543358
Add RunCommand task defining common requirements and parameters used …
jomatthi Jun 11, 2024
967ec90
Add FitFixin defining the parameters specifying the fit.
jomatthi Jun 11, 2024
f0c28df
Add GenToysV2 generating toys from workspace.
jomatthi Jun 11, 2024
824d85a
Add MultiDimFitV2 performing expected fit first without then with fro…
jomatthi Jun 11, 2024
2bcb230
Add PostFitShapesFromWorkspaceV2 calculating and storing both pre- an…
jomatthi Jun 11, 2024
20e9ffd
Add PlotShapesV2 plotting pre- and postfit shapes, missing: stacked p…
jomatthi Jun 11, 2024
2a5030e
Add ImpactsV2 performing intial fit followed by calculating impacts o…
jomatthi Jun 11, 2024
45e8708
Add PlotImpactsV2 plotting the impacts given a json file.
jomatthi Jun 11, 2024
65fcd22
Add V2 tasks to law config.
jomatthi Jun 11, 2024
22eaa78
Init file for inference tasks V2.
jomatthi Jun 11, 2024
7edf2a6
Add definition of colors to confirm_and_run script.
jomatthi Jul 31, 2024
ac0bed3
Minor fix of law config.
jomatthi Jul 31, 2024
a0d9f3d
Fix scram arch, cmssw and combine versions to adapt to NAF migration …
jomatthi Jul 31, 2024
f580008
Include wp name in cat_label and change position of label in plot.
jomatthi Jul 31, 2024
c130797
Update config for 22preEE analysis, including dataset names and clean…
jomatthi Aug 1, 2024
87411ad
Update wp config for 22preEE analysis, including dataset names and cl…
jomatthi Aug 1, 2024
e340f41
Fix broken increment_stats function.
jomatthi Aug 1, 2024
79ba342
Fix postfit shapes task to adapt to change in combine syntax.
jomatthi Aug 1, 2024
b5e9d51
Fix physics model to write out correct (Anti)SF name.
jomatthi Aug 1, 2024
4d8739c
Move fit setup parameter and process rates to config for easier access.
jomatthi Aug 1, 2024
8fbcb02
Further small adaptations and typo fixes.
jomatthi Aug 1, 2024
8e7f9be
Add CombineHarvester to cmssw_combine sandbox setup script.
jomatthi Aug 1, 2024
7c46170
Add probejet_tau2 and probejet_tau3 variables.
jomatthi Aug 1, 2024
23cf0a4
Include updated cmsdb.
jomatthi Aug 1, 2024
f881c37
Add possibility to produce plots with a cleaned up legend.
jomatthi Aug 15, 2024
4aa786b
Remove fit mode (exp, obs) from CombineBaseTask.
jomatthi Aug 16, 2024
3e110f0
Small change of workspace name to include hashed physics model instea…
jomatthi Aug 16, 2024
a94fb11
Use fit mode param as job_name, adapt reqs in exp fit mode.
jomatthi Aug 16, 2024
7b22376
Add fit mode (exp, obs) param to various tasks and adapt the combine …
jomatthi Aug 16, 2024
a55c15c
Merge branch 'master' into feature/fit_tasks_v2
jomatthi Aug 22, 2024
753aa42
Remove property definition of parameters previously ending with _inst.
jomatthi Aug 22, 2024
b62cbbd
Change default analysis to also be Run 3 SF analysis to match default…
jomatthi Aug 22, 2024
8042b4d
Change dy_lep to dy to match cmsdb convention.
jomatthi Aug 22, 2024
cb33d19
Added comment about not needing minbias_xs any more after move to cor…
jomatthi Aug 22, 2024
b0fe448
Rephrased description of analysis_id in Run 3 to include campaign.
jomatthi Aug 22, 2024
82e3b36
Small adaptations of the Run 3 config.
jomatthi Aug 22, 2024
a693b4a
Rename base inference and combine tasks.
jomatthi Aug 23, 2024
fc8506a
Rename combine verbosity and help parameter.
jomatthi Aug 23, 2024
caf8d77
Use shorter idiom for touching output directory.
jomatthi Aug 23, 2024
d7e546f
Renamed names and cleaned up variable duplicate.
jomatthi Aug 23, 2024
2fe8856
Reverted significance of per_catergory parameter to be True.
jomatthi Aug 23, 2024
a6cca62
Use SettingsParameter to resolve fit_modes.
jomatthi Aug 23, 2024
a153afb
Log files now also inludes the run combine command and the cwd inform…
jomatthi Aug 23, 2024
558943d
Simplify axes transformation.
jomatthi Aug 23, 2024
fc6ffd5
Renamed files to match name change of base classes.
jomatthi Aug 23, 2024
9ed30c4
Simplify workflow requirement implementation.
jomatthi Aug 23, 2024
5cc280e
Restructured inference tasks to use mixins for parameter definitions.
jomatthi Aug 29, 2024
032c4f1
Fixed output path of topsf.CreateDatacards.
jomatthi Aug 29, 2024
cd644e5
Fix plot name.
jomatthi Aug 29, 2024
e7a42d4
Small addition to 'confirm and run' script.
jomatthi Dec 3, 2024
49e1056
Add PSWeights producer and add FSR/ISR as unc. shifts to configs.
jomatthi Dec 3, 2024
5d3e762
Register jec/jer as uncertainty shifts.
jomatthi Dec 3, 2024
7c5a4eb
Small changes and adaptations of fit setup and configs.
jomatthi Dec 3, 2024
3bd89d1
Linting.
jomatthi Dec 3, 2024
040b285
Update columnflow.
jomatthi Dec 3, 2024
12ba4e7
Uncomment datasets and small fixes to configs after testing.
jomatthi Dec 6, 2024
594fc8d
Columnflow patch to prevent comitting too many jobs.
jomatthi Dec 6, 2024
761b84b
Physics Model to rerun with Christopher's old datacards/templates.
jomatthi Dec 6, 2024
6a3a364
Small update to cmsdb.
jomatthi Dec 6, 2024
625ecb3
Adapt template comparison script to changes.
jomatthi Dec 6, 2024
a768cbc
Missing import.
jomatthi Dec 6, 2024
062be1c
Add jet veto map selector step.
jomatthi Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restructured inference tasks to use mixins for parameter definitions.
jomatthi committed Aug 29, 2024
commit 5cc280e6add5002c699789738cb0ff588e8e04c9
9 changes: 1 addition & 8 deletions topsf/tasks/inference_v2/combine_base.py
Original file line number Diff line number Diff line change
@@ -24,14 +24,7 @@ class CombineBaseTask(
asimov_data = luigi.BoolParameter(
default=True,
significant=False,
description="Use Asimov data for the fit",
)

mode = luigi.ChoiceParameter(
choices=["exp", "obs"],
default="exp",
significant=True,
description="Mode of the combine tool",
description="Use Asimov data",
)

# upstream requirements
83 changes: 0 additions & 83 deletions topsf/tasks/inference_v2/fit_mixin.py

This file was deleted.

44 changes: 9 additions & 35 deletions topsf/tasks/inference_v2/gen_toys.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
# coding: utf-8

import luigi
import law
import os

from topsf.tasks.inference_v2.combine_base import CombineBaseTask
from topsf.tasks.inference_v2.mixins import ToysMixin


class GenToysV2(
CombineBaseTask,
ToysMixin,
):
n_toys = luigi.IntParameter(
default=-1,
significant=False,
description="Number of toys to generate",
)

set_parameters = law.CSVParameter(
significant=False,
description="Set parameters for the toys",
)

freeze_gen_parameters = law.CSVParameter(
significant=False,
description="Freeze parameters for the generation",
)

save_toys = luigi.BoolParameter(
default=True,
significant=False,
description="Save the generated toys",
)

gen_name = luigi.Parameter(
significant=True,
description="Name of the generated toys",
)
def output(self):
output_dict = {
"toy_file": self.target(f"higgsCombine{self.gen_name}.GenerateOnly.mH120.123456.root"),
"gen_toys_log": self.target("gen_toys.log"),
}
return output_dict

@property
def gen_toys_name(self):
@@ -47,13 +28,6 @@ def store_parts(self) -> law.util.InsertableDict:
parts.insert_after("fit_v2", "gen_toys", self.gen_toys_name)
return parts

def output(self):
output_dict = {
"toy_file": self.target(f"higgsCombine{self.gen_name}.GenerateOnly.mH120.123456.root"),
"gen_toys_log": self.target("gen_toys.log"),
}
return output_dict

@law.decorator.log
@law.decorator.safe_output
def run(self):
@@ -66,7 +40,7 @@ def run(self):
os.makedirs(output_dirname, exist_ok=True)

# turn inputs into strings understandable by combine
new_set_parameters = ",".join(self.set_parameters)
new_set_parameters = ",".join(self.set_gen_parameters)
new_freeze_gen_parameters = ",".join(self.freeze_gen_parameters)

command_to_run = f"combine -M {self.combine_method}"
113 changes: 58 additions & 55 deletions topsf/tasks/inference_v2/impacts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# coding: utf-8

import luigi
import law
import os

@@ -11,64 +10,14 @@
from topsf.tasks.inference_v2.inference_base import InferenceBaseTask
from topsf.tasks.inference_v2.workspace import CreateWorkspaceV2
from topsf.tasks.inference_v2.gen_toys import GenToysV2
from topsf.tasks.inference_v2.mixins import ModeMixin, ImpactsMixin, ToysMixin


class ImpactsV2(
class ImpactsBaseV2(
InferenceBaseTask,
ModeMixin,
ImpactsMixin,
):
mass = luigi.IntParameter(
significant=True,
description="Mass point",
)

robust_fit = luigi.IntParameter(
significant=False,
description="Run a robust fit",
)

combine_parallel = luigi.IntParameter(
significant=False,
description="Run the fits in parallel",
)

asimov_data = luigi.BoolParameter(
default=True,
significant=False,
description="Use Asimov data for the fit",
)

mode = luigi.ChoiceParameter(
choices=["exp", "obs"],
default="exp",
significant=True,
description="Mode of the combine tool",
)

# upstream requirements
reqs = Requirements(
RemoteWorkflow.reqs,
CreateDatacards=CreateDatacards,
CreateWorkspace=CreateWorkspaceV2,
GenToys=GenToysV2,
)

def workflow_requires(self):
reqs = super().workflow_requires()

reqs["workspace"] = self.requires_from_branch()
if self.mode == "exp":
reqs["toy_file"] = self.requires_from_branch()

return reqs

def requires(self):
reqs = {
"workspace": self.reqs.CreateWorkspace.req(self),
}
if self.mode == "exp":
reqs["gen_toys"] = self.reqs.GenToys.req(self)
return reqs

def output(self):
output_dict = {}
output_dict[f"impacts_{self.mode}"] = self.target(f"impacts_{self.mode}.json")
@@ -129,3 +78,57 @@ def run(self):
# store all outputs in log file
output = out_initial + out_impacts + out_collect
self.output()[f"impacts_{self.mode}_log"].dump(output, formatter="text")


class ImpactsExpV2(
ImpactsBaseV2,
ToysMixin,
):

# upstream requirements
reqs = Requirements(
RemoteWorkflow.reqs,
CreateDatacards=CreateDatacards,
CreateWorkspace=CreateWorkspaceV2,
GenToys=GenToysV2,
)

def workflow_requires(self):
reqs = super().workflow_requires()

reqs["workspace"] = self.requires_from_branch()
reqs["toy_file"] = self.requires_from_branch()

return reqs

def requires(self):
reqs = {
"workspace": self.reqs.CreateWorkspace.req(self),
"gen_toys": self.reqs.GenToys.req(self),
}
return reqs


class ImpactsObsV2(
ImpactsBaseV2,
):

# upstream requirements
reqs = Requirements(
RemoteWorkflow.reqs,
CreateDatacards=CreateDatacards,
CreateWorkspace=CreateWorkspaceV2,
)

def workflow_requires(self):
reqs = super().workflow_requires()

reqs["workspace"] = self.requires_from_branch()

return reqs

def requires(self):
reqs = {
"workspace": self.reqs.CreateWorkspace.req(self),
}
return reqs
15 changes: 13 additions & 2 deletions topsf/tasks/inference_v2/inference_base.py
Original file line number Diff line number Diff line change
@@ -8,13 +8,24 @@
from columnflow.tasks.framework.remote import RemoteWorkflow
from topsf.tasks.inference import CreateDatacards
from columnflow.util import dev_sandbox
from columnflow.tasks.framework.mixins import (
CalibratorsMixin, SelectorStepsMixin, ProducersMixin, MLModelsMixin, InferenceModelMixin,
)

from topsf.tasks.inference_v2.fit_mixin import FitMixin
from topsf.tasks.inference_v2.mixins import FitMixin
from topsf.tasks.base import TopSFTask


class InferenceBaseTask(
FitMixin,
CreateDatacards,
TopSFTask,
InferenceModelMixin,
MLModelsMixin,
ProducersMixin,
SelectorStepsMixin,
CalibratorsMixin,
law.LocalWorkflow,
RemoteWorkflow,
CommandTask,
):
sandbox = dev_sandbox(law.config.get("analysis", "combine_sandbox"))
Loading