Repository navigation
Response-based pixel multiplicity weights and variations - #771
Draft
davidwalter2 wants to merge 1 commit into
Draft
davidwalter2 wants to merge 1 commit into
davidwalter2 wants to merge 1 commit into
Conversation
… variations
The pixel multiplicity correction gives a muon one of two weights by its own
pixel-hit flag, w0 = p0_data / p0_MC without a valid pixel hit and
w1 = (1 - p0_data) / (1 - p0_MC) with one. The few percent of muons without
a valid pixel hit carry a weight far from one, so the templates of the 49
variations are dominated by the binomial fluctuation of their number per bin.
Muons without a valid pixel hit differ from the others by their momentum
resolution only. The probability f0 of no valid pixel hit can therefore be
given as a function of the generated pt and the reco/gen curvature ratio of a
muon, and the muon weighted by the expectation of the flag weight,
w = (1 - f0) w1 + f0 w0. This is the same weight on average for any process
and selection, without the binomial noise.
- muon_calibration.hpp: matchedGenMuonPt, qopRatioRecoGen,
PixelMultiplicityProbability, PixelMultiplicityResponseHelper and
PixelMultiplicityResponseUncertaintyHelper. Muons without a matched
generated muon get the average probability, for which the nominal weight
is one.
- muon_calibration.py: make_pixel_multiplicity_helpers takes the correction
file and the kind of weights (auto, response, flag, both).
PixelMultiplicityColumns and define_pixel_multiplicity_cols[_dimuon] give
the helpers their input columns. With "both" the variations with the flag
weights are booked in addition, as nominal_pixelMultiplicity{Syst,Stat}Flag.
- mz_dilepton.py books the response of the two muons with and without a
valid pixel hit for the simulated samples (hPixelResponse{Trig,NonTrig}).
- pixel_multiplicity_utils.py, make_pixel_corrections.py: the probability map
(hZeroPixelProb) from these histograms, stored in the correction file next
to the pixel hit multiplicities. The response of the muons with a valid
pixel hit is a standardized shape with a width that depends on the
generated pt, the one of the others its convolution with a Gaussian, fitted
per eta bin with a binned Poisson likelihood. The script takes the output
file name, and optionally the multiplicities from a second histmaker output.
- W, W-like and dilepton histmakers: --pixelMultiplicityWeights and
--pixelMultiplicityFile. setupRabbit --pixelMultiplicityWeights flag takes
the flag-based variations of an output made with "both"; the nuisance names
and groups stay the same.
With a correction file without the probability map, such as the one in
wremnants-data, the weights are the flag-based ones as before ("auto").
The clang-format hook also rewraps one existing comment in
muon_calibration.hpp.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GdFuNtsTV5EX87okA51kTz
|
CI ✅ on |
Collaborator
|
How is the map actually built here? It would make sense for this to somehow be unified with the ML reweighting scheme in the ONNX weights. |
Collaborator
|
And is the resulting weight distribution actually significantly better? (I would assume that events in the tails of the response distribution, ie with reco pT far from the gen pT, still get large weights for the variations.) |
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.
Summary
The pixel multiplicity correction and its 49 variations weight a muon by its own pixel-hit flag:
w0 = p0_data / p0_MCwithout a valid pixel hit,w1 = (1 - p0_data) / (1 - p0_MC)with one. Only a few percent of the muons have no valid pixel hit, and those carry a weight far from one, so the variation templates are dominated by the binomial fluctuation of the number of such muons in each bin.This PR adds weights without that noise. Muons without a valid pixel hit differ from the others by their momentum resolution only. The probability
f0of no valid pixel hit can therefore be given as a function of the generated pt and the reco/gen curvature ratio of a muon, and the muon weighted by the expectation of the flag weight:This is the same weight on average for any process and selection.
Changes
muon_calibration.hpp:PixelMultiplicityProbability(lookup off0),PixelMultiplicityResponseHelper,PixelMultiplicityResponseUncertaintyHelper, andmatchedGenMuonPt/qopRatioRecoGenfor the inputs. A muon without a matched generated muon gets the average probability, for which the nominal weight is one.muon_calibration.py:make_pixel_multiplicity_helpers(filename, reverse_variations, weights).PixelMultiplicityColumnsanddefine_pixel_multiplicity_cols[_dimuon]give each helper its input columns.mz_dilepton.pybooks the response of the two muons with and without a valid pixel hit for the simulated samples (hPixelResponseTrig,hPixelResponseNonTrig: eta, generated pt, charge, reco/gen curvature ratio, pixel class).wremnants/postprocessing/pixel_multiplicity_utils.pyandscripts/corrections/make_pixel_corrections.py: the probability maphZeroPixelProbfrom these histograms, stored in the correction file next to the pixel hit multiplicities. Per eta bin, the response of the muons with a valid pixel hit is a standardized shape whose width depends on the generated pt, and the response of the others is its convolution with a Gaussian; both are fitted with a binned Poisson likelihood. The script now takes the output file name (-o) and can take the multiplicities from a second histmaker output (--inputFilePixelHits).--pixelMultiplicityFileand--pixelMultiplicityWeights auto|response|flag|both.bothuses the response-based weights and books the flag-based variations in addition, asnominal_pixelMultiplicity{Syst,Stat}Flag.setupRabbit.py --pixelMultiplicityWeights flagtakes the flag-based variations of an output made withboth. Nuisance names and groups are the same in either case.Default behaviour
Unchanged with the correction file that is in wremnants-data now: it has no probability map, so
autofalls back to the flag weights and logs a warning. On 20 Z files the dilepton output with the defaults agrees to 3e-15 in all 519 histograms with one made before this change; the only additions are the two response histograms.Usage
Validation
With a map from the full Z simulation, the response of muons without a valid pixel hit is wider than that of the others by 1.1% (|eta| < 0.8) to 16% (2.3 < |eta| < 2.4) at a generated pt of 40 GeV. The predicted probability agrees with the simulated fractions with chi2/ndf = 1.10 over all generated-pt and curvature-ratio bins.
Full-statistics W histograms, fully correlated variation, relative to the nominal (the noise is estimated from two independent halves of the simulation):
--reweightPixelMultiplicityis given).This branch was ported from a development branch; on the same events its dilepton, W-like and W outputs with
bothagree with the ones of that branch to 2e-15 in all histograms (apart fromnominal_gen_smeared, which uses random numbers), andmake_pixel_corrections.py,setupRabbit.pywith either set of variations and the fits run on a 30-file output of all datasets.Open points
--pixelMultiplicityFile. Once it is there the response-based weights become the default.p0_MCin the correction. The other is a pt-dependent difference of 1-2e-4 that is not understood yet.🤖 Generated with Claude Code
https://claude.ai/code/session_01GdFuNtsTV5EX87okA51kTz