In-situ muon efficiency method for the Z dilepton and W analyses - #709
Draft
davidwalter2 wants to merge 2 commits into
Draft
In-situ muon efficiency method for the Z dilepton and W analyses#709davidwalter2 wants to merge 2 commits into
davidwalter2 wants to merge 2 commits into
Conversation
Determine the muon ID/HLT/Iso efficiency scale factors in situ, as Chebyshev polynomials in (pT, uT) fitted as unconstrained nuisances, instead of taking them from external tag-and-probe measurements. Reco and tracking scale factors continue to come from tag-and-probe. Covers both the Z dilepton path and the single-leg W path. Squashed from the following commits: - WIP: in-situ muon efficiency + local changes before merging origin/260216 - In-situ Z muon efficiency: finalize dilepton-only path and fix effStat - In-situ muon efficiency: (pT,uT) extension, both-legs effMC, uT quantiles - In-situ muon efficiency: logit SF, theory-weight fix, pT/uT binning - Restore full tag-and-probe smooth SF helpers alongside reco+tracking - mw: single-leg in-situ muon efficiency at parity with mz_dilepton - In-situ effMC: T&P-aligned probe denominator and tag-unbiased Z effMC - Fix HLT-bit operator precedence in effMC trigger flags; clamp uT at fill - In-situ effMC: logit-Chebyshev smoothing, correlation-factor plots, pt 26-90 - In-situ helpers: separate tag-leg effMC (probe conditional, tag unbiased) - In-situ SF: linear f_pass = 1 + P (MC-independent passing leg) - In-situ effMC plots: per-cell eff(uT) cells and 2D eff(pT,uT) maps - plot_insitu_effSF: linear SF = 1 + P parameterization - In-situ efficiency: pt window to 65 GeV and basis orthogonalisation - Fix stale muon collection names in the dilepton CVH SF block Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
davidwalter2
force-pushed
the
260526_inSituEfficiencies
branch
from
August 18, 2026 15:33
8339e1b to
3dac3e2
Compare
The Chebyshev coefficients of the in-situ efficiency parameterisation are strongly correlated under the probe density, which is what made the fit slow, and this recombined them into a basis orthonormal under that density to fix the conditioning. Preconditioning the fit parameters belongs in the fitter, where the transform can be built from the model's own Hessian, refreshed as the fit moves, and changed without regenerating anything upstream; rabbit does that now. Keeping a second mechanism here would mean the histmaker output depends on a basis file that has to be kept identical across the W and Z runs by hand. Removes make_insitu_basis.py, --insituBasisFile from both histmakers and from plot_insitu_effSF.py, the transform plumbing in muon_efficiencies_insitu.py, and the per-block transform matrices from the C++ helper, which goes back to evaluating the raw product basis directly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft — opened for visibility while the scope is still being split. Not ready to merge as-is, see Scope caveats below.
What this adds
An in-situ determination of the muon ID / HLT / Iso data-MC scale factors, as an alternative to the external tag-and-probe SFs. The three efficiency steps are floated as Chebyshev polynomials in (pT, uT), decorrelated per probe-eta bin, as unconstrained nuisances (not NOIs), so the scale factors are determined by the fit itself rather than taken from an external measurement.
The Z dilepton analysis is split into four categories —
nominal,failIso,failHLT,failID— which become four fit channels sharing the same coefficient nuisances, and that cross-category constraint is what determines the efficiencies. Reco and tracking SFs stay external.The passing-leg scale factor is the polynomial directly,
f_pass = 1 + P, which makes it MC-independent; the MC efficiency enters only the failing-leg factorf_fail = (1 - eMC(1+P))/(1 - eMC). Each analysis therefore supplies its own effMC. The method is implemented for both the dilepton (two-leg tag-and-probe) and the W single-muon (single-leg) topologies through a shared C++ base. The coefficients are common to W and Z, so the two can be fitted simultaneously with the scale factors fully correlated between them.The exact likelihood is linearised around a central point and iterated:
make_insitu_effSF.pyaccumulatestheta_new = theta_prev + delta * n_hat, fed back via--insituSFFile.Workflow
mz_dilepton.py --makeInsituEffMC --makeUTQuantileHists— probe spectra and uT quantile inputsscripts/corrections/make_insitu_effMC.py— per-step MC efficienciesmz_dilepton.py --insituEffMCFile ...— templates and coefficient response tensorssetupRabbit.py --muonInsituEfficiencywith the four--baseNamesmake_insitu_effSF.pyto produce the next iteration's central coefficientsConditioning of the coefficients
Chebyshev polynomials are orthogonal under the weight
1/sqrt(1-x^2), which is nothing like the probe density, so the coefficients come out strongly correlated — correlation condition number 6.1e4 over the 2112-coefficient block in the 2D fit, 1.3e5 in the 4D one. That is what made the fit slow:trust-krylov's inner solve needs ~sqrt(kappa)Hessian-vector products, and steps get rejected. Measured on the full-statistics 2D fit: 145 minutes, with 20 of 78 iterations returning a bit-identical loss and the worst single iteration burning 27 minutes to make no progress.This branch previously carried an offline fix (
make_insitu_basis.pyplus--insituBasisFile) that recombined the coefficients into a basis orthonormal under the probe density. That has been removed in favour of preconditioning the fit parameters inside the fitter, WMass/rabbit#150, which builds the transform from the model's own Hessian, refreshes it as the fit moves, and needs no regenerated inputs upstream. The offline version also required the same basis file to be used across the W and Z histmakers by hand, since the nuisances are correlated between them — a consistency requirement nothing checked.For reference, on the same full-statistics 2D input: unpreconditioned 145.5 min, the offline basis 179 min, preconditioning in rabbit 14.3 min. All three converge to genuine minima; the preconditioned fits reach EDM ~1e-16 against ~1e-11 unpreconditioned.
Scope caveats
260216_totalPhaseSpacebranch (make_pixel_corrections.py,setup.sh,.gitignore). Those are not part of this feature and should be split out or land separately.--insituEffMCFilethe histmakers follow the existing external tag-and-probe path unchanged.🤖 Generated with Claude Code