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

ele/ph mass fix #36889

Closed
wants to merge 3 commits into from
Closed

ele/ph mass fix #36889

wants to merge 3 commits into from

Conversation

rgoldouz
Copy link
Contributor

@rgoldouz rgoldouz commented Feb 4, 2022

PR description:

Hello,
The electron and photon mass are not saved properly and nanoAOD users reported that many times. It is not related to nanoAOD. The problem is available in miniAOD too.
You can check the printout here
http://dalfonso.web.cern.ch/dalfonso/NANO/massDump.txt

I checked and found that the problem is not from the EGamma code but from TLorentzVector root class. I found that the TLorentz vector is set via pxpypzE for all object candidates. It seems fine but when I tested locally for a particle with pxpypzE=(1,1,1,sqrt(3)) I did not get the mass==0. You can easily reproduce it
root -l
root [1] typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D > XYZTLorentzVectorD
root [2] XYZTLorentzVectorD newP4(1,1,1,sqrt(3));
root [3] newP4.M()
(double) -2.1073424e-08

It is because of the precision problem in TLorentz vector and it is recommended to use PxPyPzM to have correct masses for low mass objects.
https://root.cern.ch/doc/master/classROOT_1_1Math_1_1PxPyPzM4D.html

So I set the electron and photon masses by hand to 0.0005 and 0 GeV , respectively.

PR validation:

I generated electron and photon up to reco level using fastsim cmsDriver command and checked the photon and electron mass before and after this fix. Wrong mass values before the fix are corrected after the fix.

please let me know if you have any question.
Thanks ,
Reza

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 4, 2022

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-36889/28160

  • This PR adds an extra 32KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 4, 2022

A new Pull Request was created by @rgoldouz (Reza Goldouzian) for master.

It involves the following packages:

  • RecoEgamma/EgammaElectronAlgos (reconstruction)
  • RecoEgamma/EgammaPhotonProducers (reconstruction)

@jpata, @cmsbuild, @clacaputo, @slava77 can you please review it and eventually sign? Thanks.
@Sam-Harper, @jainshilpi, @valsdav, @rovere, @lgray, @sobhatta, @lecriste, @afiqaize, @wrtabb, @varuns23, @ram1123 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

}
} else {
math::XYZVector gamma_momentum = direction.unit() * scRef->energy();
math::XYZTLorentzVectorD p4(gamma_momentum.x(), gamma_momentum.y(), gamma_momentum.z(), scRef->energy());
newCandidate.setP4(p4);
newCandidate.setMass(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

use PolarLorentzVector. This is the internal representation of reco candidate p4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello Slava,

The setMass function does this transformation.
https://cmssdt.cern.ch/lxr/source/DataFormats/Candidate/interface/ParticleState.h#0159

Do you mean to use,
math::PtEtaPhiMLorentzVector p4(gamma_momentum.Pt(), gamma_momentum.Eta(), gamma_momentum.Phi(), 0.0);
I could not find Pt function in math::XYZVector.

Please let me know your opinion.
Thanks,
Reza

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I meant to replace the XYZT p4 construction and setP4;setMass with just a construction of Polar p4 followed by setP4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Slava,

As I mentioned, math::XYZVector does not have the Pt function. I need to recalculate it and I afraid to introduce bug there. What is wrong with using setMass function?
It does this transformation automatically using setCartesian function,
https://cmssdt.cern.ch/lxr/source/DataFormats/Candidate/interface/ParticleState.h#0159

Thanks,
Reza

Copy link
Contributor

Choose a reason for hiding this comment

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

typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;

@Sam-Harper
Copy link
Contributor

are we sure we want to set the electron mass to 0.5 MeV?

As far as I'm aware, all E/gamma code treats the electron as massless and has for ever (modulo this bug where it its not exactly zero due to rounding errors.

Why not continue to set it to zero as was intended. Is there is a compelling use case to need to adjust the momentum such that the mass is 0.5 MeV? It seems like such a small effect which is best ignored.

Otherwise, thanks for the fix Reza!

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 8, 2022

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-36889/28216

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 8, 2022

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

@rgoldouz
Copy link
Contributor Author

rgoldouz commented Feb 8, 2022

Thanks Sam,
I just updated the code with setting ele mass = 0.

Please let me know if you have any further comment.

Thanks,
Reza

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 8, 2022

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-36889/28218

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 8, 2022

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

@clacaputo
Copy link
Contributor

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 8, 2022

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-36176d/22288/summary.html
COMMIT: c401a22
CMSSW: CMSSW_12_3_X_2022-02-08-1100/slc7_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/36889/22288/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: 231 differences found in the comparisons
  • DQMHistoTests: Total files compared: 46
  • DQMHistoTests: Total histograms compared: 3765080
  • DQMHistoTests: Total failures: 262
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 3764795
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: -0.004 KiB( 45 files compared)
  • DQMHistoSizes: changed ( 312.0 ): -0.004 KiB MessageLogger/Warnings
  • Checked 193 log files, 42 edm output root files, 46 DQM output files
  • TriggerResults: no differences found

@jpata
Copy link
Contributor

jpata commented Feb 9, 2022

to be a bit more verbose, I think Slava's suggestion to use more precise arithmetic through typedef math::PtEtaPhiMLorentzVector PolarLorentzVector; should be tried here.
(math::XYZVector was not suggested and seems to be a miscommunication)

@rgoldouz
Copy link
Contributor Author

Hi @jpata ,
Sorry for my late reply.
As I wrote in my reply to Slava,
If I change the code like this;
math::PtEtaPhiMLorentzVector p4(gamma_momentum.Pt(), gamma_momentum.Eta(), gamma_momentum.Phi(), 0.0);
I need to use gamma_momentum.Pt(), but there is no Pt() function in gamma_momentum which is a math::XYZVector.
I think the corresponding function should be R(). But I afraid to destroy all photon object and found SetMass() function much safer

Please let me know your opinion.

Thanks,
Reza

@jpata
Copy link
Contributor

jpata commented Feb 11, 2022

Perhaps something like this?

math::PtEtaPhiMLorentzVector p4(gamma_momentum.rho(), gamma_momentum.eta(), gamma_momentum.phi(), 0.0);
newCandidate.setP4(p4);

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.

6 participants