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

pat::Muon best track embedding fix (7.0.X) Copied from #4359 #4446

Merged
merged 2 commits into from Jul 1, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions DataFormats/PatCandidates/src/Muon.cc
Expand Up @@ -13,6 +13,8 @@ using namespace pat;
/// default constructor
Muon::Muon() :
Lepton<reco::Muon>(),
embeddedMuonBestTrack_(false),
embeddedTunePMuonBestTrack_(false),
embeddedTrack_(false),
embeddedStandAloneMuon_(false),
embeddedCombinedMuon_(false),
Expand All @@ -37,6 +39,8 @@ Muon::Muon() :
/// constructor from reco::Muon
Muon::Muon(const reco::Muon & aMuon) :
Lepton<reco::Muon>(aMuon),
embeddedMuonBestTrack_(false),
embeddedTunePMuonBestTrack_(false),
embeddedTrack_(false),
embeddedStandAloneMuon_(false),
embeddedCombinedMuon_(false),
Expand All @@ -61,6 +65,8 @@ Muon::Muon(const reco::Muon & aMuon) :
/// constructor from ref to reco::Muon
Muon::Muon(const edm::RefToBase<reco::Muon> & aMuonRef) :
Lepton<reco::Muon>(aMuonRef),
embeddedMuonBestTrack_(false),
embeddedTunePMuonBestTrack_(false),
embeddedTrack_(false),
embeddedStandAloneMuon_(false),
embeddedCombinedMuon_(false),
Expand All @@ -85,6 +91,8 @@ Muon::Muon(const edm::RefToBase<reco::Muon> & aMuonRef) :
/// constructor from ref to reco::Muon
Muon::Muon(const edm::Ptr<reco::Muon> & aMuonRef) :
Lepton<reco::Muon>(aMuonRef),
embeddedMuonBestTrack_(false),
embeddedTunePMuonBestTrack_(false),
embeddedTrack_(false),
embeddedStandAloneMuon_(false),
embeddedCombinedMuon_(false),
Expand Down Expand Up @@ -195,7 +203,7 @@ reco::TrackRef Muon::dytTrack() const {

/// reference to Track giving best momentum (global PFlow algo)
reco::TrackRef Muon::muonBestTrack() const {
if (embeddedMuonBestTrack_) {
if (!muonBestTrack_.empty()) {
return reco::TrackRef(&muonBestTrack_, 0);
} else {
return reco::Muon::muonBestTrack();
Expand All @@ -204,7 +212,7 @@ reco::TrackRef Muon::muonBestTrack() const {

/// reference to Track giving best momentum (muon only)
reco::TrackRef Muon::tunePMuonBestTrack() const {
if (embeddedTunePMuonBestTrack_) {
if (!tunePMuonBestTrack_.empty()) {
return reco::TrackRef(&tunePMuonBestTrack_, 0);
} else if (muonBestTrackType() == tunePMuonBestTrackType()) {
return muonBestTrack();
Expand Down Expand Up @@ -236,6 +244,7 @@ reco::CandidatePtr Muon::sourceCandidatePtr( size_type i ) const {
/// embed the Track selected to be the best measurement of the muon parameters
void Muon::embedMuonBestTrack(bool force) {
muonBestTrack_.clear();
embeddedMuonBestTrack_ = false;
bool alreadyEmbedded = force;
if (!force) {
switch (muonBestTrackType()) {
Expand All @@ -258,6 +267,7 @@ void Muon::embedMuonBestTrack(bool force) {
void Muon::embedTunePMuonBestTrack(bool force) {
tunePMuonBestTrack_.clear();
bool alreadyEmbedded = force;
embeddedTunePMuonBestTrack_ = false;
if (!force) {
switch (muonBestTrackType()) {
case None: alreadyEmbedded = true; break;
Expand Down