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

Fixed sign in pat::Muon::dB() to match one obtained from the best track definition #28753

Merged
merged 7 commits into from
Feb 7, 2020
4 changes: 4 additions & 0 deletions PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,8 @@ void PATMuonProducer::embedHighLevel(pat::Muon& aMuon,
IPTools::signedTransverseImpactParameter(tt, GlobalVector(track->px(), track->py(), track->pz()), primaryVertex);
double d0_corr = result.second.value();
double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
// Now correct the sign using information from the track
d0_corr = (track->dxy(primaryVertex.position()) > 0 ? 1 : -1) * fabs(d0_corr);
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be

Suggested change
d0_corr = (track->dxy(primaryVertex.position()) > 0 ? 1 : -1) * fabs(d0_corr);
d0_corr = std::copysign(d0_corr, track->dxy(primaryVertex.position()));

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, I'd modify on L1102 instead. There is no significant need to assign one value and then to apply this correction.

aMuon.setDB(d0_corr, d0_err, pat::Muon::PV2D);

// PV3D
Expand All @@ -1117,6 +1119,8 @@ void PATMuonProducer::embedHighLevel(pat::Muon& aMuon,
result = IPTools::signedTransverseImpactParameter(tt, GlobalVector(track->px(), track->py(), track->pz()), vBeamspot);
d0_corr = result.second.value();
d0_err = beamspotIsValid ? result.second.error() : -1.0;
// Now correct the sign using information from the track
d0_corr = (track->dxy(beamspot) > 0 ? 1 : -1) * fabs(d0_corr);
aMuon.setDB(d0_corr, d0_err, pat::Muon::BS2D);

// BS3D
Expand Down