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

Version 2 of inference workflow #3

Open
wants to merge 67 commits into
base: master
Choose a base branch
from

Conversation

jomatthi
Copy link
Contributor

This PR implements a more thought-out version of the task structure of the inference workflow calculating the top tagging scale factors, impacts of the considered nuisance parameters, and pre- and postfit shapes. This is achieved by restructuring the inheritance and internal dependencies between the different blocks, and by introducing a CombineBaseTask and a FitMixin class that incorporates common parameters needed by the other tasks. The same tasks introduced in PR #1 are also implemented in this version of the workflow. In addition, the topsf.PlotShapesV2 task is implemented, taking the output root file of tops.PostFitShapesFromWorkspaceV2. This is however not yet final and still to be polished and expanded to also plot the shapes of the different subprocesses contributions.

To make sure only the shape information relevant for the wanted fit is used, the topsf.CreateDatacards task now requires a wp_name parameter to be set as the SF for the different working points are not to be fitted simultaneously.

The confirm_and_run.sh script now also accepts and expands some predefined and often used extra_params.

An example command that should trigger the entire workflow and result in impact plots for each of the SF:

source $TOPSF_BASE/confirm_and_run.sh

version=my_version

fit_args=(
    "--physics-model" "topsf.inference.combine_physics_model:topsf_model"
    "--wp-name" "very_tight"
    "--fit-modes" "3q:ThetaLike,2q:ThetaLike,0o1q:ThetaLike"
    "--years" "UL17"
    "--pt-bins" "pt_300_400,pt_400_480"
    "--sf-range" "[1,0.2,2.0]"
    "--mode" "exp"
)

common_args=(
    "--version" "${version}"
    "--inference-model" "uhh2"
    "--producers" "weights,features"
)

args=(
    "--poi" "SF__0o1q__UL17__pt_300_400,SF__2q__UL17__pt_300_400,SF__0o1q__UL17__pt_400_480,SF__2q__UL17__pt_400_480,SF__3q__UL17__pt_300_400,SF__3q__UL17__pt_400_480"
    "--cms-label" "'Simulation Private Work'"
    "--height" "800"
    "--topsf.ImpactsV2-mass" "0"
    "--topsf.ImpactsV2-robust-fit" "1"
    "--topsf.ImpactsV2-combine-parallel" "12"  # FIXME How can I remove this?
    "--topsf.GenToysV2-set-parameters" "SF__0o1q__UL17__pt_300_400=1.,SF__2q__UL17__pt_300_400=1.,SF__3q__UL17__pt_300_400=1.,SF__0o1q__UL17__pt_400_480=1.,SF__2q__UL17__pt_400_480=1.,SF__3q__UL17__pt_400_480=1."
    "--topsf.GenToysV2-freeze-gen-parameters" "SF__0o1q__UL17__pt_300_400,SF__2q__UL17__pt_300_400,SF__3q__UL17__pt_300_400,SF__0o1q__UL17__pt_400_480,SF__2q__UL17__pt_400_480,SF__3q__UL17__pt_400_480"
    "--topsf.GenToysV2-gen-name" "_toy"
    ${fit_args[@]}
    ${common_args[@]}
)

command_to_run="law run topsf.PlotImpactsV2 ${args[@]}"
confirm_and_run "$command_to_run"

jomatthi added 30 commits June 6, 2024 13:50
…for any combine command of the form 'combine -m method -t -l'.
…lot of the contributions of the (sub-) processes.
…f all nuisances, collecting the results in a json file.
@jomatthi
Copy link
Contributor Author

Thank you for the first set of comments and the valuable feedback, @dsavoiu. The last commits address the comments, more or less one commit per comment to hopefully help with reviewing.

Further improvements using mixing are currently in development.

@jomatthi
Copy link
Contributor Author

The latest commit include a restructured version of the inference tasks, now using mixins to declare the used parameters for each tasks.

Also, instead of using one task to produce expected and observed impacts, now two classes are defined: topsf.ImpactsExpV2 and topsf.ImpactsObsV2 to avoid the dependency on the topsf.GenToysV2 task in the observed case. This is however not perfect and definitively up to discussion and currently limited by my limited knowledge on how to properly implement a dynamic dependency. Feedback is appreciated!

@jomatthi
Copy link
Contributor Author

jomatthi commented Dec 6, 2024

The latest commits include the additional functionalities including FSR/ISR and jec uncertainty shifts.
The current workflow is tested with the limited UL17 and 22pre/postEE configs, both for the WP and the SF analysis up to the creation of datacards. The fitting workflow was not changed in the latest commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants