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

properly treat averaging with self in GhostTrackVertexFinder::vtxMean #37088

Merged

Conversation

slava77
Copy link
Contributor

@slava77 slava77 commented Feb 28, 2022

while debugging in some corner of phase space I noticed that a relatively benign case of averaging of two identical points in GhostTrackVertexFinder::vtxMean can lead to a NaN in the results.
The NaN eventually propagates downstream and leads to
an exception thrown in PerigeeConversions::ftsToPerigeeParameters (cms::Exception("PerigeeConversions", "Track with pt=0")), which is actually caught in

} catch (const cms::Exception& ex) {
if (ex.category() != "PerigeeConversions")
throw;
edm::LogInfo("TrajectoryStateClosestToPoint_PerigeeConversions")
<< "Caught exception " << ex.explainSelf() << ".\n";
valid = false;
. Apparently, given no checks for finiteness, a perp computed on a 3D vector of NaN values looks like a zero.

I'm proposing a simple fix to return one of the identical points.

I'm adding a warning only because this condition was previously leading to a (caught) exception.

(Also, I'm not familiar enough with GhostTrackVertexFinder to conclude that an averaging with self is an indication of a logic error and that a fix upstream is needed.)
After some tests in relvals, the conditions seems to happen in O(1e-3) events.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-37088/28574

  • This PR adds an extra 20KB to repository

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

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-37088/28576

  • This PR adds an extra 20KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @slava77 (Slava Krutelyov) for master.

It involves the following packages:

  • RecoVertex/GhostTrackFitter (reconstruction)

@jpata, @cmsbuild, @clacaputo, @slava77 can you please review it and eventually sign? Thanks.
@GiacomoSguazzoni, @JanFSchulte, @rovere, @VinInn, @mmusich, @mtosi, @dgulhan this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@slava77
Copy link
Contributor Author

slava77 commented Feb 28, 2022

@cmsbuild please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-85247b/22718/summary.html
COMMIT: fd748b1
CMSSW: CMSSW_12_3_X_2022-02-28-1100/slc7_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/37088/22718/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 17 differences found in the comparisons
  • DQMHistoTests: Total files compared: 49
  • DQMHistoTests: Total histograms compared: 4001207
  • DQMHistoTests: Total failures: 7
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 4001178
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
  • Checked 204 log files, 45 edm output root files, 49 DQM output files
  • TriggerResults: found differences in 1 / 48 workflows

@@ -123,6 +125,11 @@ static double vtxErrorLong(const GlobalError &error, const GlobalVector &dir) {
static GlobalPoint vtxMean(const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2) {
GlobalVector diff = p2 - p1;

if UNLIKELY (diff.perp2() == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm, I actually meant to use mag2 here. I will update.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-37088/28585

  • This PR adds an extra 20KB to repository

@cmsbuild
Copy link
Contributor

Pull request #37088 was updated. @jpata, @cmsbuild, @clacaputo, @slava77 can you please check and sign again.

@slava77
Copy link
Contributor Author

slava77 commented Feb 28, 2022

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 1, 2022

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-85247b/22725/summary.html
COMMIT: fc78082
CMSSW: CMSSW_12_3_X_2022-02-28-1100/slc7_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/37088/22725/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 7 differences found in the comparisons
  • DQMHistoTests: Total files compared: 49
  • DQMHistoTests: Total histograms compared: 4001207
  • DQMHistoTests: Total failures: 4
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 4001181
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
  • Checked 204 log files, 45 edm output root files, 49 DQM output files
  • TriggerResults: no differences found

@slava77
Copy link
Contributor Author

slava77 commented Mar 1, 2022

Reco comparison results: 7 differences found in the comparisons

136.874 and 35034.0 have one logWarning each related to this PR.

The comparisons also show differences in 39496.0 39500.0 in simPVZ plot
but considering that the plot looks empty, I suspect that it's an unrelated change from some uninitialized value, perhaps triggered by recompilation of a related code.

@slava77
Copy link
Contributor Author

slava77 commented Mar 1, 2022

136.874 and 35034.0 have one logWarning each related to this PR.

So, this apparently means that not all cases of GhostTrackVertexFinder::vtxMean lead to a crash, since these workflows run OK in the baseline.
IMHO, the update is straightforward and the LogWarning is not really required.
@cms-sw/reconstruction-l2 please let me know if this needs to be kept or removed.

@jpata
Copy link
Contributor

jpata commented Mar 1, 2022

so there are no reco differences (in e.g. 136.874), despite the bugfix?

@slava77
Copy link
Contributor Author

slava77 commented Mar 1, 2022

so there are no reco differences (in e.g. 136.874), despite the bugfix?

After debugging this a bit I have updated the description of the PR: the condition was leading to an exception, but the exception was caught, which explains why there is no crash for the events with a warning.

I can confirm that without the fix (in Run: 319450 Event: 105539294; event index 43 in the workflow) this part of the code is producing an invalid point with a -nan and this result is ignored (a default invalid vertex is returned), while with the check in this PR a valid (no nan is returned).

At least in this workflow this PR affects only pfGhostTrackVertexTagInfos, which contributes to pfGhostTrackBJetTags, which is saved in RECO, but it has no monitoring either in the standard DQM or in the reco validate.C

@jpata
Copy link
Contributor

jpata commented Mar 2, 2022

@emilbols are pfGhostTrackVertexTagInfos actually used for physics anywhere, if they are not monitored?
cc @cms-sw/btv-pog-l2

@jpata
Copy link
Contributor

jpata commented Mar 4, 2022

+reconstruction

  • bugfix for ghost track vertices, with minimal physics effect, but prevents a rare crash
  • ghost track btags are not monitored, and per an email exchange, could potentially be considered as deprecated, I opened an issue here: pfGhostTrackVertexTagInfos deprecated? #37140

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 4, 2022

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 now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2)

@qliphy
Copy link
Contributor

qliphy commented Mar 4, 2022

+1

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.

5 participants