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

Fix a discrepancy in Puppi weights when running on MiniAOD w/ useExistingWeights=False #28033

Merged
merged 1 commit into from Oct 4, 2019

Conversation

hqucms
Copy link
Contributor

@hqucms hqucms commented Sep 20, 2019

PR description:

When running Puppi on MiniAOD w/ useExistingWeights=False, in some cases there is a discrepancy between the puppiWeight and the rescaled pT (i.e., rescaled pT != original pT * packCand->puppiWeight()). This is tracked to:

int iPuppiMatched = fUseExistingWeights ? val : fPuppiContainer->recoToPup()[val];
if (iPuppiMatched >= 0) {
auto const& puppiMatched = lCandidates[iPuppiMatched];
pVec.SetPxPyPzE(puppiMatched.px(), puppiMatched.py(), puppiMatched.pz(), puppiMatched.E());
if (fClonePackedCands && (!fUseExistingWeights)) {
if (fPuppiForLeptons)
pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iPuppiMatched]);
else
pCand->setPuppiWeight(lWeights[iPuppiMatched], pCand->puppiWeightNoLep());
}
} else {
pVec.SetPxPyPzE(0, 0, 0, 0);
if (fClonePackedCands && (!fUseExistingWeights)) {
pCand->setPuppiWeight(0, 0);
}
}
puppiP4s.push_back(pVec);

on L281 and L283, iPuppiMatched should not be used to access the puppi weight from lWeights, as lWeights is 1-to-1 with hPFProduct -- instead val is the correct index.

As this only affects the puppi weights set for the new packedCandidates, this discrepancy does not affect cases when useExistingWeights=True, or running on RECO/AOD inputs.

This PR fixes this discrepancy and also simplifies the logic to compute the Puppi-scaled p4.

@ahinzmann

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28033/11959

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@ahinzmann
Copy link
Contributor

ahinzmann commented Sep 20, 2019

@hqucms this would be a nice simplification.
I wonder if this also works for puppiNoLeptons and puppiForMET, where the particle list is shorter than the original list of candidates, because leptons are removed before running PUPPI?
(if it breaks puppiNoLeptons, we could consider to include a doNoLeptons into the PuppiProducer and get rid of the candidate filter in puppiForMET, simplifying also puppiForMET)

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@hqucms
Copy link
Contributor Author

hqucms commented Sep 20, 2019

@ahinzmann I think nothing should break as the weight list lWeights is always equal to the input candidate list, right? The output particle/p4 list (lCandidates) is not needed after the simplification.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-28033/11961

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @hqucms (Huilin Qu) for master.

It involves the following packages:

CommonTools/PileupAlgos

@perrotta, @cmsbuild, @santocch, @slava77 can you please review it and eventually sign? Thanks.
@rappoccio, @ahinzmann, @riga, @jdolen, @gkasieczka, @clelange this is something you requested to watch as well.
@davidlange6, @slava77, @fabiocos you are the release manager for this.

cms-bot commands are listed here

@ahinzmann
Copy link
Contributor

ahinzmann commented Sep 20, 2019

Ok. Just since I got paranoid with this piece of code, could you make a comparison of puppiMET and the weights of the puppiForMET particles:

  1. running makePuppies on AOD (just like in the official MiniAOD sequence)
  2. running makePuppiesFromMiniAOD on MiniAOD with useExistingWeights=True
  3. running makePuppiesFromMiniAOD on MiniAOD with useExistingWeights=False
    I believe 1. and 2. should be part of some validation workflows, but 3. is not.

In fact it would be nice to have example config for those three cases in the /test folder as well. Currently there is only a test for 2.

@hqucms
Copy link
Contributor Author

hqucms commented Sep 20, 2019

@ahinzmann Since 1 and 2 are in the PR validation workflow, maybe we can first trigger a PR test to check them.

@perrotta
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 20, 2019

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-run-pr-tests/2589/console Started: 2019/09/20 12:13

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-dc8543/2589/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 66 differences found in the comparisons
  • DQMHistoTests: Total files compared: 34
  • DQMHistoTests: Total histograms compared: 2958092
  • DQMHistoTests: Total failures: 303
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2957448
  • DQMHistoTests: Total skipped: 341
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 33 files compared)
  • Checked 145 log files, 15 edm output root files, 34 DQM output files

@hqucms
Copy link
Contributor Author

hqucms commented Sep 26, 2019

Ok. Just since I got paranoid with this piece of code, could you make a comparison of puppiMET and the weights of the puppiForMET particles:

  1. running makePuppies on AOD (just like in the official MiniAOD sequence)
  2. running makePuppiesFromMiniAOD on MiniAOD with useExistingWeights=True
  3. running makePuppiesFromMiniAOD on MiniAOD with useExistingWeights=False
    I believe 1. and 2. should be part of some validation workflows, but 3. is not.

In fact it would be nice to have example config for those three cases in the /test folder as well. Currently there is only a test for 2.

@ahinzmann
I have run the tests on a JetHT 2017F data file for the 3 options and found no change in puppiMET with this PR [0]. I have not figured out how to access the weights for puppiForMET particles though -- it seems that they are not saved in the event content?

[0] https://cernbox.cern.ch/index.php/s/LUlVAKr3vSH47Cp

@hqucms
Copy link
Contributor Author

hqucms commented Sep 26, 2019

Regarding the small changes in the b-tagging discriminants in the PR test: they are caused by changes in numerical precision in the calculation of the puppi scaled p4. Before the PR, the candidate p4 is computed with double -> float (when creating the RecoObj) -> double, now is double -> double without the intermediate conversion. Inserting an intermediate conversion to float can reproduce the old behavior exactly.

@ahinzmann
Copy link
Contributor

@hqucms The puppiForMET particles are indeed no saved. But the puppiNoLepton weights (which is a subset of puppiForMET) are stored in the packedCandidates.
Regarding b-tagging, I'd say we should go for the solution without the intermediate conversion.

@slava77
Copy link
Contributor

slava77 commented Sep 30, 2019

@ahinzmann
please clarify if your comments earlier in the thread were already addressed.
Thank you.

@ahinzmann
Copy link
Contributor

ahinzmann commented Sep 30, 2019

Looking at the three sumET plots in [0], useExistingWeights=True and False indeed look almost the same, however aod2mini looks very different from the other two. It doesn't seem caused by this PR, but certainly something that we need to follow up on.
@hqucms You plotted sumET, but in fact it's better to look at MET (simply called ".pt" in slimmedMETsPuppi)

[0] https://cernbox.cern.ch/index.php/s/LUlVAKr3vSH47Cp

I conclude that the PR is fine.

@slava77
Copy link
Contributor

slava77 commented Oct 2, 2019

+1

for #28033 fc452b1

  • code changes are in line with the PR description
  • jenkins tests pass and comparisons with the baseline show small differences in puppi-related variables in PAT jets and MET
    • local tests show that slimmedJetsPuppi have changes in their kinematics at numerical precision level (the pt stays the same, but eta changes within delta of 4e-6).

@fabiocos
Copy link
Contributor

fabiocos commented Oct 4, 2019

+1

@fabiocos
Copy link
Contributor

fabiocos commented Oct 4, 2019

merge

@cmsbuild cmsbuild merged commit 7903ae0 into cms-sw:master Oct 4, 2019
@ahinzmann
Copy link
Contributor

@hqucms @ALL
Could we backport this to 10_2 and 10_6? During PUPPI tuning activities we stumbled on the same issue and would like to make sure no JetMET analysis is affected by this. Even if production is not affected by this.

@santocch
Copy link

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will be automatically merged.

@hqucms
Copy link
Contributor Author

hqucms commented Oct 14, 2019

@hqucms @ALL
Could we backport this to 10_2 and 10_6? During PUPPI tuning activities we stumbled on the same issue and would like to make sure no JetMET analysis is affected by this. Even if production is not affected by this.

@ahinzmann
Please see #28169 and #28170 for the backports. I made a minimal change to fix the weights, leaving out the code simplification part in this PR (which leads to some small changes in e.g., the b-tag discs at numerical precision level, due to the removal of some float--double conversion).

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

Successfully merging this pull request may close these issues.

None yet

7 participants