Skip to content

Fix QCD Shape unc, calulated at hist merge step, not event wise Unc, so added data-driven flag so that it do not crash before hist-Merge#281

Open
Sayan-Dhani wants to merge 1 commit into
cms-flaf:mainfrom
Sayan-Dhani:fix-QCD-shape-unc-at-flaf
Open

Fix QCD Shape unc, calulated at hist merge step, not event wise Unc, so added data-driven flag so that it do not crash before hist-Merge#281
Sayan-Dhani wants to merge 1 commit into
cms-flaf:mainfrom
Sayan-Dhani:fix-QCD-shape-unc-at-flaf

Conversation

@Sayan-Dhani

@Sayan-Dhani Sayan-Dhani commented Jul 8, 2026

Copy link
Copy Markdown

Title: Exclude data-driven shape uncertainties from per-event tree processing (fixes QCDScale crash)

Description:

Problem
QCDScale is a data-driven shape uncertainty for the HH→bbττ QCD ABCD estimate: its Up/Down templates are built after histogramming, from the OS_AntiIso/SS_Iso/SS_AntiIso sideband regions — there is no per-event weight variation and no corresponding Events__QCDScale__Up/Down tree in the anaTuple.

However, every stage that consumes unc_cfg_dict["shape"] assumed the opposite: that each key in that section names a real tree-level systematic requiring an Events__<unc>__<scale> tree. Adding QCDScale there (to give it a datacard nuisance name) made three independent stages try to load a tree that was never produced, crashing with:

RuntimeError: ERROR: tree Events__QCDScale__Up not found in file ...
KeyError: 'Events__QCDScale__Up'
at HistTupleProducerTask, HistFromNtupleProducerTask, and (latent, not yet hit in production but same code path) AnalysisCacheProducer.

Fix
Introduce a data_driven: true flag on a shape entry (set in the main repo's weights.yaml for QCDScale) and skip flagged entries wherever a stage builds its list of per-event/tree-level uncertainties to process:

Analysis/HistTupleProducer.py (createHistTuple): scale_uncertainties now skips data_driven entries.
Analysis/AnalysisCacheProducer.py (createAnalysisCache): same skip (same bug pattern; would have crashed identically once this stage runs with unc variations enabled).
Analysis/HistProducerFromNTuple.py: uncs_to_compute now skips data_driven entries, so it neither looks up a Events__QCDScale__* tree nor produces {var}_QCDScale_{scale}-named histograms.

The Analysis/HistMergerFromHists.py's fill_hists, which needed the opposite treatment (see HH_bbtautau PR 74 ), and tasks.py's HistMergerTask.uncNames construction, which correctly still includes QCDScale unfiltered — the merge stage is exactly where this data-driven uncertainty is supposed to be built and consumed.

…so added data-driven flag so that it do not crash before histMerge
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