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
LowPtElectrons: fix for UL FastSim mini v2 and nano v9 workflows #35181
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35181/25114
|
A new Pull Request was created by @bainbrid for master. It involves the following packages:
@jpata, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@cmsbuild please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-b28116/18429/summary.html Comparison SummarySummary:
|
const edm::Ptr<pat::PackedCandidate>* ptr1 = | ||
ele.hasUserData("ele2packed") ? ele.template userData<edm::Ptr<pat::PackedCandidate>>("ele2packed") | ||
: nullptr; | ||
const edm::Ptr<pat::PackedCandidate>* ptr2 = | ||
ele.hasUserData("ele2lost") ? ele.template userData<edm::Ptr<pat::PackedCandidate>>("ele2lost") | ||
: nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const edm::Ptr<pat::PackedCandidate>* ptr1 = | |
ele.hasUserData("ele2packed") ? ele.template userData<edm::Ptr<pat::PackedCandidate>>("ele2packed") | |
: nullptr; | |
const edm::Ptr<pat::PackedCandidate>* ptr2 = | |
ele.hasUserData("ele2lost") ? ele.template userData<edm::Ptr<pat::PackedCandidate>>("ele2lost") | |
: nullptr; | |
using PackedPtr = edm::Ptr<pat::PackedCandidate>; | |
const PackedPtr* ptr1 = ele.template userData<PackedPtr>("ele2packed"); | |
const PackedPtr* ptr1 = ele.template userData<PackedPtr>("ele2lost"); |
- less verbose
PATObject::userData
already returnsnullptr
if data is not available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (ptr1 != nullptr && ptr1->isNonnull() && ptr1->isAvailable() && ptr1->get() != nullptr && | ||
ptr1->get()->bestTrack() != nullptr) { | ||
return ptr1->get()->bestTrack(); | ||
} else if (ptr2 != nullptr && ptr2->isNonnull() && ptr2->isAvailable() && ptr2->get() != nullptr && | ||
ptr2->get()->bestTrack() != nullptr) { | ||
return ptr2->get()->bestTrack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the string of checks is a bit elaborate and repeated
if (ptr1 != nullptr && ptr1->isNonnull() && ptr1->isAvailable() && ptr1->get() != nullptr && | |
ptr1->get()->bestTrack() != nullptr) { | |
return ptr1->get()->bestTrack(); | |
} else if (ptr2 != nullptr && ptr2->isNonnull() && ptr2->isAvailable() && ptr2->get() != nullptr && | |
ptr2->get()->bestTrack() != nullptr) { | |
return ptr2->get()->bestTrack(); | |
bool hasBestTrack = [] (const PackedPtr* ptr) { | |
return ptr != nullptr && ptr->isNonnull() && ptr->isAvailable() && ptr->get() != nullptr && | |
ptr->get()->bestTrack() != nullptr | |
}; | |
if (hasBestTrack(ptr1)) { | |
return ptr1->get()->bestTrack(); | |
} else if (hasBestTrack(ptr2)) { | |
return ptr2->get()->bestTrack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugins/LowPtGsfElectronIDProducer.cc:166:34: error: 'hasBestTrack' cannot be used as a function
166 | if (hasBestTrack(ptr1)) {
| ^
...
plugins/LowPtGsfElectronIDProducer.cc:162:18: error: the address of 'static constexpr bool LowPtGsfElectronIDProducer::produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const::<lambda(const auto:23&)> [with auto:23 = pat::Electron]::<lambda(const PackedPtr*)>::_FUN(const PackedPtr*)' will never be NULL [-Werror=address]
@slava77 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try auto hasBestTrack =
and ;
at the end of return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (trk != nullptr) { | ||
eid_trk_p = (float)trk->p(); | ||
eid_trk_nhits = (float)trk->found(); | ||
eid_trk_chi2red = (float)trk->normalizedChi2(); | ||
TVector3 trkTV3(0, 0, 0); | ||
trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi()); | ||
TVector3 eleTV3(0, 0, 0); | ||
eleTV3.SetPtEtaPhi(ele.pt(), ele.eta(), ele.phi()); | ||
trk_dr = eleTV3.DeltaR(trkTV3); | ||
} else { | ||
if (ele.core().isNonnull()) { | ||
reco::TrackRef trk = ele.closestCtfTrackRef(); | ||
if (trk.isNonnull()) { | ||
eid_trk_p = (float)trk->p(); | ||
eid_trk_nhits = (float)trk->found(); | ||
eid_trk_chi2red = (float)trk->normalizedChi2(); | ||
TVector3 trkTV3(0, 0, 0); | ||
trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi()); | ||
TVector3 eleTV3(0, 0, 0); | ||
eleTV3.SetPtEtaPhi(ele.pt(), ele.eta(), ele.phi()); | ||
trk_dr = eleTV3.DeltaR(trkTV3); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (trk != nullptr) { | |
eid_trk_p = (float)trk->p(); | |
eid_trk_nhits = (float)trk->found(); | |
eid_trk_chi2red = (float)trk->normalizedChi2(); | |
TVector3 trkTV3(0, 0, 0); | |
trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi()); | |
TVector3 eleTV3(0, 0, 0); | |
eleTV3.SetPtEtaPhi(ele.pt(), ele.eta(), ele.phi()); | |
trk_dr = eleTV3.DeltaR(trkTV3); | |
} else { | |
if (ele.core().isNonnull()) { | |
reco::TrackRef trk = ele.closestCtfTrackRef(); | |
if (trk.isNonnull()) { | |
eid_trk_p = (float)trk->p(); | |
eid_trk_nhits = (float)trk->found(); | |
eid_trk_chi2red = (float)trk->normalizedChi2(); | |
TVector3 trkTV3(0, 0, 0); | |
trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi()); | |
TVector3 eleTV3(0, 0, 0); | |
eleTV3.SetPtEtaPhi(ele.pt(), ele.eta(), ele.phi()); | |
trk_dr = eleTV3.DeltaR(trkTV3); | |
} | |
if (trk != nullptr || (ele.core().isNonnull() && ele.closestCtfTrackRef().isNonnull()) { | |
const reco::Track* tk = trk ? trk : &*ele.closestCtfTrackRef().isNonnull(); | |
eid_trk_p = tk->p(); | |
eid_trk_nhits = tk->found(); | |
eid_trk_chi2red = tk->normalizedChi2(); | |
TVector3 trkTV3(0, 0, 0); | |
trkTV3.SetPtEtaPhi(tk->pt(), tk->eta(), tk->phi()); | |
TVector3 eleTV3(0, 0, 0); | |
eleTV3.SetPtEtaPhi(ele.pt(), ele.eta(), ele.phi()); | |
trk_dr = reco::deltaR(*tk, ele); | |
} |
- remove repeated code
- remove local
trk
shadowing the inputtrk
- drop
(float)
, which is already clear from lhs - remove unnecessary and pretty heavy conversion to
TVector3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35181/25188
|
@cmsbuild please test |
RecoEgamma/EgammaElectronProducers/src/LowPtGsfElectronFeatures.cc
Outdated
Show resolved
Hide resolved
Co-authored-by: Slava Krutelyov <slava77@gmail.com>
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35181/25266
|
@cmsbuild please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-b28116/18606/summary.html Comparison SummarySummary:
|
+reconstruction
|
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) |
@bainbrid |
+1 |
Yes, I already have the branch ready, just need to fold in your suggested changes. Will try to make the PR today. |
PR description:
LowPtGsfElectronIDProducer
when attempting to access anedm::Ref
to the missinggeneralTracksBeforeMixing
collection in AOD.generalTracksBeforeMixing
collection in theGsfElectronCore
andGsfElectron
objects.ElectronSeed
step (obtained from the availablegeneralTracks
collection in AOD), instead of from the KF track embedded in theGsfElectronCore
object (which is chosen based on number of shared hits with theGsfTrack
and obtained from the missinggeneralTracksBeforeMixing
collection in AOD).PR validation:
This PR was validated using cmsDriver commands that performed the GEN->AOD and mini v2 steps, based on those provided here, for tests with the 10_6_X cycle, and modified versions for tests with the 12_1_X release (this PR).
@slava77 @jordan-martins @crovelli